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.

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Shekhar Bhandari 2 years, 8 months ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
December 21, 2017 at 8:21 am

reiL

I am trying to:
Multi site Installation of which the urls to consider are below.
a) hidden link ( Base Site)
b) hidden link

For language setup we have followed this settings hidden link

Now we were in need to use custom language code that is 'zh' in place of 'zh-hans' hidden link

So what we did was we used the plugin WPML Language Mapping and had following code for custom language code

add_filter( 'wpml_language_codes_map', 'wpml_map', 10, 1 );
function wpml_map( $map ) {
if(in_array('zh-hans', $map)){
$map[ 'zh-hans' ] = 'zh';
}
if(in_array('zh-hant', $map)){
$map[ 'zh-hant' ] = 'zh';
}
return $map;
}

Also to make sure this code exutes on top of WPML plugin we added a code as below

add_action( 'activated_plugin', 'my_plugin_load_first' );
function my_plugin_load_first()
{
$path = str_replace( WP_PLUGIN_DIR . '/', '', __FILE__ );
if ( $plugins = get_option( 'active_plugins' ) ) {
if ( $key = array_search( $path, $plugins ) ) {
array_splice( $plugins, $key, 1 );
array_unshift( $plugins, $path );
update_option( 'active_plugins', $plugins );
}
}
}

After which everything worked as expected we were able to create articles, posts, products, events and even translate them through lionbridge and it worked fine however when we created the pages in corresponding 'zh-hans' language the url came out to be fine in wp-admin as see hidden link

But when we opened that it redirected to not found page and the url surprisingly changes to have 'zh-hans' and 'zh' both in url hidden link

However when we uncheck the setting "Use directory for default language" the custom 'zh' language code works fine just it doesnt 'en' in our case default language code to urls

Is there a way out to use default language code directory and also use 'zh' instead of 'zh-hans' for simplfied/traditional chinese

December 22, 2017 at 8:32 am #1464263

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Thank you for contacting WPML support. I'd be happy to help you on this.

It seems you want to change the language code zh-hant to zh, and for this, you have created few functions, instead of creating the codes to change this, I suggest you create the new language and duplicate all current content into that language, this way you will not face any issues at all.

For further details, please check this ticket: https://wpml.org/forums/topic/change-language-id-in-url/#post-593333

Let me know if that helps.

Thanks

December 22, 2017 at 9:41 am #1464349

reiL

Hi Shekhar -

You suggested to create a new language with language code and that way we wont have issue. That's right we were using that setup earlier, but unfortunately that custom language code was not accepted by third party translation service. Lion Bridge expect the ISO format language code as 'zh-hans' (simplified) and 'zh-hant' (traditional).

Thank you.

December 25, 2017 at 2:24 am #1465432

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

Then you should either write some custom code to make this work, which is beyond the scope of our support.

At this point I would suggest you consider contacting one of our certified partners from this link:
http://wpml.org/documentation/support/wpml-contractors/

Before doing so please have a look also here:
http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/

You will get the custom assistance you need to get on with your project.

Kind Regards,
Shekhar