
Localizator3
Language versions without contexts for MODX 3: resource fields, TVs, SEO, MiniShop3 products
- MODX 3
- PHP 8.2
- Vue 3


| Event | When | Parameters |
|---|---|---|
OnBeforeSaveLocalization | Before create and update | mode, id, data, localizatorContent (object), object |
OnSaveLocalization | After create and update | mode (new / upd), id, localizatorContent (object), object.No data or objectType keys. |
OnBeforeRemoveLocalization | Before remove | id, localizatorContent, object |
OnRemoveLocalization | After remove | id, localizatorContent, object |
OnLocalizatorContentDuplicate | After a localization is duplicated | mode (duplicate), id, resource_id, source_key, key.Not registered in _build/elements/events.php. |
| Event | When | Parameters |
|---|---|---|
OnBeforeSaveLocalizatorLanguage | Before create and update | mode, id, data, localizatorLanguage (object), object |
OnSaveLocalizatorLanguage | After create and update | mode (new / upd), id, localizatorLanguage (object), object.No data or objectType keys. |
| Event | When | Parameters |
|---|---|---|
OnBeforeFindLocalization | Before language lookup by host and URL | language, http_host, request.A non-empty string from the plugin aborts the lookup. return false does not stop it.Nothing is printed to the page. |
OnFindLocalization | After a lookup attempt, including when no language was found | language, http_host, request.Not fired when OnBeforeFindLocalization aborted or on auto-detect 302 redirect. |
OnToggleLocalizatorLanguage | After the current language is applied | language, language_key, http_host, request.On a full page and via the connector (Referer) it fires for every found language. Skip when key and cultureKey are unchanged only for a repeated set via the language parameter or cookie. |
OnFindLocalizatorResource | When resolving a resource | resource (starts false), request.If the plugin set resource, the built-in findResource() is not called. |
OnHasLocalizatorError404 | Before a 404 when localization is missing | resource, language_key.Only when localizator3_404_if_no_localization is on, the language key is non-empty, and fields are not taken from the base-language resource. |
Внимание
Return false from an OnHasLocalizatorError404 handler to skip the error page. The core may still log that the plugin failed.
| Event | When | Parameters |
|---|---|---|
OnBuildLocalizationTabs | Building form tabs | Depends on the calling processor |
mgr/content/getformconfig localizatorContent — always null.tabs — by reference.resource, user.customization — by reference, keys user_id, resource_id, context_key, class_key.You can add fields via tabs and customization if the change lands in $modx->event->returnedValues and the plugin output is empty.
mgr/fields localizatorContent — by reference.tabs, customization — not by reference.customization — only user_id, resource_id.After the event, the form reads only tabs via $modx->event->returnedValues['tabs'] when plugin output is empty. customization is not applied to the form.
A plugin can add a tab with a custom field:
<?php
if ($modx->event->name !== 'OnBuildLocalizationTabs') {
return;
}
$tabs = $modx->event->params['tabs'] ?? [];
$tabs['mine'] = [
'id' => 'mine',
'caption' => 'My fields',
'fields' => ['myfield'],
];
$modx->event->returnedValues['tabs'] = $tabs;The plugin must print nothing: the form uses $modx->event->returnedValues['tabs'] only when its output is empty.