Skip to content
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

Without Lang Prefix #20

Open
KVRA opened this issue Mar 14, 2022 · 7 comments
Open

Without Lang Prefix #20

KVRA opened this issue Mar 14, 2022 · 7 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@KVRA
Copy link

KVRA commented Mar 14, 2022

My site is multi-domain
( next config like: )

...
  i18n: {
    locales: ['en-US', 'fr-FR', 'de-DE'],
    defaultLocale: 'en-US',
    domains: [
      {
        domain: 'dev.site.com',
        defaultLocale: 'en-US',
        http: true,
      },
      {
        domain: 'dev.site.fr',
        defaultLocale: 'fr-FR',
        http: true,
      },
    ],
...

But my links now have are like : "dev.site.fr/fr-FR/example"
How to remove the language sufix since I already do it by domain ?
I managed to do like that

  <Link
      href={href}
      as={translateUrl(href, router.locale, {
        withoutLangPrefix: true,
        format: 'string',
      })}
    >

is this the proper way ? Can I remove all the language prefix everywhere ?
Also how to make the url "site.fr/sell" redirect to "site.fr/vendre" instead of redirecting with the lang prefix "site.fr/fr-FR/vendre/"

PS. THANKS FOR YOUR WORK ON THIS !

@zergu
Copy link

zergu commented Jul 6, 2022

We have same issue with unintended adding locale to url path. We use language subdomains so we end up with broken urls.

@cvolant
Copy link
Collaborator

cvolant commented Jul 25, 2022

Subdomains... I didn't thought about that...
Yes, it is not supported yet but it must be.
I will post here when I start working on it, but I don't know yet when that will be possible. Feel free to work on it yourself : pull requests are welcome.

@cvolant cvolant added bug Something isn't working enhancement New feature or request labels Jul 25, 2022
@cvolant
Copy link
Collaborator

cvolant commented Mar 1, 2023

I gave it a try here, but there is still some issues to tackle.

I tried to set localhost:3000 and localhost:3001 as different domains, then launch on instance on each port to test it locally, but even without next-translate-routes, it creates looping redirections. Do you have an idea why?

    domains: [
      {
        domain: 'localhost:3000',
        defaultLocale: 'en-US',
        http: true,
      },
      {
        domain: 'localhost:3001',
        defaultLocale: 'fr',
        http: true,
      },
    ],

I leave it as is for now, since I need to work on other subjects. Feel free to give it a try too, you can reuse my PR. I will post here again when I will work on it again.

@KVRA
Copy link
Author

KVRA commented Mar 3, 2023

I have created a fork to make this, I only had to change one line in fileUrlToUrl
gindumac@4ef06b1

But It should change not depenging on the env variable but instead based on the next config domains array, still works for me, currently using it on a big site :)

Where can I buy you a coffee ? Thanks

@cvolant
Copy link
Collaborator

cvolant commented Mar 3, 2023

I only had to change one line in fileUrlToUrl

Is it really enough?! 😮
I am quite surprised because fileUrlToUrl is not the only place where a lang prefix is added...
Do you have a way to test multi domain routing locally?

Where can I buy you a coffee ?

😄
Well, if you really want to, you can do it here: https://don.hozana.org/je-donne

@KVRA
Copy link
Author

KVRA commented Jun 1, 2023

Yes, it works and its working in prod for a while now, I use this functions to sitemap, alternative lang links etc...
Just added dev.site.com and dev.site.de to my /etc/hosts pointing to 127.0.0.1 and added those domains to next.config

I didn't made a PR since I only E2E test without unit test :P but it works !

If you want to see in prod the English version is gindumac.com

@cvolant
Copy link
Collaborator

cvolant commented Jun 1, 2023

Ok, cool.
It would be good to make something clean on the repo so that it works for everybody, but I need to test multi domain routing locally, and it did not work when I tried. Lately I have too much to do to be able to work on this (and we don't need it for ourselves) : so I need help to tackle this.
Do you have a working config I could build on? I tried this but even without next-translate-routes, it does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants