You manage every language of a page in one page tree. Each page has a source language and a language variant for every language it's translated into. PagibleAI notices when the source changes, shows you which translations are out of date, and Translate sends only the changed parts to the AI, so your own edits in the translations are kept. Below, you'll learn how to set up languages, translate content and show the languages on your website. For the story behind this feature, read PagibleAI CMS 0.14: Every Language in Sync.
Multilingual Laravel Websites with AI Translation in PagibleAI
Quick start
Add your languages and a translation provider to the .env file:
CMS_LOCALES=en,de,fr
CMS_AI_TRANSLATE=deepl
CMS_AI_TRANSLATE_API_KEY=your-api-key
CMS_AI_TRANSLATE_MODEL and CMS_AI_TRANSLATE_URL select the model and endpoint if your provider needs them. For details, see Configure DeepL. Then:
- Create the
job_batchestable and start a queue worker as described in Queue and rate limits. - Choose the language in the page list, select the pages and use Translate in the bulk menu.
- Review the AI drafts and publish them.
How languages work
A page is the position in the page tree. Its content lives in language variants, and each variant has its own path, name, title, content, meta data, status, versions and publishing schedule. One variant is the source, which all other languages are translated from. A page with only one variant is a single-language page; you don't have to translate every page.
Moving, copying and deleting act on the whole page with all of its languages. Editing, publishing, scheduling and the version history act on one language. The access rules for logged-in visitors are set once per page and apply to all languages, see Frontend Access Control.
To make another language the source, select the pages in the page list and use Change source language in the bulk menu. This requires a user without language restrictions.
Configure languages
List the content languages in CMS_LOCALES. The default language of new pages is APP_LOCALE if it's in the list, otherwise the first language. With only one language, the admin panel hides all translation features.
CMS_LOCALES=en,de,fr,de-CH
Pages can also have variants in languages that aren't listed, e.g. after an import or when you remove a language. Translate updates these existing variants but never creates new ones in such languages. Creating a language variant always requires the variant:add permission.
Untranslated pages and fallbacks
CMS_TRANSLATE_FALLBACK decides what menus, breadcrumbs, sub-page lists and blog lists do with pages that have no visible variant in the current language:
hide(default): the page and its sub-pages are left out. Only the exact language is used.source: the page is shown with the name of its source variant and links to the URL of the source variant.
CMS_TRANSLATE_FALLBACK=source
A page is never rendered under a URL of a language it doesn't have, so the fallback doesn't create duplicate content.
In source mode and in the editor preview, regional languages show the variant of their parent language before the source variant, e.g. de-CH uses de. To change these fallbacks, publish the configuration with php artisan vendor:publish --tag=cms-config and set translate.chains in config/cms.php:
'translate' => [
'fallback' => env( 'CMS_TRANSLATE_FALLBACK', 'hide' ),
'chains' => [
'de-CH' => ['de'],
'lb' => ['de', 'fr'],
],
],
Languages not listed in CMS_LOCALES are skipped. Each fallback language adds a join to the page queries, so keep the chains short.
Queue and rate limits
Translations run as a batch of queued jobs on the queue set in CMS_QUEUE_CONNECTION and CMS_QUEUE. Before you translate the first page, create the job_batches table of Laravel, otherwise translations fail:
php artisan make:queue-batches-table
php artisan migrate
Run a queue worker, or set the queue connection to sync to translate during the request. Large pages are split into several provider calls. CMS_AI_RATELIMIT limits the provider calls per minute and tenant (default 60). Jobs over the limit wait instead of failing, and rate limit, overload and connection errors of the provider are retried after 10 seconds, 1 minute and 5 minutes for up to 6 hours. You can queue as many translations at once as the rate limit allows in these 6 hours; larger requests are rejected with "No more than N translations may be queued at once". Final failures are written to the log and the page stays under "Needs update".
Translate pages in the admin panel
Page list
The page list always shows one language, which you choose in the language selector above the tree. Next to each language, the selector shows how many pages need an update, are missing or are unreviewed AI drafts. Pages without a variant in that language are dimmed and show their source name. Use the Create button of such a page to add the language as a copy of the source, or Restore if the language is in the trash.
The Translation filter of the page list finds the pages that need work, with the number of pages next to each entry:
- Needs update: the source page was published with changes since the last translation.
- Missing: the page has no variant in the selected language yet.
- AI draft: the latest draft was written by the AI and nobody has saved it since.
Select several pages and use Translate in the bulk menu to translate them at once. A progress bar shows how many pages are done, and pages with running translations show e.g. "Translating into DE, FR" in the tree. You can leave the page meanwhile, the translation continues in the background.
Page editor
The language menu in the page editor lists all languages with their state: Source, Up to date, Needs update, Trashed or Create for a missing language. Switching the language saves your changes first.
If the translation needs an update, the menu offers Translate and Ignore changes. Translate translates the changed parts in the background and saves the result as a draft by the editor "AI draft". Review the changes, e.g. in the version history, and publish the draft like any other change. If you save a draft while the AI is translating, your changes are merged with the translation instead of being overwritten.
Ignore changes marks a translation as up to date without changing its content, e.g. if the source only got a typo fix.
Use Delete this language to move a variant to the trash. Restore this language brings it back until it's purged or removed automatically after the number of days in CMS_PRUNE. The source variant can't be deleted; delete the whole page or change its source language first.
How changes are merged
PagibleAI stores a checksum of every element, meta entry and page field of the source when a translation is made. The next Translate only sends the items whose checksum changed:
- New elements of the source are added to the translation at the same position.
- Elements deleted in the source are removed from the translation.
- Elements you deleted only in the translation stay deleted.
- Elements you added only in the translation are kept after their predecessor.
- A reference to a shared element is kept if you replaced it in the translation.
- Config entries and fields like type, theme, tag and cache are copied from the source without translation.
Restoring an old version of a translation also marks it as "Needs update". Changing the source language of a page keeps the other languages linked to the new source.
URLs of translations
The path of a new variant is the translated slug below the path of the nearest parent page in that language, e.g. fr/a-propos if the French parent page has the path fr. If the path is already taken, -<lang> is appended, then -<lang>-2 and so on. Later translations keep the path, so published URLs stay stable. Only a path that was copied untranslated is replaced by the translated slug, unless an editor changed it. Links to other pages of your site in text, markdown and URL fields are changed to the URLs of these pages in the target language if they have one.
Without AI translation
Translating pages with AI requires the page:save and text:translate permissions, translating file descriptions file:save and text:translate. Users without text:translate don't see Translate. They add a language with Create in the page list or the language menu, which copies the source page. You translate the texts by hand, and the page stays under "Needs update" until an AI translation or Ignore changes marks it as done. See Configure DeepL to set up a translation provider.
What gets translated
Texts of the field types string, text, plaintext and markdown are translated, as well as table cells and fields within items. The page title, name and meta texts are translated too. HTML fields and config entries are copied unchanged. The site name and page title are sent to the provider as context.
Theme developers can keep values unchanged in all languages, e.g. codes, currencies or reference numbers, with "translate": false in the schema.json of the theme:
"currency": {
"type": "string",
"translate": false,
"label": "Currency"
}
The same flag on an element type excludes all of its fields, like the built-in code element does. See Create Content Elements for the schema format.
Shared elements and files
Shared elements and files have a language too. Leave it empty for content used in all languages, like logos or address blocks. When you insert a shared element into a page, the element picker shows the elements of the page language by default.
Shared elements aren't translated by the page translation. Create one shared element per language and reference the right one in each page variant. To translate its texts with AI, use the translate GraphQL mutation or the translate-content MCP tool and save the result in the element of the target language.
File descriptions (alt texts) and transcriptions are kept per language. Select files in the file list and use Translate descriptions to fill the missing languages with AI. The translations are saved as file drafts. Each request translates up to 100 files into up to 5 languages from CMS_LOCALES, while page translations take up to 1,000 pages at once.
Languages on the website
Each language variant has its own URL. The theme renders pages with the language set in <html lang> and dir="rtl" for right-to-left languages, and Laravel uses that language for the texts of the theme.
- Language switcher: the themes show a language menu with the published languages of the current page if it has more than one. Add it to your own layouts with
<x-cms::languages :page="$page" :nav="$nav" />. - hreflang: pages with more than one published language link to all of them with
<link rel="alternate" hreflang>. If one of them is in the language set inAPP_FALLBACK_LOCALE, it's also linked asx-default. - Sitemaps: the sitemap lists the URL of every published language variant, and the news sitemap uses the language of each article.
- Search: the search index contains all languages and frontend searches only return pages in the current language.
One domain per language works too. Set the domain of the top-level page in each language; new translations of the sub-pages use the domain of their parent page in the same language.
Translator accounts
The translator role allows editing, translating with AI and publishing single languages, but not moving, deleting or restructuring pages. Combine it with writable languages to limit a user to the languages they are responsible for:
php artisan cms:user -a translator --langs=fr --langs=it translator@example.com
Users with writable languages can only change and publish pages, elements and files in these languages. They can't change the domain or language of a page or its source language. Shared elements and files without a language can only be changed by unrestricted users. You can also set the writable languages in the user management of the admin panel. See Authorization and Permissions for all roles and permissions.
APIs
lang argument on the page query and mutations, variants field with the state of each language, translation filter of the page listtranslatePage(id: [ID!], lang: [String!]) and translateFiles(id: [ID!], lang: [String!]) mutations, translateProgress(batch) query and mutations to add, drop and restore languageslang parameter on get-page, save-page, search-pages, get-page-history and publish-pagetranslate-page with a list of languages, translate-content for free text, drop-page-variant, restore-page-variantfilter[lang] for pages and their relations, variants attribute with the URLs of all visible and hidden languageslanguage(), fallback() and visible() methods of the PageView::query() builderVariants facade to add, save, translate, publish, drop, restore and purge languagesThe other GraphQL mutations for languages are translate for free text, addPageVariant, ignoreChanges, dropPageVariant, keepPageVariant and purgePageVariant. See GraphQL Pages for their arguments.
Import multilingual sites
The TYPO3, Drupal, Joomla and Statamic importers add the translations of a page as published language variants of the same page instead of separate pages. Map the languages of the old site with --language, using the language key of the source CMS:
- TYPO3: the language ID, e.g.
--language=1:de - Joomla: the language tag, e.g.
--language=de-DE:de - Drupal: the language code, e.g.
--language=de:de - Statamic: the site handle, e.g.
--language=german:de
Append a URL as third part to import a language with its own domain, e.g. --language=fr-FR:fr:https://example.fr/. For Statamic sites that aren't stored in the database, the third part can also be the URL path of the site, e.g. --language=german:de:/de/. Imported URLs are kept as they are. If a translation has the same elements in the same order as its original, the importer links them so later changes show up under "Needs update"; otherwise the translation is marked as "Needs update" right away. When you run an import again, it skips translations you changed in PagibleAI. See the Reference for all import commands.
Frequently asked questions
Can I use one domain per language?
Set the domain of the top-level page in each language, e.g. example.de for German and example.fr for French. New translations of the sub-pages use the domain of their parent page in the same language.
Does PagibleAI support right-to-left languages?
Pages in right-to-left languages like Arabic or Hebrew are rendered with dir="rtl", and the themes adapt their layout to it.
What does AI translation cost?
PagibleAI itself is free and open source. You pay your translation provider, e.g. DeepL, for the translated text. Because Translate only sends the parts that changed since the last translation, updates of existing pages cost a fraction of a full translation.
Can I translate pages without AI?
You can add a language with Create and translate the texts by hand, as described in Without AI translation.