I am using angular-translate-loader-static-files and it works like a charm. Well... almost. For some reason my json files won't load properly everytime.
I have 2 json files locale-en.json and locale-fr.json
Loaded this way :
$translateProvider.useStaticFilesLoader {
prefix: 'locales/locale-'
suffix: '.json'
}
$translateProvider.useSanitizeValueStrategy(null);
$translateProvider.preferredLanguage 'fr'
Most of the time everything works just fine but sometimes the files aren't loaded, in the network console the locale-xx.json response is index.html
I think the problem comes from modifying the json files, then refreshing the page. Restarting Chrome sometimes fixes this problem, until it comes again.
I solved my problem by adding a / before 'locales/locale-'
$translateProvider.useStaticFilesLoader {
prefix: '/locales/locale-'
suffix: '.json'
}
What happened is that it tried to load locales/local-xx.json from the current url.
For example if I was on the route
localhost:8080/users
the request was
localhost:8080/users/locales/locale-xx.json
instead of
localhost:8080/locales/locale-xx.json