1

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?

1
  • beautiful question. I have used it as a reference to use static files loader.. couldn't easily find it elsewhere, and that's a shame because that is probably the common use case. Apr 3, 2015 at 19:01

2 Answers 2

0

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?

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.