
- MODX 3
- PHP 8.2
- Vue 3


Key prefix: localizator3_. Namespace: localizator3.
Where to edit: System → System Settings, filter by localizator3.
Use the getLocalizedResources snippet for localized lists; it localizes fields itself.
{'!getLocalizedResources' | snippet : [
'snippet' => 'pdoResources',
'parents' => 0,
'limit' => 10,
]}[[!getLocalizedResources? &snippet=`pdoResources` &parents=`0` &limit=`10`]]On install and upgrade, the resolver creates or overwrites pdotools_fetch_class = ModxPro\PdoTools\FetchLocalizator (extends Fetch). The namespace bootstrap loads Composer vendor/autoload.php (PSR-4). The OnMODXInit plugin does the same. The class does not load bootstrap.
Use FetchLocalizator for direct pdoResources / pdoMenu.
The plugin assigns resource fields from localizator3_translate_fields. content is written to localizator3_content and does not replace resource content. Non-empty TVs from getTVKeys() are assigned to the resource.
{$_modx->resource.localizator3_content}The Localization tab shows only TVs with the localizator3_enabled flag on the TV form.
| --- | --- | --- | | localizator3_default_language | empty | Default language. An empty value falls back to the first active language by rank only in auto-translation and CLI. Site and selection languages do not use that fallback.
mSearch and blocking base-language localization use the fallback only when localizator3_default_from_resource is Yes. Without the setting and without an active language, auto-translation and CLI stop with an error.
With localizator3_default_from_resource off and a non-empty key, saving a new resource creates that language’s localization. | | localizator3_default_from_resource | No | Base language from resource fields and TVs. The base language disappears from the tab only when set to Yes and localizator3_default_language is non-empty. An empty setting does not hide the tab via fallback. | | localizator3_check_permissions | No | Enforce LocalizatorManagerPolicy permissions. | | localizator3_disabled_templates | empty | Template IDs without the Localization tab, comma-separated. | | localizator3_404_if_no_localization | No | Returns 404 when localization is missing. Skipped without a language key and for the base language when localizator3_default_from_resource is on. Before the response, OnHasLocalizatorError404 is called: false cancels the 404. | | localizator3_auto_detect_language | No | Auto-detects language on the front end when friendly URLs are enabled. If the URL has no language segment, the request parameter is used, otherwise the localizator3_key cookie, otherwise Accept-Language. Then it performs a 302 redirect to the language http_host and the current request path. | | localizator3_request_language_param | language | Parameter name in $_REQUEST on the front end with friendly_urls. The value must be an active key matching ^[a-z]{2}(-[a-z0-9]{2,8})?$. An empty name disables the check. The parameter overrides the cookie in the connector and AJAX. | | localizator3_debug_log | No | Extra $modx->log lines with prefixes like [localizator3 getformconfig]. With the setting on, some lines are INFO and some are DEBUG. TV render errors are always ERROR.
The same toggle is the LOCALIZATOR3_DEBUG_LOG constant. The MODX log is usually core/cache/logs/error.log. For DEBUG, log_level must not be stricter than DEBUG. | | localizator3_seo_title_maxlength | 70 | Maximum length of the SEO Header field on the localization tab. | | localizator3_seo_description_maxlength | 160 | Maximum length of the Description field on the localization tab. | | localizator3_seo_keywords_maxlength | 255 | Maximum length of the SEO Keywords field on the localization tab. |
SEO field hints on the localization tab: localizator3_seo_title_hint, localizator3_seo_description_hint, localizator3_seo_keywords_hint.
| --- | --- | --- | | localizator3_default_translator | Yandex | Yandex, Google, DeepL, LibreTranslate, MyMemory, SimpleCopy. An empty value or a name outside the list gives SimpleCopy. Unknown names are also logged. | | localizator3_key_yandex | empty | Yandex Translate API key. | | localizator3_key_google | empty | Google Cloud Translation API key. | | localizator3_key_deepl | empty | DeepL API key. | | localizator3_libretranslate_url | http://localhost:5000 | LibreTranslate URL. | | localizator3_key_libretranslate | empty | LibreTranslate API key. | | localizator3_mymemory_email | empty | Email for MyMemory. | | localizator3_translate_fields | pagetitle,longtitle,menutitle,seotitle,keywords,introtext,description,content | Auto-translation fields. In transport, values have no spaces after commas: the auto-translate processor does not trim. | | localizator3_translate_translated | No | Translate empty fields on existing resource localizations. | | localizator3_translate_translated_fields | No | For resources: overwrite non-empty translate_fields only when localizator3_translate_translated is Yes. For lexicons, this flag alone is enough. |
SimpleCopy copies text without calling an API.
Without localizator3_default_language and without an active language, the script writes an error to stderr and exits with code 1.
cd core/components/localizator3/scripts
php translate_resources.php --parents=1 --depth=5
php translate_resources.php --ids=1,2,3 --dry-runSample --dry-run output:
Would translate resource 12 (Example page)
Done: 1 resources, 0 errors.In one run only the first of --ids and --parents in the arguments is used. The other is ignored.
| Parameter | Description |
|---|---|
--ids=1,2,3 | Resource IDs |
--parents=1 | Parent |
--depth=5 | Depth with --parents (default 10) |
--dry-run | Plan without writes |
Environment variables: MODX_BASE_PATH, LOCALIZATOR_CONTEXT (default web).
PHP routing looks at http_host and the first URL segment. For site.example/en/... configure the web server. The samples below are not part of the package.
RewriteRule ^(ru|en)/assets(.*)$ assets$2 [L,QSA]location ~ ^/(ru|en) {
rewrite ^/(ru|en)/(favicon.ico|assets.*)$ /$2 redirect;
try_files $uri $uri/ @rewrite;
}