Background of the issue:
Our WordPress website uses WPML to support multiple languages. We want to change the language slugs from /zh-hans/ to /zh/ for Simplified Chinese and from /zh-hant/ to /tw/ for Traditional Chinese. We have tried using the wpml_language_url filter, wpml_get_home_url filter, and manually rewriting URLs via the rewrite_rules_array hook in functions.php without success. We checked WPML settings, but the UI does not allow direct modification of language codes. The new URLs should replace the current ones while preserving all translations and SEO settings.
Symptoms:
Unable to change WPML language slugs from /zh-hans/ to /zh/ and /zh-hant/ to /tw/ using available methods.
Questions:
Does WPML officially support changing language slugs?
Is there a proper way to change language slugs without breaking existing translations?
Thank you for contacting WPML support. While you are waiting for one of my colleagues to take this ticket and work on it, let me provide you with first debugging steps or if I can perhaps help with the issue quickly.
Please note that by design it is not possible to edit the language code of default languages.
However, you would be able to add a new custom language ( Chinese(Simplified) ) with your custom language code(zh).
Since you already have content in Chinese Simplified, you can duplicate the existent "Zh-hans" content in the new language "zh".