Invisible Internationalization?
Unanswered
ncls. posted this in #help-forum
ncls.OP
Is there a way to make internationalization invisible (no
This type of URL just doesn't look good for webapps and often just causes issues when people with different language settings share URLs. I want to prevent that.
/en, de or whatever in the URL) like in normal React projects using i18n?This type of URL just doesn't look good for webapps and often just causes issues when people with different language settings share URLs. I want to prevent that.
10 Replies
@ncls. Is there a way to make internationalization invisible (no `/en`, `de` or whatever in the URL) like in normal React projects using i18n?
This type of URL just doesn't look good for webapps and often just causes issues when people with different language settings share URLs. I want to prevent that.
You can do it like you would do dark mode
@joulev You can do it like you would do dark mode
ncls.OP
I use next-themes for dark mode. But you mean storing the language info in the local storage as i18n usually does that? Can I just use i18n as it usually works on normal React projects?
Or can I maybe use the approach Next.js features in their documentation but cookie-based rather than URL-based?
@ncls. I use next-themes for dark mode. But you mean storing the language info in the local storage as i18n usually does that? Can I just use i18n as it usually works on normal React projects?
I don’t know how i18n “usually works†on normal react projects, so can’t comment on that.
A typical i18n solution would rely on the url to provide locale information, but since you want it to be invisible that’s not applicable.
Then the only way to do it is by using a state-based solution. Which is like the way you would handle theming.
That said, just don’t. The locale params provide language info not only to users but to search engines as well - you don’t want to prevent German version of your pages from showing on Google right? Secondly, to resolve the problem of sharing URLs, you can simply handle redirection when an incoming request has the locale different from the expected language in the header
A typical i18n solution would rely on the url to provide locale information, but since you want it to be invisible that’s not applicable.
Then the only way to do it is by using a state-based solution. Which is like the way you would handle theming.
That said, just don’t. The locale params provide language info not only to users but to search engines as well - you don’t want to prevent German version of your pages from showing on Google right? Secondly, to resolve the problem of sharing URLs, you can simply handle redirection when an incoming request has the locale different from the expected language in the header
Putting the locale in the url is an established good practice and you should follow that
ncls.OP
SEO doesn't matter for this since it won't show up in search engines either way. That's why I'm focusing on usability which would be better if there was no language in the URL
If I share a YT link with you, you don't want to suddenly have your YouTube switch to german because the URL says so. That's what I want to prevent here
@ncls. If I share a YT link with you, you don't want to suddenly have your YouTube switch to german because the URL says so. That's what I want to prevent here
YouTube locale depends on the user settings. If you want to do it the YouTube way, you need to save the preferred locale into the database, but then it will be simple won’t it
Asiatic Lion
did you find any solution for this ?