Blog

✨ Gato AI Translations for Polylang now supports translating meta containing arrays and objects

Leonardo Losoviz
By Leonardo Losoviz ·

Gato AI Translations for Polylang has just released v12.2.0 with a brand-new feature: Translate meta data containing arrays and objects (in addition to a single string).

The following data structures in meta fields are now supported:

  • Single string. Eg: "hello world"
  • Array of strings. Eg: ["hello", "world"]
  • Object's 1st level strings. Eg: { level1_key1: "hello", level1_key2: "world"}

The plugin will identify the data structure without any manual intervention, and translate the strings accordingly:

  1. Detect arrays and objects in your meta fields
  2. Extract the translatable strings
  3. Translate them
  4. Store the results in the database, preserving the original data structure

Extending compatibility to more plugins

This feature provides support for plugins that store arrays and objects in meta fields.

An example is Slim SEO, a popular SEO plugin that stores its meta data as a JSON object under meta key slim_seo.

For instance, this is how that meta for a post is stored in the database:

a:4:{s:5:"title";s:67:"This is the meta title in English, will it be translated my friend?";s:11:"description";s:42:"I hope it will, or else I'm fried!";s:7:"noindex";i:1;}

...representing this JSON object:

{
  "title": "This is the meta title in English, will it be translated my friend?",
  "description": "I hope it will, or else I'm fried!",
  "noindex": 1
}

To translate the Slim SEO meta for our posts and pages, you just need to add the slim_seo meta key in the Settings for translating custom post meta:

Indicating to translate Slim SEO meta key in the Settings
Indicating to translate Slim SEO meta key in the Settings

Now, when translatinga a page which contains Slim SEO meta...

Origin page in English, containing Slim SEO meta
Origin page in English, containing Slim SEO meta

...the translated page will have the SEO meta also translated:

Translated page to Spanish, with translated Slim SEO meta
Translated page to Spanish, with translated Slim SEO meta

Enjoy!


New plugins coming soon

Subscribe to receive a notification when the next plugin by Gato Plugins is released.