Extending
ExtendingTranslating additional Elementor widgets

Translating additional Elementor widgets

Gato AI Translations for Polylang can translate widget-based Elementor pages.

The plugin ships with support for all Elementor and Elementor PRO widgets. For custom or 3rd-party widgets, you can extend translation support via PHP hooks.

Translating strings

To declare additional translatable properties on an Elementor widget, use the gatompl:elementor_widget_type_translatable_properties filter.

The filter receives a [widgetName => properties] map. The properties entry can hold:

  • Flat control names — e.g. 'author_name'
  • Dot-paths — e.g. 'author_avatar.alt' (translates to settings.author_avatar.alt)
  • Repeater fields — declared as a sub-array [repeaterName => [...subFields]]

These are mixed freely, and nesting can go to any depth.

For instance, this hook makes:

  • The flat control author_name and the dot-path author_avatar.alt translatable on the blockquote widget
  • The repeater sub-field name translatable inside the slides repeater of the reviews widget
add_filter(
    'gatompl:elementor_widget_type_translatable_properties',
    static function (array $translatableProperties): array {
        $translatableProperties['blockquote'][] = 'author_name';
        $translatableProperties['blockquote'][] = 'author_avatar.alt';
        $translatableProperties['reviews']['slides'][] = 'name';
        return $translatableProperties;
    }
);

The same filter works for both simple controls and repeater fields — there is no separate hook for repeaters.

Translating entity references

A property can store an entity ID (a post, taxonomy term, media item or menu) that should be remapped to the corresponding target-language entity at translation time. Use the matching filter:

Reference kindFilter
Custom posts and mediagatompl:elementor_widget_type_custompost_and_media_reference_properties
Taxonomy termsgatompl:elementor_widget_type_taxonomy_term_reference_properties
Menus by IDgatompl:elementor_widget_type_menu_reference_by_id_properties
Menus by sluggatompl:elementor_widget_type_menu_reference_by_slug_properties

The shape is the same as the translatable-properties filter — flat names, dot-paths or sub-arrays for repeaters.

// Custom post / media reference
add_filter(
    'gatompl:elementor_widget_type_custompost_and_media_reference_properties',
    static function (array $properties): array {
        $properties['featured-post'][] = 'post_id';
        $properties['gallery']['items'][] = 'image_id';
        return $properties;
    }
);
 
// Taxonomy term reference
add_filter(
    'gatompl:elementor_widget_type_taxonomy_term_reference_properties',
    static function (array $properties): array {
        $properties['related-category'][] = 'category_id';
        return $properties;
    }
);
 
// Menu reference by ID
add_filter(
    'gatompl:elementor_widget_type_menu_reference_by_id_properties',
    static function (array $properties): array {
        $properties['menu-picker'][] = 'menu_id';
        return $properties;
    }
);
 
// Menu reference by slug
add_filter(
    'gatompl:elementor_widget_type_menu_reference_by_slug_properties',
    static function (array $properties): array {
        $properties['menu-picker'][] = 'menu_slug';
        return $properties;
    }
);

Discovering widget names and property names

Run the Translate custom posts GraphQL query and inspect the elementorData field in the response. Each widget exposes its widgetType and its settings tree — that's where you'll find the property names (including nested dot-paths and repeater fields) you need to pass to the hooks above.

Inspecting elementorData in the Translate custom posts GraphQL response
Inspecting elementorData in the Translate custom posts GraphQL response

See the Retrieving page builder data to translate guide for how to run that query.

Where to find examples

The plugin's own integrations are a useful reference. Explore this file inside the plugin you installed:

  • wp-content/plugins/gato-ai-translations-for-polylang/src/ConditionalOnContext/LicenseIsActive/ConditionalOnModule/Elementor/Constants/WidgetTypes.php