> I need your help with a design decision.
First of all, thanks for spending some more time on DM, Marcin.
My vote is for:
1b: we should not try to be too magical, explicit is better.
1a: I feel fallback on fields would make instances 'inconsistent'.
By the way, I agree with Jakub that fallback languages should be
configurable. Even more, I think the fallback language is
language-specific. For example, the fallback for 'fr-be' should be
'nl-be', but for 'fr-ca' it should be 'en-ca'.
Regards,
Joost
--
Joost Cassee
http://joost.cassee.net
>> By the way, I agree with Jakub that fallback languages should be
>> configurable. Even more, I think the fallback language is
>> language-specific. For example, the fallback for 'fr-be' should be
>> 'nl-be', but for 'fr-ca' it should be 'en-ca'.
>
> It makes sense, but the configuration is getting complicated.
>
> TRANSLATION_FALLBACK_LANGUAGES = {
> 'fr-be': ['nl-be', 'en'],
> 'fr-ca': ['en-ca', 'en'],
> '': ['en', 'pl'], # for all the other languages
> }
>
> Any ideas for simpler solutions?
Ha! I'd begun typing a similar example, but gave up and hoped you would
come up with something simpler. :-) This is complicated, I agree. So
what about this idea: automatically fallback to the default language
(LANGUAGE_CODE), but allow the developer to override the fallback by
providing a function. For example:
settings.py:
TRANSLATION_FALLBACK_LANGUAGES = 'somemodule.get_fallback_translation'
somemodule.py:
FALLBACK = [[l[0] for l in settings.LANGUAGES]
def get_fallback_translation(lang):
return FALLBACK
or
somemodule.py:
FALLBACK = {...}
def get_fallback_translation(lang):
return FALLBACK[lang]
On the other hand, this might be too much trouble. Maybe we can get away
with Jakub's proposal until anyone complains? (One could, of course,
test the TRANSLATION_FALLBACK_LANGUAGES variable type for a list or a
dict...)
By the way, we might want to start every DM setting with a common
prefix, for example MULTILINGUAL_.