Multilingual

CanAI translates natively, with no extra translation plugin: one post per page, translated at render time, set up under CanAI → Translations.

What it is and when to use it

Use it when the same site must be served in more than one language. Each page stays a single post. Template strings, titles, content, images, menus and site-level text are swapped for the visitor's language when the page renders. Non-default languages are served under a path prefix (for example /ms/about/) with hreflang alternates in the head.

The default language is WordPress's Site Language (Settings → General). It is the language your pages are written in and the only one without a prefix. Change the Site Language and CanAI follows: the new language takes the unprefixed address, the previous one stays as a translation language, and the next admin page says what moved.

Setting it up

  1. Open CanAI → Translations → Languages. Languages are picked from WordPress's own language list; the Site Language's row comes first and cannot be removed.
  2. Add each translation language. The picker fills the URL prefix, the name and the hreflang; you can edit them. Two languages cannot share a prefix or an hreflang.
  3. Translate in the other tabs:
Tab What it holds
Languages The language list.
Global Per-language site name, tagline and archive titles.
Strings Every t() string on the site, with a translation field per language. Filter by language, untranslated, or by page, layout or menus.
Menus Per language: the default menu with translated labels, or a menu of its own.
Content Coverage of pages and posts, and a link to edit each translation.
Media Which image replaces which, per language.

Template strings: whole sentences

Wrap text in t('…'). Translate a whole sentence at a time, with its inline tags inside; translators can move the tags. Dynamic values go in as {placeholders}.

<p>{{ t('Get <strong>free shipping</strong> on orders over {amount}.', {amount: '$50'}) }}</p>
<p>{{ t('Read our <a href="{url}">terms</a>.', {url: turl('/terms/')}) }}</p>
<img src="{{ tmedia(123) }}" alt="{{ t('Our workshop') }}">

tmedia(id) swaps an image per language: on a translation language it returns the mapped attachment, otherwise the original. Set the pairs in the Media tab. Keep the tags and {placeholders} of the source in each translation; one that loses them is rejected on save.

Titles, content and custom fields

Posts and pages get per-language overrides for title, content, excerpt and custom fields (plus SEO title and description). In the block editor, open the translation with post.php?post=ID&action=edit&lang=ms; it uses the same blocks and saves only title, content and excerpt into the translation. The Translations meta box on the edit screen also links to Edit in block editor and View for each language. If you are on a template, Translate strings (post lists) or Translate this page (admin bar) opens the Strings tab filtered to that page.

In All Pages, All Posts and All Templates, a Translations column shows a chip per language: the code (MS) when translated, MS• when partly translated, + MS when not yet. The chip opens the right editor.

Menus

Menu item titles are strings like any other: translate them in Strings (filter: menus), on the Menus tab, or under each item in Appearance → Menus. See Navigation and links.

SEO plugins

If Slim SEO or Rank Math is active, CanAI serves each language's SEO title and description (stored with the translation) and adds language alternates to the sitemap.

From an agent

Ability Use
wpcanai/i18n-get-settings, i18n-set-settings Read or replace the language list (by slug or WordPress locale such as ms_MY).
i18n-list-strings The t() sources with translations; filter by untranslated, search, post_id (with layout, menus) or location.
i18n-set-translations Bulk set source-to-translation pairs for one language; empty removes.
i18n-rescan Rebuild the string index.
i18n-list-content, i18n-get-content Coverage per page, and the raw default-language source to translate.
i18n-get-post-overrides, i18n-set-post-overrides A post's per-language title, content, excerpt, fields, SEO.
i18n-get-term-overrides, i18n-set-term-overrides The same for term name and description.
i18n-get-global-strings, i18n-set-global-strings Site name, tagline, archive text.
i18n-get-media-map, i18n-set-media-map Original-to-translated attachment IDs for tmedia().
{ "lang": "ms", "translations": { "Get <strong>free shipping</strong> today.": "Dapatkan <strong>penghantaran percuma</strong> hari ini." } }

Writes to the default language are rejected; it is the source.

If something looks wrong

Related