2

This is my JS file:

function($translateProvider) {
  $translateProvider.useStaticFilesLoader({
    prefix: 'Angular/lang_',
    suffix: '.json'
  })

  $translateProvider.registerAvailableLanguageKeys(['en_US','es_ES', 'pt_PT','fr_FR','de_DE','ja_JP','it_IT'], {  
    'en-*':'en_US',
    'es-*':'es_ES', 
    'pt-*':'pt_PT',
    'fr-*':'fr_FR',
    'de-*':'de_DE',
    'ja-*':'ja_JP',
    'it-*':'it_IT',
    '*':'en_US'//For languages other than the above, fallback language is English.
  })    
}]

I have to add this file into my app.js, on some condition (when they need a translation service). So I have to separate this file and only include it when it is necessary. Is there any way to do it in angularjs, like adding require(file)?

Please do help. Thanks in advance!

qxz
  • 3,814
  • 1
  • 14
  • 29
  • 1
    Have you tried `document.write('')`? – Naman Dec 16 '16 at 07:39
  • Possible duplicate of [How to include a remote JavaScript file conditionally?](http://stackoverflow.com/questions/8085111/how-to-include-a-remote-javascript-file-conditionally) – Emre Türkiş Dec 16 '16 at 08:03

0 Answers0