Fallback to default language if field is empty#5
Fallback to default language if field is empty#5selwin wants to merge 4 commits intozmathew:masterfrom
Conversation
|
Thanks again for the suggestions. It's great to get feedback from people using this app. But this one is a little controversial with the other devs at my company. I agree that it is consistent with i18n / gettext, but not sure if I agree with this behaviour. One of the reasons pointed out was that this behaviour hides the fact that you're missing a translation. This issue is also related to the "content to be translated later" problem. Right now, if I had a "not null" translatable field, I MUST fill in ALL translations before saving or else the db will give me an error. I'm going to think about this one, not quite sold on merging it in yet. |
|
Hi Matthew, The final decision is of course yours but let me try to convince you why I think my proposed behavior makes sense ;) So I believe there are two issues, which I believe are slightly different:
In my case, having a fall back is important because I'm integrating linguo to an already existing project with an existing model. When south creates non blank fields, south will ask for defaults. The only sensible values are "" (empty string) or |
now accounts for none and empty
changed test for language fallback
|
First of all thanks for the app, it is really useful. I would propose, to address the point number 2, that we add a setting (that can be turned on for instance on a development or qa environment) that when no translation is provided returns a [MISSING TRANSLATION] string instead of falling back to indicate the missing translation. We could also add a setting to disable the fallback so that the changes don't impact apps already in production. I can make this change if there is real interest in pursuing this fallback approach because i would really enjoy to go back to the canonical version of the app instead of pointing to my fork. |
Hello,
I use linguo in a project where not all products are translated - and for these products I have to display the original text.
I modified
MultilingualModel'sgetterto fallback to the default language so instead of doing:I can do:
There are a few reasons why I think this is good:
Obviously, this change breaks a few tests that expect non translated fields to return an empty string. But I'll update those if you plan on merging this in.
If you're worried about breaking existing projects, we can also make this behavior optional through a flag in settings.py (LINGUO_FALLBACK).
Let me know what you think!
Regards,
Selwin