Detecting locale using env variables not working
I am trying to get my multi domain locale detection working but it isn't.
I don't want to use a prefix, it is different domains and I want to try out the translation in dev.
I have:
Then I set the local using Powershell:
But it loads the english website and is looking for keys in the "en" locale:
And yes, this is true, it does not exist in "en" because "en" is the default language:
So how do I make it look in the "se" locale?
And if the language is "en" I don't want to see this error message.
I don't want to translate english to english. I want to use the full strings in the code instead of using translation keys.
Lastly I need this to work with the generate command. So that I can get a translated website in static format in different languages.
2 Replies
Hi @Zyme. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the knowledge sources, I don't have enough specific details to fully address your question about detecting locale using environment variables in Nuxt. However, I can provide some general guidance and suggestions based on Nuxt i18n configuration:
1. The configuration you've shown uses the
no_prefix
strategy and multiDomainLocales
, which is correct for your use case of different domains without prefixes.
2. Setting an environment variable for the domain may not be sufficient for Nuxt to detect the locale. The i18n module typically uses other methods for detection.
3. For your specific case of wanting to use full strings in the code for English instead of translation keys, you might need to adjust your i18n configuration and how you're handling translations.
To potentially resolve your issues:
1. Make sure your i18n.config.ts
file is properly set up with the correct messages for each locale.
2. Instead of using environment variables, you might want to consider using the detectBrowserLanguage
option in your i18n configuration. This can help with automatic locale detection.
3. For handling English without translation keys, you might need to implement a custom solution or adjust how you're using the $t
function.
4. To avoid the "Not found key" errors for English, you could provide fallback translations or implement a custom handling for the default language.
If you need more specific help, you might want to check the official Nuxt i18n documentation or consider asking a more detailed question with your full i18n configuration and how you're implementing translations in your components.
For further assistance, you might want to check out these resources:
1. Nuxt i18n Documentation
2. Stack Overflow: Nuxt 3 i18n browser detection not working
If these suggestions don't solve your problem, you might want to create a minimal reproduction of your issue and seek help on the Nuxt GitHub Discussions or consider professional support options if available.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@105676519669538816> Kapa.ai is still learning and improving, please let me know how I did by reacting below.