Reputation: 197
i am working on an application and i want to translate some data in my page. I am using the following angular libraries: angular-translate and angular-translate-loader-static-files.
i have write these config method:
myApp.config(['$translateProvider', function($translateProvider) {
$translateProvider.useStaticFilesLoader({
prefix: appdifConst.context + '/messages/messages_',
suffix: '.json'
});
$translateProvider.preferredLanguage('en');
}]);
As it seem i get all the json files from /message/messages_*.json when my application starts. What i want, is to configure this method above in a way that, when my application start to load, only one of the files (for example english which is the predefined) to loaded and when i click on a link (for example fr) the appi to make a post ajax request and brings the messages_fr.json back. How is that possible?
Upvotes: 1
Views: 842
Reputation: 28648
This sounds like a bug on your side to me, because there's one thing I don't understand..
You say that angular translate downloads ALL the json files.
How does it KNOW which translations exist???
My guess is that there is code with $translationProvider.use(key)
on every language you have.
Perhaps someone thought this is mandatory as part of the setup or something? otherwise it just doesn't make sense that translate will know which translations you have and download them.
Upvotes: 0
Reputation: 8893
Actually, what you want is exactly what angular-translate does. It only loads the language that is currently requested (in your case 'en'). What version do you use?
Upvotes: 0