3

I've downloaded the angular I18n repo using bower install angular-i18n which pulls it into my bower_compontents and updates the bower.json file with angular-i18n : 1.5.3, which is expected behavior.

I want to include a specific locale(ex. de-de.js) in my build process so that it gets included along with the other angular scripts, every time I run grunt serve which isn't happening at the moment. Any ideas how this can be achieved?

Thanks.

SinSync
  • 488
  • 1
  • 6
  • 16

3 Answers3

1

In my case, I added in my bower file the specific version that i need using the link of the raw version of the file angular-locale_es.js. bower.json

"dependencies": {
    "angular": "^1.5.0",
    "angular-mocks": "^1.5.0",
    ...
    "angular-locale_es": "https://raw.githubusercontent.com/angular/bower-angular-i18n/master/angular-locale_es.js",
     ...
  }
1

In your bower.json you can add an overrides section and specify the i18n script you want to include.

{
  "name": "your application",
  "version": "1.1.2",
  "dependencies": {
    "angular": "#1.5.7",
    "angular-i18n": "#1.5.7",
 "moment": "#2.13.0",
  },
  "overrides": {
    "angular-i18n":{
      "main":[
        "angular-locale_de-ch.js"
      ]

    },
    "moment": {
      "main": [
        "moment.js",
        "locale/de.js"
      ]
    },
  }
}
RenRen
  • 10,550
  • 4
  • 37
  • 39
0

So to answer my own question, if you only want one of the locales you can copy and replace the contents of the de-de.js locale into the main angular-i18n file, which is hassle free and does not require a complicated approach.

However if you have multiple locales and want to make a decision based on a condition, you can set a default locale using this library

https://github.com/lgalfaso/angular-dynamic-locale/

after which all you have to do is add a base location for your locale files(I'm using the CDN for example): tmhDynamicLocaleProvider.localeLocationPattern('https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.5.5/angular-locale_{{locale}}.js');

check for your condition and pass the locale as $translate.use('de');

Hope that helps!

SinSync
  • 488
  • 1
  • 6
  • 16