Skip to content
Advertisement

Language getting detected but translation not working with i18n

I have set up the i18n middleware in my Express Node js server like this:

JavaScript

Here is the translation test file:

JavaScript

The value of title in English is title and for Malaysian, it’s tajuk

As per the express middleware documentation, I’m passing my as the accept-language header , and console.log(req.i18n.language) is correctly printing it.

However, console.log(t('title')) is still printing title instead of tajuk

Advertisement

Answer

This looks crazy but this solved the problem:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement