Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client wanted to separate English into en_us and en_gb variations, with en_us as the default language and its URL changed from domain.com to domain.com/en_us/. They also wanted to implement en_gb at domain.com/en_gb/ while keeping all other languages unchanged.
Solution:
We advised the client that it is not possible to change the language code directly. Instead, we recommended creating custom languages with the en-us and en-gb codes. We instructed the client to:
1. Create a full backup of the database and website.
2. Follow the guide to create the en-us language and duplicate the content to the new language: https://wpml.org/faq/how-can-i-assign-or-change-language-code-to-existing-content/
3. Add the language with the en-gb code by following this guide: https://wpml.org/documentation/getting-started-guide/language-setup/editing-wpmls-languages-table/#adding-your-own-languages-using-wpmls-gui
4.Kindly note that you'll also need to use a different locale for the en_us language because this locale is already used for the default English language. Please check this errata page
Please note that this solution might be irrelevant if it's outdated or not applicable to your case. If so, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket: https://wpml.org/forums/forum/english-support/

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 5 replies, has 2 voices.

Last updated by Mohamed Sayed 10 months, 1 week ago.

Assisted by: Mohamed Sayed.

Author Posts
March 4, 2024 at 8:55 am #15368116

mikeG-21

Hi.

We currently have EN as a default language and about 14 other languages. We want to seperate EN to en_us and en_gb variation. We want to implement it in a way that en_us is still a default language but the URL/permalink of that language is changed from domain.com to domain.com/en_us/, while still keeping all posts/pages assigned to that primary language as they are now. At the same time, we would do redirects from domain.com to domain.com/en_us/, so domain.com would not have any function. Additionally, we want to implement en_gb language variation which would mean that it would live on domain.com/en_gb/. All other languages (FR, DE, ES...) should stay intact.

What would be the best and most optimal way to do this?

Thank you. Regards.

March 4, 2024 at 5:04 pm #15371435

Mohamed Sayed

Hi,
Thanks for contacting WPML support.

It's not possible to change the language code directly, so you can create custom languages with the en-us and en-gb codes.

Please create a full backup of the database and website then follow this guide to create the en-us language and duplicate the content to the new language: https://wpml.org/faq/how-can-i-assign-or-change-language-code-to-existing-content/

Then you can add the language with en-gb code by following this guide: https://wpml.org/documentation/getting-started-guide/language-setup/editing-wpmls-languages-table/#adding-your-own-languages-using-wpmls-gui

Let me know please if that helps.

Kind regards,
Mohamed

March 5, 2024 at 7:07 am #15372699

mikeG-21

Hi Mohamed.

Thank you for your reply.

1. So if I understand this correctly, we need to create 2 new custom languages with those language codes:
- en_gb: This means that the language permalink would be domain.com/en_gb/
- en_us: This means that the language permalink would be domain.com/en_us/

2. After that we need to duplicate the content from the current primary EN language to en_gb and en_us?

3. But what happens with the primary EN language that was sitting on domain.com? Can't this language be available on en_us without any content duplication etc.? Or will the default EN language stay there and we will need to put the redirects to /en_us?

4. Is there any possible way where default language sits on /en_us and the domain.com doesn't have any language function? So basically when you visit domain.com it redirects you to domain.com/en_us by default?

Thank you

March 5, 2024 at 2:20 pm #15374963

Mohamed Sayed

Hi Mike,

1. That's correct, you need to create 2 with those codes. Kindly note that you'll also need to use a different locale for the en_us language because this locale is already used for the default English language. Please check this article https://wpml.org/errata/how-to-add-english-united-states-as-a-custom-language-to-use-as-default-or-translation-language/

2. After that you can duplicate the content to the new language if needed https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/#how-to-duplicate-pages-and-posts-in-bulk

3. The default English language will remain so you need first to switch the default language if needed with the following steps:

- Go to WPML > Language > Site Languages
- Click on "Change Default Language" button and Switch to one of the new languages
- Go to Dashboard > Settings > Permalinks, and resave resave the Permalinks settings

Then you can completely delete the old content and the old language from your site https://wpml.org/faq/how-to-completely-remove-a-language-from-your-site/

4. To add the language directory /en_us/ to the URLs of your new default language, please follow this guide: https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/

March 6, 2024 at 6:57 am #15377125

mikeG-21

Hi.

Thank you for your clarification!

If we follow these steps the default language will be on domain.com/en_us/ and when the user visits the domain.com it will be automatically redirected to domain.com/en_us/, right?

And if he visits some old page or post link for example domain.com/page/ will it be automatically redirected to domain.com/en_us/page/ or do we need to do this with 301 redirects?

Thanks! Regards

March 6, 2024 at 3:56 pm #15380658

Mohamed Sayed

When you add the directory to your default language URLs, you must use a root page. This page will be what your site visitors see when they access the domain name, i.e. domain.com

You can find more details about the root page and how to create it here: https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/#what-is-a-root-page-and-do-i-need-one

Regarding the other question, when someone tries to access an old page link domain.com/page/, they will be redirected to domain.com/en_us/page/

Please see here: hidden link