Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I thought it would be nice and helpful addition if we could integrate automatic translation suggestions through the Google AJAX Language API.
The work is pretty much done and feedback would be appreciated. If all this passes scrutiny, I'll port to D6.
- added admin configuration area to allow enabling/disabling if translation suggestions
- extended the jQuery code to fetch a translation
- added current locale setting to the Drupal.settings js object
- added boolean of whether or not to use translation suggestions to the Drupal.settings js object
- added a button to copy the suggested translation to the translation textarea
- made minor changes to the html of the "source" area to allow that either source or translation suggestion is copied to the translation textarea
- made minor UI change (html) to separate source text from suggested translation
- made minor css change to separate source text from suggested translation
- made minor css change so .toggle area highlights on hover
- fixed #237702: Language name not shown in "Translate to" header
Comment | File | Size | Author |
---|---|---|---|
#25 | 237709-google-translate_2.patch | 6.27 KB | podarok |
#24 | 237709-google-translate.patch | 6.01 KB | andypost |
#23 | for_all_languages_contributions.patch | 4.77 KB | podarok |
#20 | l10n_client_7.x-dev.zip | 24.08 KB | podarok |
#20 | for_all_languages_contributions.patch | 4.77 KB | podarok |
Comments
Comment #1
jpoesen CreditAttribution: jpoesen commentedCorrection: previous supplied patches were created against 5.x-1.0. New patches applied against 5.x-1.x-dev
Comment #2
Gábor HojtsyHm, sounds quite interesting. Some questions / suggestions:
- How would this look on the UI?
- I'd add more descriptions on what the Google Language API usage means (ie. what is shared with Google, comment about the accuracy of their service, etc).
- I am on the fence of whether this should be on or off by default.
Comment #3
Gábor HojtsyAlso, please combine patches into one, it is much easier to review. Thanks!
Comment #4
jpoesen CreditAttribution: jpoesen commentedThe UI change is part of the patch already. See attachment.
1. When clicking a string in the left column, the translation is automatically added to the source text you get in the middle column. The two are clearly separated by a blue line and the locale preceeds the translation:
Submit
------------------
NL: Verzend
2. an extra button 'copy translation' is added to the 3rd column. To avoid conflict with the 'copy source' button, I've wrapped source content and translation suggestion in a unique div to ensure only source or translation is copied to the textarea
About more comments on the Google api itself (privacy, accuracy, etc): where should this be put? Help? Description on the settings form?
Also, I've extracted the code and put it into a proper module (Google AJAX Language API: http://drupal.org/project/glangapi), but I've yet to release a first version. Would you like the client to depend on that module or is it ok for you like this?
Ok, I'll combine the patches.
Comment #5
Gábor HojtsyIt might be better to depend on that extra module and automatically turn on this feature in our module if that module is already in place. That would be an optional dependency. In which case we can forget about the settings page.
I imagined disclaimers on the settings page where the user choose to use the Google AJAX Language API, but this only makes sense of course of we handle all in this module.
Comment #6
jpoesen CreditAttribution: jpoesen commentedOk to let the client depend on the extra module, but I can imagine that an admin would like to be able to have the translation suggestions enabled site wide (setting in glangapi), while being able to disable it specifically for the client.
I'm thinking of a simple plugin system for glangapi where one or more additional modules would provide integration with (and a settings interface for) modules like the localization client.
If we want to enable translations this way, we'd have to look at slight modifications to the client so that I can easily extend the UI...
Comment #7
Gábor HojtsyGood! This way of the integration sounds much better :)
Comment #8
akaserer CreditAttribution: akaserer commentedhi
you wrote:
"If all this passes scrutiny, I'll port to D6."
i found this feature great for d5.
is the port to d6 still on the todo-list?
Comment #9
podarokTomorrow I got google translate support via jquery.translate-1.3.9.min.js and a few lines of code into module and js
In code (l10n_client.js) there is hardcoded
var trans = $('#l10n-client-string-editor .source-text').text().translate('en','uk');
translation from en to uk
but You can insert Your language tag for testing just change uk to any other
Just put jquery.translate-1.3.9.min.js into l10n_client module folder and apply the patch
In this code there is a problem that I can`t fix now - translation got only one time (need page refresh every time), so I need help, cause I`m not javascript developer 8(((
I think its a little bug with my code, but can`t figure where
jguery plugin from http://code.google.com/p/jquery-translate/
The same trouble with latest dev version of jquery-translate so it is really my bug
Comment #10
Gábor HojtsyHow does this work with placeholders like @count (are they left intact?), and links/html markup (are they left intact?).
Comment #11
podarokSorry here is a real patch
Comment #12
podaroknope Gabor
html code translated nice(tags stay untranslated) but placeholders translated as english text
we need special parser before sending text for translation
But this code if we fix @page refresh@ bug is very nice almost
Comment #13
podarokpossibly this is a bug of jquery-translate
http://code.google.com/p/jquery-translate/issues/detail?id=58
Comment #14
podarokHere is a fully working patch with latest jquery-translation (1.4.4) against DRUPAL-7--1
html tags keeps untranslated
placeholders like @count - translated 8((((
Comment #15
podarokComment #16
podarokwe need to replace only uk with variable of current language
how to find it with javascript?
Comment #17
podarokjust translated ~100 strings in Ukrainian and have a small statistic
~every 5 needs hand changing, but really fast work aginst po file translation by hands...
Have to be ported to all languages!
Comment #18
podarokafter translating > 500 strings make a little patch for existing config
when selecting string in the tree - send it to google without pushing button "Google translate"
-1 click patch
with this patch we can`t change existing translations
but for untranslated strings - very usefull
Need work to check if string already translated - do not send it to Google
Comment #19
andypostI think this addition needs a configuration settings to be Enablable so default behavior is do not use GT for backward compatibility
tabs all over patch
dreditor shows tabs and ending whitespace
translation direction should be configurable, as I see it now it's hardcoded
Powered by Dreditor.
Comment #20
podarokHere is pre-RTBC patch with added option for Fast/Not Fast translation
Also fixed and removed hard-coded language tag and added real language tag from $language->language
So This patch need to be tested and after that possibly commited
Comment #21
podarokComment #22
podarokTested patch on
Drupal7-BETA3 Ukrainian
Drupal7-BETA3 Russian
looks like working for me
need review for other languages
Comment #23
podarokreset for testing bot
Comment #24
andypostI scare that library http://code.google.com/p/jquery-translate/ is distributed under "Code license: MIT License" so it's not compatible to be included into drupal cvs ... so I included this one as external script (I'm using last stable version)
Settings form is extended to make this feature disabled by default (should be discussed)
Variables are renamed (use_fast changed to l10n_client_auto_gtranslate)
Javascript should not use global variables so replaced with Drupal.settings
Added check to ensure that language is not English so no reason to translate en=>en
PS: I think this feature could be easily added as contrib module but having this in l10n_client is preferable way!
Comment #25
podarokThanks @andypost
checked out this patch at Seven theme and looks like we need a small typo fix with UI
here is a patch for it with Your @andypost updates
still need review
Comment #26
podarokComment #27
podarokLooks like working in
Opera 11
Firefox
Chrome
tested on Ukrainian and Russian translations
Powered by Dreditor.
Comment #28
andypostLet's get Gabor's review on this.
Comment #29
Gábor HojtsyReviewing:
- great that you rolled this agains 7.x, perfecto!
- why do you change the submit button? and the textarea height?
- not sure why insist on checking for $language->language != 'en', the l10n_client UI should not show on English, should it?
- why do we have a google translate button even if autotranslation is on? it already happens automatically, right?
Comment #30
Gábor HojtsyBTW would love to include this (once cleaned up) in the next (upcoming) 7.x-1.x and 6.x-2.x release. Thanks for working on it.
Comment #31
podarokcause we`ve got a new button "Google translate" that in some themes entering second line of buttons
Yes, we can hide it, but sometimes jquery-translate got timeouts connecting to google(text just leaves untranslated) and this button can help for sending text by hand
Comment #32
andypostWe should follow commited #568028: Inform user about submission status
To display ONLY errors of translations (mostly timeouts)
UI is a main trouble - for D7 we should test UI in seven so buttons goes a bit wider so Button moves to second line and breaks UI.
I think it's not a good idea to hide button if auto-translation enbaled because user should have ability to manualy translate in any case.
Probably we should rename button's value from 'Google translate ' to something shorter and maybe change text on other buttons because current UI does not allow to add own buttons without braking UI
$language->language != 'en'
is needed because client does not check this condition at all so translating from EN to EN seems confusingComment #33
podarokstill not in 7.x-1.0-beta3 8(