In my Angular Translate v2.0.0 projects, I have created three language files: "en.json", "en-US.json", and "en-EU.json" loaded via StaticFilesLoader. I want the translations to fallback to "en.json" if the key doesn't exist in the specific "en-*" file. This works when defining translations with $translateProvider.translations(), but I need to load static files.
Here is an example of the code:
/i18n/en.json
{ "sidebar": { "HEADING": "I AM HEADING" }}
/i18n/en-US.json
{ "formats": { "date": "MM/DD/YYYY" }}
/i18n/en-EU.json
{ "formats": { "date": "DD/MM/YYYY" }}
In the configuration, I use:
// Register a loader for the static files
$translateProvider.useStaticFilesLoader({
prefix: 'i18n/',
suffix: '.json'
});
$translateProvider.preferredLanguage('en-US');
$translateProvider.fallbackLanguage('en');
$translateProvider.useCookieStorage();
$translateProvider.useSanitizeValueStrategy('sanitize');
$translateProvider.useMissingTranslationHandlerLog();
When the application loads, only "formats.date" renders and the error states that "sidebar.HEADING" does not exist.