Use fallbackLanguage when using determinePreferredLanguage
See original GitHub issueWhen I use determinePreferredLanguage
I would like to use fallbackLanguage
or any other special defined fallback when determine methods retruns locale code which is not in my available langague keys.
@PascalPrecht is there any way to achive that?
For now I defined smth like this:
$translateProvider.useStaticFilesLoader({
prefix: 'resources/translations/',
suffix: '.json'
});
$translateProvider.useLocalStorage();
$translateProvider.useMissingTranslationHandlerLog();
$translateProvider.registerAvailableLanguageKeys(
['pl', 'en'],
{
'en*': 'en',
'pl*': 'pl',
'*': 'en' // must be last!
}
);
$translateProvider.fallbackLanguage('en');
$translateProvider.determinePreferredLanguage();
and it works well, but it will be better to define it 😃
Issue Analytics
- State:
- Created 9 years ago
- Reactions:5
- Comments:11 (2 by maintainers)
Top Results From Across the Web
angular-translate - Fallback language for ...
How can I register a fallback language if the determinePreferredLanguage() returns a language key my code doesn't know? I want to fall back...
Read more >5b. How to add a language - Traceur Fabmob
By default, the fallback language is english but it can easily be modified by just changing en in the line below by the...
Read more >Angularjs – angular-translate – Fallback language for ...
I use angular-translate in my app. How can I register a fallback language if the determinePreferredLanguage() returns a language key my code doesn't...
Read more >Use Localization in AngularJS Using Internationalization
This article shows how to implement Localization using AngularJS.
Read more >Introduction of translation in your project - Angular Translate
PS: This post is for Angular1 and using Angular Translate for translation ... determinePreferredLanguage() //load fallback language .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, but if i call
determinePreferedLanguage()
it will internally set the language to the determined language, or am I wrong? It will at least set what is returned by$translateProvider.preferredLanguage()
.I had a problem with this code:
In a polish Browser the last line will fail with
Plural Function not found for locale: pl_PL
which leads me to the assumption thatdeterminePreferredLanguage()
is setting something internally. If I change the code to (as suggested by @mrzepinski):everything works fine. So in this case
determinePreferredLanguage()
will not return or set pl.A preferred language is the requested language one, but not an actual available or selected one.