rainlab/translate-plugin

Translation fallbacks not working anymore

tschortsch opened this issue · 5 comments

Since updating to the latest version of the plugin our translation fallbacks don't work anymore for me. I tracked the issue down to this change: 4ec9302.

The hasTranslation() function now returns true if there is an empty string in the rainlab_translate_attributes table which seems to be the case for nearly all our items. Even worse those empty strings can't be removed via the backend since saving an empty field adds the empty string record to the database.

When I revert this change the fallbacks work again but when I now save a translated item it always get saved to the database even if I didn't touch the value (it saves the string from the fallback language as translation). Is this intended to happen?

Hey @tschortsch

Can you try this commit, it seems to satisfy both use cases: ca559b8

Thanks for the change 👍🏻 With that the fallbacks work again! But when I open an entry, switch the site (locale) in the backend and directly save (without changing anything) a new database entry is created in the rainlab_translate_attributes table with all the original strings inside.

Try this one: 997e05e

Wow you're crazy, thanks a lot! Only thing which might be strange is that now an empty array is saved to the database if there are no translated attributes. I fixed this in this PR: #715. With that the whole translation entry gets removed from the database if there are no translated attributes.

Discussion on this moved to #720