Generator-jhipster: wiredep should not exclude angular-locale_fr.js

Created on 5 Feb 2015  路  9Comments  路  Source: jhipster/generator-jhipster

As angular-i18n is excluded from wiredep in Gruntfile.js, angular-i18n/angular-locale_fr.js is also excluded and so date filter cannot localize month and day names for instance.

I tried to come up with a regexp to exclude all but fr and en but it does not cover all cases like country variants and could be error prone when users add other languages

/angular-i18n\/angular\-locale\_(?!(en|fr))[a-z][a-z]\.js/

So either we remove the original exclusion /angular-i18n/ at the cost of adding not required files, or we manually include them in index.html outside the wiredep markers.

If we choose the second option, we should document it in 'Installing new languages'.

Most helpful comment

You can use bower overrides in order to get wiredep adding your locale file:

{
  ...
  "dependencies": {
    "angular-i18n": "1.0.0"
  },
  "overrides": {
    "angular-i18n": {
        "main":  [
            "angular-locale_fr.js"
        ]
    }
  }
}

I hope this could be useful.

All 9 comments

Does anybody knows why angular-i18n was excluded?

The reason why it's excluded is the language file angular-i18n/angular-locale_fr.js (as for any of the angular-locale files in angular-i18n folder) was not included when the wiredep support was implemented.

This referense to index.js script shows what vender javascript files was included in index.html bebore the wiredep task was configured:
https://github.com/jhipster/generator-jhipster/blob/2cd0dbd439f6700a93785665fd259eaf274f7e4b/app/index.js#L847

Not sure why though but i think it has to do with that JHipster uses angular-dynamic-locale to load the locale files.

I also suspect that this was overlooked because date formatting using month or day names was not used in default entities views.

Or maybe it's just me as I'm writing a French only app so not really concerned about locale switching.

I'll test with a freshly generated app.

Sorry, it fails only in my app, it works fine on sample app.

You can use bower overrides in order to get wiredep adding your locale file:

{
  ...
  "dependencies": {
    "angular-i18n": "1.0.0"
  },
  "overrides": {
    "angular-i18n": {
        "main":  [
            "angular-locale_fr.js"
        ]
    }
  }
}

I hope this could be useful.

Thanks @lifeisfoo I just used it and it works like a charm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaidohallik picture kaidohallik  路  3Comments

edvjacek picture edvjacek  路  3Comments

tomj0101 picture tomj0101  路  3Comments

chegola picture chegola  路  4Comments

Steven-Garcia picture Steven-Garcia  路  3Comments