-
-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiple languages per domain #2418
Comments
I also have this problem and want to know how to solve it |
I made a workaround BUT its a bit of a hack, if you enable it you will experience text flickering sometimes (solved the flickering).. idk why but it will flicker from defaultLocale to selectedLocale @BobbieGoede sorry for tag :) but do you have any idea why this is happening? this is the only issue i have with this workaround What i did was i set strategy to "no_prefix" added pages:extend hook for all locales that require prefix:
made plugin 01.loadLocale.ts
made pinia store localeStore with boot function and userLocale (i use this var when i want to know what lang user has)
navigateTo composable:
then you need a global middleware to make sure locales that shouldnt be accessible on certiant domains are not.. ex: domain1.com cant have hu,it prefixes so if url contains hu,it at the start redirect him to 404 not found.. would paste code but there is alot of code that is irellevant here.. also if user gets redirected to error.vue you need to navigate user yourself |
On request the module uses the configured strategy, locales and defaultLocale (and more) to navigate/redirect users and load the appropriate locale messages. If it is detected that a certain locale should be loaded, the module will also set the locale, I can only guess, but I think your code and the module code are fighting to switch locale 😅.. You might have more luck by setting I can see the value of this feature but it I think would be quite complex to implement with the way the module is built currently. You might have better results by splitting the i18n configs for |
Thanks for response :) I had some time and played around a bit more.. I've updated package to latest version had beta before, enabled lazy mode and i am no longer experiencing flickering.. idk what fixed it but maybe its because i have more content getting loaded and it has time to init lang bundle 😅? (flickering was only at the start from default to selected, after that everything was fine just on the inital load).. so yeah it is possible to use multiple langs per domain you just need to hack it a bit :p.. I have updated my answer with full code if anyone wants to try :) |
I have the same problem, is there any solution? |
Setting differentDomains does not solve this scenario |
I am in a need for similar feature and couldn't find any up-to-date workaround so thought I would have a go for it myself. You can see the changes in this commit: bjerggaard@d610dd6 This feature did break some of the differentDomains tests and I couldn't get my head around the reason for following line in the current code: Line 47 in dd86b7b
Perhaps @kazupon can shed a light on this? For me, it looks like no_prefix is implied when using differentDomains in the current codebase.
|
Thank you for your PR.
Then the solution will cover most of usecases |
I have updated the PR with latest changes from main branch. |
@bjerggaard |
@BobbieGoede appreciate it, thanks :-) |
Describe the feature
add ability to specify prefix for each language on top of domain.
so paths would look like this:
domain1.com => sl lang
domain1.hr => hr lang
domain2.com/en => en lang
domain2.com/hu => hu lang
if user hits "domain2.com" it redirects him to "domain2.com/defaultLocale"
i am willing to implement this myself but i need a bit of guidance since i am new to nuxt / ts :)
Additional information
Final checks
The text was updated successfully, but these errors were encountered: