Title: Language Code with hyphen problem
Last modified: May 2, 2019

---

# Language Code with hyphen problem

 *  [Nethub](https://wordpress.org/support/users/nethub/)
 * (@nethub)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/language-code-with-hyphen-problem/)
 * Hi all,
 * According to Google: [https://support.google.com/webmasters/answer/189077](https://support.google.com/webmasters/answer/189077)
 * > The value of the hreflang attribute identifies the language (in ISO 639-1 format)
   > and optionally a region (in ISO 3166-1 Alpha 2 format) of an alternate URL.(
   > The language need not be related to the region.) For example:
   >  de: German language content, independent of region
   >  en-GB: English language
   > content, for GB users de-ES: German language content, for users in Spain
 * Since some languages have different types, such as Chinese Traditional and Chinese
   Simplified, ISO 639-1 format only describes 1 language code “zh” for both Chinese
   languages, but we cannot fill “zh” for both Chinese Traditional & Chinese Simplified
   at the same time.
 * From Google answer, we should use “zh-TW” / “zh-CN” or “zh-Hant” / “zh-Hans” 
   instead (ISO 3166-1 Alpha 2), so that I fill “zh-TW” & “zh-CN” in the fields “
   Language Code (ISO 639-1)”.
 * It works everywhere (e.g. “Settings” page, “Pages” page), except this:
    1. go
   to Page 2. Edit a page 3. Current URL is /wp-admin/post.php?post=92&action=edit
   4. Change language from English (en) to Chinese Traditional (zh-TW) 5. Current
   URL is /wp-admin/post.php?post=92&action=edit&edit_lang=zh-tw 6. Change language
   from Chinese Traditional (zh-TW) to English (en) 7. Current URL is /wp-admin/
   post.php?post=92&action=edit&edit_lang=en-tw 8. You can see “edit_lang” becomes“
   en-tw” unexpectedly, and now current page is not really English, but still Chinese
   Traditional
 * I found the problem can be fixed by below:
 * [Edit includes/admin/class-wpm-admin-gutenberg.php and change the line]
    href
   = url + query.replace(/edit_lang=[a-z]{2,4}/i, ‘edit_lang=’ + lang) + document.
   location.hash; [to] href = url + query.replace(/edit_lang=[a-z-]{2,5}/i, ‘edit_lang
   =’ + lang) + document.location.hash;
 * Can developer confirm above is good or not, and apply it in future update?

The topic ‘Language Code with hyphen problem’ is closed to new replies.

 * ![](https://ps.w.org/wp-multilang/assets/icon-256x256.png?rev=1760406)
 * [WP Multilang - Translation and Multilingual Plugin](https://wordpress.org/plugins/wp-multilang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-multilang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-multilang/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-multilang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-multilang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-multilang/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Nethub](https://wordpress.org/support/users/nethub/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/language-code-with-hyphen-problem/)
 * Status: not resolved