Stephen B. answered 02/22/21
Web Developer Instructor
Thanks for your great feature request. So yea, you right. There's currently no way to change a fallback language at runtime. I refactored the entire fallback language process in canary
branch (or fallback-languages
since its not merged yet), which lets you define more than one fallback language.
So this doesn't solve you problem, I'm just dropping it here to elaborate with you on that. So in angular-translate 2.0 (which will be released hopefully in february) you would do something like this:
This would take care of loading all your fallback translations one by one, so that there are available once needed. Now, when using localStorage to remember the language, it could be that there's e.g. de
stored which is then the actual preferred language, rather than en
.
In such situations, we start iterating over fallback language from the index of the language key that comes out of the storage, an and put the preferred language (the original one en
) at the end of the stack, to make sure the preferred language is also always the last fallback language.
What you want is actually more a way to define an active
fallback language. angular-translate doesn't really care what are your fallback languages. it just iterates over your registered fallback languages, and tries to find translation ids there. If it doesn't find a translation id in a fallback language, it tries the next one.
So when saying we want to tell which fallback language to use in the case where more than one are available, we have to catch that some how.
Just leaving my thoughts here, but I think we should get this in.