User Tools

Site Tools


Translations of this page:

Sidebar

Documentation index

google_translate

Google translate

You can translate your descriptions using Google translate API. Note, that this service is not free, and it's Google who takes money for the service, not the script.

To do it you have to go to https://developers.google.com/translate/v2/faq and get Server API Key. You need Server, not a Browser key.

Translation of Existing DB

If you already have a ready DB with descriptions you want to translate you have to use ssh and go to scj/bin, after that run

php rot.php action=translate

This this point script will ask you what you want to translate, and, if you want to translate both descriptions and titles (alt) you'll have to run this command twice.

Then script asks what method you want to use - stops, log, fast stops - means we we'll make a stop after each phrase and you'll be able to edit a result. Log - means no stops but output texts and translations, fast - no output, just translates as fast is it can..

Translation of New Entries

It takes some time to setup and understand how it works but it worth it because it gives you flexibility to do much more.

You have to setup Import Replacements for necessary fields , let's say for description

If this field = URL
Contains this value = http (ie we want to translate descriptions for all galleries actually)
Then Search For - * (* means 'whole field')
in This Field 	- Custom Vars 1 ( if you use version 50 or language field if you use 51)
And Replace it With - external::http://YOURDOMAIN/scj/bin/rot.php?action=translate_text&text={DESCRIPTION}&source_lng=en&target_lng=de&api_key=YOUR_API_KEY (and field content will be replaced by text returned by this url)

As you can see this way all new content will be processed using that URL 

What you have to notice here:

  * external:: at the beginning - prefix means what script has to request an external url
  * YOURDOMAIN - ....
  * {DESCRIPTION} - tag that will be replaced with an actual gallery's description 
  * source_lng=en&target_lng=de - edit languages here
  * YOUR_API_KEY - should be replaced with your key you got from google

Why do we do it this way: that's a way for you to optimize this, for example you can user it as external::http://YOURDOMAIN/my_script.phptext={DESCRIPTION} and translate using your script that will be more flexible, use another, may be free, translation service and so on.

Moreover, this is a way for you not to save a key in the DB just in case if someone gets an access to your admin area.

google_translate.txt · Last modified: 2014/03/31 16:04 (external edit)