It seems that the current documentation for the aurelia-i18n plugin no longer produces a working solution.
I am using the aurelia loader and the cli project type. I have followed the documentation but when my app loads I get an error - “failed loading locales/en/translation.json”. I know that the translation.json file can at least be seen by my app because I get a 200 response in the network log.
I have tried various configs but nothing seems to work. As of now, below is what my config looks like:
import {Backend, TCustomAttribute} from ‘aurelia-i18n’;
…
aurelia.use.plugin(‘aurelia-i18n’, (instance) => {
let aliases = [‘t’, ‘i18n’];
// add aliases for ‘t’ attribute
TCustomAttribute.configureAliases(aliases);
// register backend plugin
instance.i18next.use(Backend.with(aurelia.loader));
// adapt options to your needs (see http://i18next.com/docs/options/)
// make sure to return the promise of the setup method, in order to guarantee proper loading
return instance.setup({
backend: { // <-- configure backend settings
loadPath: 'locales/{{lng}}/{{ns}}.json', // <-- XHR settings for where to get the files from
},
attributes: aliases,
lng : 'en',
fallbackLng : 'en',
debug : false
});
});
I am sure I am simply missing something but I am not 100% sure because following the documentation doesn’t result in success either. Any ideas what I might be missing?