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 16 replies, has 2 voices.

Last updated by Harshad 9 years, 2 months ago.

Assigned support staff: Harshad.

Author Posts
October 6, 2012 at 10:19 am #78639

Dorian

Hello,
I've searched the site and forums, but I can't find any explanation on this... (surprising - I would've guessed lots of people would need to know)

Here's my situation: I have a website in both Chinese and English. For the sake of the Chinese version, I installed a sophisticated plugin that enables one to integrate website comments with Chinese social network accounts, quite a complex affair.

One of the things this plugin does is create a custom comment box at the bottom of a post, with various options related to social networking. It's all in Chinese, the plug-in doesn't appear to be localized (strings remain in Chinese even when I switch site language to English), but strangely enough, when I search for strings to translate using WPML, no strings in Chinese are detected, only some in English (which I see appearing nowhere on the front-end).

So I suppose one option would be for me to get my hands dirty a bit and 'show' WPML which are the strings to translate, using the tutorials I've noticed elsewhere on this website; but actually, the functions this plugin offers are only interesting to Chinese users, people from other countries don't use the same social networks. So another, theoretically simpler option would be to simply <b>hide</b> the plug-in whenever a page in English is displayed.

But I'm no expert programmer, and if the only way to do so is to use the widespread

<?php
if (ICL_LANGUAGE_CODE=='en'){
?>

formula, I must confess I don't know which plugin file to modify... It's quite a complicated thing (called Duoshuo).

How should I manage this?

Cheers,
Dorian

October 6, 2012 at 1:07 pm #78645

Harshad

Dear Dorian,

I assume you have installed the same Duoshuo plugin.
http://wordpress.org/extend/plugins/duoshuo/

I further gave a try installing the plugin at my local install, and see the plugin provides widgets.

If you are using widgets to create a custom comment box at the bottom of a post, then I recommend you use widget logic plugin
http://wpml.org/2011/03/howto-display-different-widgets-per-language/

Widget Logic is a plugin that allows controlling where widgets display using PHP code. You can use it to specify where widgets are allowed, including which languages they will display in.

Please let me know if this helps.

October 6, 2012 at 2:33 pm #78649

Dorian

Hi Harshad,
Many thanks for your quick reply.

This is the plugin I am using, but I don't make use of its widget functionalities. By activating the plug-in, a comment box is created at the bottom of each post -- that is the element I would like to see disappear when the page is in English.

See example here of a Chinese webpage with this function (this WP install is Chinese only, without WPML, I'm still testing locally before merging EN+ZH): hidden link

Best,
Dorian

October 7, 2012 at 8:36 am #78680

Harshad

Dear Dorian,

Checking the duoshuo plugin files, I see it includes the comments template on posts. It calls the public function commentsTemplate($value).

Can you please give a try adding below code to your theme's functions.php file.

if(ICL_LANGUAGE_CODE=='en'){
add_filter('init', 'remove_duoshuo_comments', 10);
function remove_duoshuo_comments() {
global $duoshuoPlugin;
remove_filter('comments_template', array($duoshuoPlugin, 'commentsTemplate'));
}
}

The above code will remove the filter when sites current language is English.

October 7, 2012 at 9:59 am #78692

Dorian

Excellent, thanks Harshad! This does make the Chinese comments disappear in English.

One more little thing though: this plugin also has the effect to 'take over' the part of a post that displays the number of comments posted, and this info is then displayed in Chinese (ex. instead of "2 comments", "两条评论" shows up) -- even after switching to English...

How do I make sure this doesn't happen?

Cheers,
D-

October 7, 2012 at 2:12 pm #78702

Harshad

Dear Dorian,

I have browsed your site hidden link and I see it shows 0 comments above the posts.

I don't find 两条评论 anywhere in your site, Can you please point out the exact location where you see the text?

October 7, 2012 at 4:02 pm #78712

Dorian

Hi Harshad,
No, it's true that on the online version of my website there is no problem. For the moment, 2 separate WP installs are publicly visible on the front end: English / Chinese. WPML is only implemented on my localhost sandbox for now, until everything is OK and I merge the 2 installs.

Therefore, the problem with the number of comments is not immediately visible for now on the public front-end... If you would like to see this in order to solve the issue, I can show you on a different public sandbox server?

(basically, it's just that "# Comments" info that stays in Chinese, at the top of each post)

October 10, 2012 at 4:53 am #79054

Harshad

Dear Dorian,

I greatly apologize for delay, I was away so could not get back to you.

Yes it would be good to see the different sandbox server, or if it is possible for you to send your ftp and wp-admin details to my email address, I will further try to lookup into searching the string.

October 18, 2012 at 4:58 am #80422

Dorian

Hi Harshad,
Please take a look at the sandbox version of our website here: hidden link

You'll notice, in English posts (such as hidden link), next to the date, the string of 4 Chinese characters I mentioned earlier. Even though the Duoshuo comments box is hidden, the plugin itself still has an impact on this.

Best,
Dorian

October 18, 2012 at 6:08 am #80434

Harshad

Dear Dorian,

Can you please send me the ftp and wp-admin details for sandbox version of your site to my email address?

Please include this forum link for reference.

October 18, 2012 at 11:51 am #80512

Harshad

Dear Dorian,

Thanks for the details, on further investigation I found that, you had Chinese Simplified language as String's source language set in wpml -> string translation.

And you had enabled custom zh language Chinese, So I had to set the Strings source language to English in wpml -> string translation.

But this still has not resolved the problem.

I think within your theme files, archive page, single.php page some thing is conflicting.

I have also checked the database and removed strings for zh-hans.

Still its not working.

October 19, 2012 at 6:40 am #80648

Dorian

Hi Harshad,
Yes, the problem certainly comes from my theme, but I have no clue as to how to solve it. My theme developer is completely unreachable, unfortunately, so I can't ask him for any help...

Dorian

October 22, 2012 at 9:08 am #80931

Harshad

Dear Dorian,

Okay will check it again, and update you on it.

November 6, 2012 at 5:41 am #83240

Dorian

Dear Harshad,

Sorry to pressure you on this, but would you have any new suggestions regarding the way to solve this issue?

Best,
Dorian

November 6, 2012 at 12:55 pm #83308

Harshad

Dear Dorian,

Do you have .mo file uploaded to your theme?

The topic ‘[Closed] Display/Hide Plugins Depending on Language’ is closed to new replies.