When trying to use the Google Translator to translate Chinese content, it will not work. The drupal language codes ('zh-hans' and' zh-hant') do not work with the Google Translate API. The only Chinese language code that works is actually 'zh-TW'.

I am patching this and will attach it here when I am finished. Hopefully I can save people some time and effort, so that they can translate content to Chinese without going through the trouble of figuring this out and manually adding the appropriate language code.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zhuber’s picture

Status: Active » Patch (to be ported)
FileSize
573 bytes

Here is the patch, please have a look and implement whenever you can. It creates a Chinese language that works with the Google Translate API upon installation of this module.

zhuber’s picture

Status: Patch (to be ported) » Needs review
Berdir’s picture

Category: feature » bug
Status: Needs review » Needs work

We usually define a mapping for this in the translator plugin. Microsoft needs one for chinese as well. Users that will want to translate into chinese will already have the default chinese language enabled and probably a lot of translations in there, so adding a new language won't help them.

We are also working on generalizing default language mapping in translators and providing a per-translator UI for defining mappings for custom languages. The issue is #1877418: general language mapping, if you want to work on that :)

Berdir’s picture

The mapping functionality has been implemented and committed. So all you need to do is update this module accordingly to support it.

skyredwang’s picture

Issue summary: View changes
Status: Needs work » Fixed

To edit translator language code, visit /admin/config/regional/tmgmt_translator/manage/

Google Language code for Chinese:
Chinese Simplified zh-CN
Chinese Traditional zh-TW

More codes are documented here: https://developers.google.com/translate/v2/using_rest

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

seanr’s picture

I've configured it as suggested in #5, but it still doesn't work for me.

Google translator (auto created) can not translate from English to Chinese, Simplified.

Any idea what's going on there?

[edit: never mind, I figured it out - editing the existing language wasn't enough, I had to create a custom language]

popstas’s picture

Mappings was not used in canTranslate(), heres the patch with fix for tmgmt.
At this time, google has `zh` and `zh-TW`.