google_translate
Differences
This shows you the differences between two versions of the page.
| google_translate [2014/03/31 16:04] – created admin | google_translate [2026/03/21 10:11] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Google translate ====== | ====== Google translate ====== | ||
| - | You can translate your descriptions using Google | + | The script includes built-in |
| - | To do it you have to go to https:// | + | ===== Translation of Existing Database ===== |
| - | ===== Translation of Existing DB ===== | + | To translate your existing gallery database, connect to your server via SSH and run: |
| - | If you already have a ready DB with descriptions you want to translate | + | php rotation.php action=translate |
| - | php rot.php action=translate | + | (from the scj/bin directory) |
| - | 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. | + | If you run this on a slave site, the results are saved there as well. This is useful |
| + | The script will prompt you to: | ||
| - | **Then script asks what method | + | 1. Select which field to translate (if you have both description and alt text, you' |
| + | 2. Choose where to save the translated text | ||
| + | 3. Enter your Google Translate API key | ||
| + | Then you'll choose a translation mode: | ||
| - | ===== Translation of New Entries ===== | + | - **stops:** The script pauses after each phrase so you can manually review and correct the translation before saving to the database |
| + | - **log:** Translates without pausing, but shows the output for review | ||
| + | - **fast:** Translates as quickly as possible with no pauses or output | ||
| - | It takes some time to setup and understand how it works but it worth it because it gives you flexibility to do much more. | + | For best results, use UTF-8 encoding when connecting |
| - | You have to setup [[Import Replacements]] for necessary fields , let's say for description | + | ===== Translation of New Entries ===== |
| + | To automatically translate new galleries as they' | ||
| < | < | ||
| If this field = URL | If this field = URL | ||
| - | Contains this value = http (ie we want to translate descriptions for all galleries | + | Contains this value = http (matching |
| - | Then Search For - * (* means ' | + | Then Search For - * (the entire |
| - | in This Field - Custom Vars 1 ( if you use version 50 or language field if you use 51) | + | in This Field - Custom Vars 1 (we'll store translation here) |
| - | And Replace it With - external:: | + | And Replace it With - external:: |
| - | + | ||
| - | 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' | + | |
| - | * source_lng=en& | + | |
| - | * YOUR_API_KEY - should be replaced with your key you got from google | + | |
| </ | </ | ||
| + | When a gallery is imported, the script makes a request to the URL above. The Custom Vars 1 field receives the translation result returned by the URL. For example, Custom Vars 1 will contain the German translation of the description. | ||
| - | Why do we do it this way: | + | Key features of this approach: |
| - | 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. | + | - **external:: |
| + | - **{DESCRIPTION}** is replaced with the actual gallery description | ||
| + | - **source_lng=en& | ||
| + | - **api_key** should be your Google API key | ||
| + | You can save the translation to a slave field. For example, if you have an English master site and a German slave, set up this rule once on the master and save results to the slave' | ||
| + | This approach (using Import Replacements) is more flexible than a single button. You can point to your own translation script (external:: | ||
| + | This flexibility lets you customize how imported text is processed. | ||
google_translate.1396281875.txt.gz · Last modified: (external edit)
