Hi,

I use on my site the component and to use the China language I have changed the source code to support more than 2 char for the country code (China code use 5 char).
For this works fine , need to use the file name syntax: name-ononono.X.yyy
where
X = country code (used by google translate)
yyy = file extension

This is the country flags file I use:

01-USA-32.en.png
02-Espanya-Spain-32.es.png
03-Deutschland-Germany-32.de.png
04-France-32.fr.png
05-Nihon-Japan-32.ja.png
06-Zhongguo-China-32.zh-CN.png

My change on the source is bellow.
I already force the source language, but I not sure if this can be useful for others users....

$ diff gtranslate_links.module.backup gtranslate_links.module
34c34,37
<     if (preg_match('/([a-z]{2})\.[^.]*$/', $file, $matches) > 0) {
---
>     //by Cesar Inacio Martins
>     //Ao inves de pegar os dois ultimos caractere, pega a penultima "extencao"
>     //if (preg_match('/([a-z]{2})\.[^.]*$/', $file, $matches) > 0) {
>     if (preg_match('/\.([^.]*)\.[^.]*$/', $file, $matches) > 0) {
45c48
<     $gtransurl = 'http://translate.google.com/translate?u=' . urlencode($url) . '&tl=' . $langflag['langcode'];
---
>     $gtransurl = 'http://translate.google.com/translate?u=' . urlencode($url) . '&sl=pt&tl=' . $langflag['langcode'];

Just a plus:
I find cool icons country flags on this site:
http://www.iconspedia.com/cat/world-flags/

Is a good suggestion to put on the README file.

Comments

blinkingtwelve’s picture

Assigned: ceinmart » blinkingtwelve
Status: Active » Postponed

Thanks for the patch. I haven't noticed those 5-letter country codes before, but if GT can handle it so should this module. Some users will have to reorder/rename their flags so I'll roll this into a 2.x-release together with #514602 .

+ I'll test for a speed difference when google is told the source language, if it's significant, I may make it configurable.
+ I'll put your link in the README but please not that the included icons are GPL whereas the iconspedia icons have mixed licenses.

blinkingtwelve’s picture

Status: Postponed » Needs review

Support for freeform language codes is now in CVS.

blinkingtwelve’s picture

Status: Needs review » Fixed
ceinmart’s picture

Hi,

I forgot, Need make a little change on this code I suggest:

if (preg_match('/\.([^.]+)\.[^.]*$/', $file, $matches) > 0) {

(change the * for + )

If don't do this, the directory "." will appear like a flag (empty image) in some browsers (IE/opera)

I have noticed this only a few days ago because here I use only Firefox , what don't show empty images ... but when I see my site in other browser I got the error.

ceinmart’s picture

ceinmart’s picture

Status: Fixed » Needs work

sorry .. my bad...
disregard this posts..

blinkingtwelve’s picture

The regex I eventually ended up putting into the module is not quite the same as the one you suggested, and does not suffer from this problem. Thought I'd mention this to avoid any confusion by other users.
You can use the 2.x-versions if you want arbitrary-length language codes, that way you don't have to maintain a custom version of the module.

blinkingtwelve’s picture

Status: Needs work » Fixed

Reverting status to 'fixed'.

sbatmc’s picture

I was wondering how to get the Chinese translation to work with this module? I have the newest release (v 1.9 2009/09/29), but am not clear how to actually enable Chinese (I also need Vietnamese). Do I have to make any changes to the g_translatelinks.module file ... or create a new flag image for Chinese with a different naming structure? Any help is appreciated! Thanks!

blinkingtwelve’s picture

You can add languages by creating an icon with an appropriate filename. There are pointers in the README on where to get icons - if you use the ones from KDE (look in the l10n directory of a kdebase package, for instance, this one) I'd be very happy to add your contribution in the next release. Please open a new issue for that, do not reply in this thread anymore.

I haven't released 1.9 yet, however. But you're encouraged to download the 2.x beta and apply your changes to that one. Saves you work later on. It has a new filename format, check the README.

Status: Fixed » Closed (fixed)

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