Custom localePath is not work when navigate or change language
See original GitHub issueI use next and express to create server. I use next-i18next to create multilingual web app. I have project structure
├── dist/ # Built files
├── public/ # Static files (locales)
└── src /
├── component/ # Components
├── lib/ # Store i18n.js
├── pages/ # Pages
└── server.js
And file i18n.js
const NextI18Next = require('next-i18next')
module.exports = new NextI18Next({
localeSubpaths: true,
otherLanguages: ['fr'],
localePath: 'public/locales/'
})
Everything work fine on page start. But when I navigate to other page with Link
provided by this lib or change language with i18n.changeLanguage(i18n.language === 'en' ? 'fr' : 'en')}
. The new language is not loaded properly.
I found that the server is still try to download the locale files from /static/locales
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Custom localePath is not work when navigate or change ...
Everything work fine on page start. But when I navigate to other page with Link provided by this lib or change language with...
Read more >Language Switcher doesn't apply the new locale
I was looking for this anwer, but I have a problem, his.$router.replace(this.switchLocalePath(language)); only changes URL but does not refresh ...
Read more >Advanced Features: Internationalized Routing
Generally a Locale Identifier is made up of a language, region, and script separated by a dash: language-region-script . The region and script...
Read more >Translation | Django documentation
LocaleMiddleware ). If you haven't yet, see How Django discovers language preference. ... Specify a translation string by using the function gettext() ....
Read more >leancoders/next-i18next
If you want to structure your translations/namespaces in a custom way, you will need to pass modified localePath and localeStructure values ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have found the solution. just use express.static to map static path to target path like
And problem is now gone.
I’ve reflected on this problem in https://github.com/isaachinman/next-i18next/issues/42, which I’d like to discuss first before submitting the PRs with fixes 😉 I refer to
localePath
aspathToTranslations
there. Will get back to you when I’ve got some time.