This thread is resolved. Here is a description of the problem and solution.
Problem: The client is concerned about maintaining their current URLs with the language code /es_ES/ when switching to WPML, which uses the language code /es/ by default. They want to avoid 404 errors and are considering whether to redirect all /es_ES/ URLs to /es/ or to create new languages with the old site's language codes.
Solution: We recommend two options: 1. If you decide to use the predefined language code /es/, you should set up redirects from /es_ES/ to /es/. This cannot be done through the WPML GUI, so you would need to use custom functions, such as adding rules to the .htaccess file or using a redirection plugin.
2. If you prefer to keep using /es_ES/, you can create a custom language in WPML. First, change the default locale for the predefined /es/ language to something else (e.g., es_ESS), and then you can use es_ES for your custom language. Remember to set the correct default locale and hreflang for your language.
For more details on editing WPML's language table and setting up language codes, please visit our documentation.
If this solution does not seem relevant to your situation, please open a new support ticket in our support forum.
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.
Sorry guys, but I have to question something again. I closed a ticket because I changed my mind, but now I am not sure if my decision is the best solution. I am going to be concise this time.
My old/actual site has this type of urls for translated content:
hidden link
Note that the language code is /es_ES/ and not /es/
I don't want my actual urls to be lost or 404. What do you recomend?
1. Redirect all /es_ES/ to WPML /es/ or
2. Create new languages, that will use my actual/old site languages codes?
If you recommend me solution 1, how do you recommend me to do redirects? with htacces rules, or by using WordPress native redirect functions, such as redirect_guess_404_permalink()? source: hidden link
If you recommend me solution 2, what should I set on the default locale? Currently I get "The defaul locale already exists".
Question? Why is so difficult to change the code?
Is there any documentation that you are following?
Nope.
Is there a similar example that we can see?
Nope.
What is the link to your site?
Is a developing site.
Thank you, and sorry for arising this question again. It is an important decision that will last many years!
I have carefully reviewed your request and believe you need to decide. However, I would like to provide you with some helpful information.
I understand that you are currently using the language code /es_ES/. With WPML, you can utilize a pre-defined language with the code /es/ or create a custom language.
To create a custom language, you must change the default locale for the pre-defined /es/ language to something else. Once done, you can use the locale es_ES for your custom language.
If you decide to use the language code /es/, it is recommended that you set up redirects. Unfortunately, the WPML GUI does not have any tools for this. You must use custom functions, such as adding them to the server side (e.g., the .htaccess file), or employ a redirection plugin.
Andrey, thank you very much for your kind response.
If you were me, what solution would you choose? I am doubtful.
What is the locale used for? From what I have read, I understood it is for translating strings within wordpress core files (that is translation for the admin) but I am not sure.
Can I name the new locale anything I want? for example, es_ES_custom? Or does it have the adhere to some rule?
Andrey, one more important question that I just thought about. We are using WordPress API to fetch posts. I was told before buying this plugin that WPML works with translations over API calls. Does it work as well with custom languages? This is a fundamental feature on our blog.
If you would like to see how we use it, you can go to the homepage, search for "All posts" and search for anything:
hidden link
you can try searching for "ai".
Thank you.
New threads created by Andrey and linked to this one are listed below:
Thank you for your feedback regarding language codes. If the code /es_ES/ is working for you, it would be OK to leave it as is. However, the code /es/ looks more pleasing.
Ensuring you have set the correct Default locale and hreflang for your language is essential.
The default locale refers to the locale active for your language when loading GetText translations. This means that WordPress, plugins, and themes' standard translations will be loaded by locale, not just for the admin.
Hreflang refers to the code that Google expects for your language. The language tag should contain the same information as the locale name but formatted differently. For example, if the locale for Canadian French is fr_CA, the corresponding language tag would be fr-ca. Instead of an underscore, use a dash, and ensure all letters are lowercase.
If you choose the predefined language code /es/, you do not need to do anything about the default locale. However, if you are creating a custom language and want to use the locale es_ES for your custom language, you must first change it for predefined (for example, es_ESS) since it already exists. WPML does not allow the use of existing locales for custom languages.
Andrey, thank you very much for your detailed response. After some trying , I decided that I am using default WPML languages, and using pre_redirect_guess_404_permalink() wordpress core filter, to redirect my users if they type an old url /es_ES/ to my new url /es/. This solution is more elegant and much more simple than creating three custom languages. Thank you very much for your time. I didn't marked this as resolved, because I wanted tell you this, and thank you for your time and patience.