google_translate
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| google_translate [2026/10/20 17:27] – Synchronize English documentation with canonical Russian pages; reviewed locally 2026-10-20 user | google_translate [2026/11/03 20:55] (current) – Document translation settings, Custom adapter and standalone API example admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | The script includes built-in Google Translate API integration for automatic text translation. Note that this is a paid service | + | If you run several language versions of your site, SCJ can automatically translate gallery and category text through third-party services |
| - | ===== Translation of Existing Database | + | ===== Configuration |
| - | To translate your existing gallery database, connect to your server via SSH and run: | + | Open **Rotation → Settings → Translators**. |
| - | | + | |
| + | - Enter the service' | ||
| + | - Select the source language. **Auto** asks the service to detect it. | ||
| - | (from the scj/bin directory) | + | The defaults are Custom and English |
| - | If you run this on a slave site, the results are saved there as well. This is useful if you have a master | + | Google and DeepL use your accounts with those providers. Sign up with the provider |
| - | The script will prompt you to: | + | ===== Translating an individual field ===== |
| - | 1. Select which field to translate (if you have both description and alt text, you'll need to run this twice) | + | Text fields |
| - | 2. Choose where to save the translated | + | |
| - | 3. Enter your Google Translate API key | + | |
| - | Then you'll choose a translation mode: | + | The result appears in the same field. Use the form's normal Save button to save it. |
| - | - **stops:** The script pauses after each phrase so you can manually review | + | ===== Existing |
| - | - **log:** Translates without pausing, but shows the output for review | + | |
| - | - **fast:** Translates as quickly as possible with no pauses or output | + | |
| - | For best results, use UTF-8 encoding when connecting | + | For existing galleries, select **Fields |
| - | ===== Translation of New Entries ===== | + | Bulk translation reads the source site's text and overwrites the selected fields on the language site. |
| - | To automatically translate | + | For categories, use **AutoTranslate All** on the categories page. After confirmation, |
| + | |||
| + | For new galleries, | ||
| + | |||
| + | ===== Building your own service (Custom) ===== | ||
| + | |||
| + | The adapter is '' | ||
| < | < | ||
| + | examples/ | ||
| + | </ | ||
| - | If this field = URL | + | The URL is built from the configured site URL and SCJ folder. |
| - | Contains this value = http (matching all galleries) | + | |
| - | Then Search | + | |
| - | in This Field - Custom Vars 1 (we'll store translation here) | + | |
| - | And Replace | + | |
| + | < | ||
| + | https:// | ||
| </ | </ | ||
| - | When a gallery is imported, | + | The request flows from the admin button |
| - | Key features of this approach: | + | **The example does not perform real translation.** It returns the original text with a language prefix, such as '' |
| - | - **external:: | + | Save '' |
| - | - **{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' | + | ===== API protocol |
| - | The built-in translation has limitations | + | For example, Custom sends a POST request with JSON and an X-Api-Key header. Replace the domain |
| + | |||
| + | <code bash> | ||
| + | curl 'https://example.com/ | ||
| + | -H 'Content-Type: | ||
| + | -H ' | ||
| + | --data ' | ||
| + | </ | ||
| + | |||
| + | Example response: | ||
| + | |||
| + | <code json> | ||
| + | {"text":" | ||
| + | </ | ||
| - | In the example configuration above, the API key is stored in the database. If you give someone | + | * '' |
| + | * '' | ||
| + | * '' | ||
| - | This flexibility lets you customize how imported | + | A successful response must have HTTP status 200 and a string field named text. API errors use a different HTTP status and a JSON error field. Custom does not substitute the original text for a failed translation. |
google_translate.txt · Last modified: by admin
