Reputation: 75
I'm currently trying to add localization to my nodeJS backend but im having trouble.
In my frontend (angular) i have an interceptor that sets the language in the header:
Which succesfully works as can be seen below in 'Accept-Language' in the headers of my request:
In my backend app.js i import and configure i18next, i18next-fs-backend, i18next-http-middleware and set the path of the locale files (which can also be seen bellow) and :
But when i try to use the translations in my response it doesn't work, it displays the 'delete_success' and not the translation.
Bellow im posting some stuff that is printed in the req.i18n console.log in case it helps:
bound I18n {
observers: { languageChanged: [ [Function (anonymous)] ] },
options: {
debug: false,
initImmediate: false,
ns: [ 'translation' ],
defaultNS: [ 'translation' ],
fallbackLng: [ 'en' ],
preload: [ 'pt-BR' ],
backend: {
loadPath: './locales/{{lng}}/translation.json',
addPath: '/locales/{{lng}}/{{ns}}.missing.json',
ident: 2,
parse: [Function: parse],
stringify: [Function: stringify]
},
language: 'en',
}
I have no idea what else to try, any tips? :(
Upvotes: 0
Views: 1506
Reputation: 75
I found my problem!
The problem was in the path specified to the locales as shown bellow:
Three hours to figure that out T_T
Upvotes: 2