Change fallback language during runtime #313
Description
Hi,
First off, thanks for angular-translate, great project! I have run into a use case though, which I don't know how to solve and wanted to reach out for advice/help.
We are in the process of adding support for a second language of our application. Users will be able to select their preferred language. Their preference is persisted in the back-end.
Now for the complication. For some of our customers we use regions to provide custom translations for a subset of labels; 'en_CUSTOMERID'. Because we only translate a subset we also set the fallbackLanguage to 'en'. In other words:
$translateProvider.preferredLanguage('en_CUSTOMERID')
$translateProvider.fallbackLanguage('en')
The problem is that it isn't until runtime that we know the user's preference (either because the user changes it during runtime, or more often because we receive the user's preferences through our initial call to the back-end). To my knowledge, at runtime, the only option available is to set the user's preference through $translate.uses(). This can lead to the following situation:
$translateProvider.preferredLanguage('en_CUSTOMERID')
$translateProvider.fallbackLanguage('en')
....
$translate.uses('nl_CUSTOMERID')
What I would like to do is something like $translate.fallbackLanguage('nl'), to match the user's preferred 'base' language. What are my options? The only moment to set the fallbackLanguage is via the translateProvider, which is only available during module.config() and I don't see how I can know the user's preferences at that time (as opposed to the application's default language).
Any help would be much appreciated.
Kind regards,
Elger
p.s. I tried starting a new google groups topic instead of this issue, but it looks like the group is configured in such a way that this isn't allowed.