Closed (fixed)
Project:
Google Translate Links
Version:
6.x-1.4
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
29 Aug 2009 at 14:15 UTC
Updated:
26 Oct 2009 at 16:00 UTC
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
Comment #1
blinkingtwelve commentedThanks 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.
Comment #2
blinkingtwelve commentedSupport for freeform language codes is now in CVS.
Comment #3
blinkingtwelve commentedComment #4
ceinmart commentedHi,
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.
Comment #5
ceinmart commentedComment #6
ceinmart commentedsorry .. my bad...
disregard this posts..
Comment #7
blinkingtwelve commentedThe 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.
Comment #8
blinkingtwelve commentedReverting status to 'fixed'.
Comment #9
sbatmc commentedI 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!
Comment #10
blinkingtwelve commentedYou 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.