You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
I am using the angular-translate and in the configuration of my application I have the following:
`corporativas.config(['$translateProvider',
function ($translateProvider) {
//TRANSLATION SYSTEM
$translateProvider.useStaticFilesLoader({
prefix: 'locales/locale-',
suffix: '.json'
});
$translateProvider.registerAvailableLanguageKeys(['en', 'es']);
$translateProvider.preferredLanguage('en'); //manual decision of translation provider
$translateProvider.fallbackLanguage('en');
$translateProvider.useSanitizeValueStrategy('sanitize');
$translateProvider.useCookieStorage(); //use cookie storage to save the language of the user, updated everytime it changes
}]);`
But the languages that are defined in the function registerAvailableLanguageKeys () are static, but for my application these values must be obtained from the database.
I understand that in the angle config I can not make asynchronous calls because the angular life cycle executes the config first and may not return anything at run time.
So I was wondering if anyone knows how to update the values of the registerAvailableLanguageKeys () from a controller or from the run.
version:
Angularjs: 1.6.4
Angular-translate: 2.15.1
The text was updated successfully, but these errors were encountered:
Well. Hardly. As you said already: The config is a life cycle phase which is done prior before anything else.
You can solve this issue with adding such values either within your page template processor (i.e. as HTML meta tags and re-parsing them again), a custom (blocking?) script injected with dynamic values and adding data to your DOM or with a custom AngularJS bootstrapper which loads (without AngularJS) some configurations before.
Personally, I'm fine with the first one (depends whether page modifications are possible).
I need to do something similar, how can I inject new texts on runtime to translate new texts after the angular config phase was procesed? I don't understand the explanations of @knalli
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I am using the angular-translate and in the configuration of my application I have the following:
`corporativas.config(['$translateProvider',
function ($translateProvider) {
//TRANSLATION SYSTEM
$translateProvider.useStaticFilesLoader({
prefix: 'locales/locale-',
suffix: '.json'
});
$translateProvider.registerAvailableLanguageKeys(['en', 'es']);
$translateProvider.preferredLanguage('en'); //manual decision of translation provider
$translateProvider.fallbackLanguage('en');
$translateProvider.useSanitizeValueStrategy('sanitize');
$translateProvider.useCookieStorage(); //use cookie storage to save the language of the user, updated everytime it changes
}]);`
But the languages that are defined in the function registerAvailableLanguageKeys () are static, but for my application these values must be obtained from the database.
I understand that in the angle config I can not make asynchronous calls because the angular life cycle executes the config first and may not return anything at run time.
So I was wondering if anyone knows how to update the values of the registerAvailableLanguageKeys () from a controller or from the run.
version:
Angularjs: 1.6.4
Angular-translate: 2.15.1
The text was updated successfully, but these errors were encountered: