Skip Navigation

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 1 reply, has 2 voices.

Last updated by Itamar 1 month, 3 weeks ago.

Assigned support staff: Itamar.

Author Posts
June 17, 2020 at 12:24 pm #6393905

Webber

Hello,

I do not want the /zh-hans as a suffix of the translated Chinese pages of my website which is English by default.

So I added a custom language via WPML ->Languages->Edit languages and add a new custom language for Chinese. Added the desired language code of "cn" and made sure to use a different default locale from the original language.

The problem is that when I enable the "Browser language redirect" option, the Chinese browser do not redirect to the /cn directory because this output is generated:

/* <![CDATA[ */
var wpml_browser_redirect_params = {
   "pageLanguage":"en",
   "languageUrls":{
      "en_US":"https:\/\/dev.webber.nl\/innovatest",
      "en":"https:\/\/dev.webber.nl\/innovatest",
      "US":"https:\/\/dev.webber.nl\/innovatest",
      "de_DE":"https:\/\/dev.webber.nl\/innovatest\/de\/",
      "de":"https:\/\/dev.webber.nl\/innovatest\/de\/",
      "DE":"https:\/\/dev.webber.nl\/innovatest\/de\/",
      "ja":"https:\/\/dev.webber.nl\/innovatest\/ja\/",
      "pl_PL":"https:\/\/dev.webber.nl\/innovatest\/pl\/",
      "pl":"https:\/\/dev.webber.nl\/innovatest\/pl\/",
      "PL":"https:\/\/dev.webber.nl\/innovatest\/pl\/",
      "cn_CN":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "cn":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "CN":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "nl_NL":"https:\/\/dev.webber.nl\/innovatest\/nl\/",
      "nl":"https:\/\/dev.webber.nl\/innovatest\/nl\/",
      "NL":"https:\/\/dev.webber.nl\/innovatest\/nl\/",
   },
   "cookie":{
      "name":"_icl_visitor_lang_js",
      "domain":"dev.webber.nl",
      "path":"\/innovatest\/",
      "expiration":24
   }
};
/* ]]> */

I would like to add the following to this "languageUrls" list:

      "zh_CN":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "zh":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "ZH":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "zh_SG":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "sg":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "SG":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "zh_TW":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "tw":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "TW":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "zh_HK":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "hk":"https:\/\/dev.webber.nl\/innovatest\/cn\/",
      "HK":"https:\/\/dev.webber.nl\/innovatest\/cn\/",  

Is this possible? Please help!

June 18, 2020 at 4:54 pm #6406179

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

The 'Browser language redirect' feature of WPML works according to the language that is set on the browser of the user that is accessing the site. Your custom language code (cn) is not a language code that browsers recognize. Please see this link as a reference.
hidden link
Therefore, I'm afraid that it can not work.

In any case, even if there is a JS solution for this, I'm sorry but this would be our of the scope of our support forum. https://wpml.org/purchase/support-policy/.

At the following link, you can submit a feature request that goes directly to our developers.
https://wpml.org/suggest-a-new-feature-for-wpml/
They will consider whether it is possible or needed to add this feature.

Otherwise, I can also suggest you consider contacting one of our certified partners from this link: https://wpml.org/contractors/
Before doing so please have a look also here:
https://wpml.org/documentation/about-wpml-contractors/what-type-of-work-you-can-expect-from-contractors/
With our contractors, you might get the custom assistance you need to get on with your project.

Best Regards,
Itamar.

The topic ‘[Closed] How to add custom language to wpml_browser_redirect_params’ is closed to new replies.