strategy: prefix
doesn't work when locales are set in i18n.config.ts
and fetched from API but not hard coded in nuxt.config.ts
#3288
Labels
Environment
Reproduction
The repo is available here: https://github.com/serhii-chernenko/nuxt-i18n-issue
I also added files to the Stackblitz service: https://stackblitz.com/edit/nuxt-starter-e83jtjvk?file=nuxt.config.ts, but it just doesn't work with dynamic routes. It'd be better to reproduce locally from the GitHub repo mentioned above.
Describe the bug
Nuxt i18n dynamic locales issue explanation
The main goal I want to achieve is fetching locales' setup from a DB.
I have the languages API endpoint
languages.get.ts
:The data is fetched in
i18n.config.ts
:The file is imported via
nuxt.config.ts
:As a result, translations work as expected, but
strategy: prefix
is not.en
andua
locale codes are not included in the URL.The only way I found to fix it, just add:
to the
nuxt.config.ts
:But it doesn't make sense because it's still hardcoded anyway. I want to make
strategy: prefix
working when the whole functionality is dynamic and fetched from the API endpoint (from DB in general).Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: