MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

Translations

MMO\editor\cms · 1 symbol · generated 27 Oct 2026

class

Translations

Translations.php:24

The translations of a page (Page::$translations): its texts in each of its other languages, the default one being the draft itself (Page::$languages, the first).

class MMO\editor\cms\Translations
Namespace
MMO\editor\cms
A language translates the **texts** only: the page's `title`, its `seo` title and description, and in each section the fields a reader reads -- a string of format `text` (the default) or `html`. A choice (`enum`), an address (`url`, `uri`), a code (a `pattern`: an anchor, an icon), a number, an image's address are the page's whatever the language: the sections, their order and their settings are the same in every language. A field's `"translate": true` or `false` (its schema) says otherwise. A translation holds only what is translated: `{title, seo: {title, description}, sections: {id: data}}`, the data of a section being a part of its own (a list: an item by index, `null` for one not translated). What is not translated shows in the default language ([`Merge`](https://mmoframework.fr/en/documentation/mmo.editor/php/cms/Translations.md#translations-merge)): a new language shows the page as it is, until it is translated. mmo.editor's page editor has the same rules (`MMO.editor.PageEditor#translatable()`): change both together.
$english = Translations::Version($page->exportDraft(), 'en', Pages::Shared()->getSectionTypes());

Constants1

MAX_LANGUAGES

the languages a page has at most

const MAX_LANGUAGES = 30

Methods9

Code($code)

staticTranslations.php:33
static function Code(mixed $code): ?string
$codemixeda language's tag, as a client sends it: en, pt-BR, zh-Hant, fr_FR...
returnsnull | stringthe tag a page keeps: --separated and lowercase (it is also the first folder of the page's address in that language); null when it is no language tag (RFC 5646: I18n::splitLanguage)

Filled($value)

staticTranslations.php:72
static function Filled(mixed $value): bool
$valuemixed
returnsboolwhether $value is a text that says something: not empty, nor a markup holding nothing

Kind($field, $key, $parent)

staticTranslations.php:57
static function Kind(array $field, ?string $key = null, ?array $parent = null): ?string
$fieldarray
$key = nullnull | stringits name
$parent = nullnull | array
returnsnull | stringwhat a translation does with it: text (translated), object and list (their fields may be), null (the same in every language)

LanguageOf($version, $language)

staticTranslations.php:45
static function LanguageOf(array $version, ?string $language): ?string
$versionarray
$languagenull | stringwhat is asked for
returnsnull | stringthe language $version is shown in for $language: $language when it is one of its languages, its default one otherwise; null for a page that does not say its language

Merge($schema, $data, $translation)

staticTranslations.php:83
static function Merge(array $schema, array $data, mixed $translation): array
$schemaarray
$dataarraythe default language's
$translationmixedits translation (Strip)
returnsarray$data, its texts translated where $translation has them

MergeValue($field, $kind, $value, $translation)

staticTranslations.php:92
protected static function MergeValue(array $field, ?string $kind, mixed $value, mixed $translation): mixed
$fieldarray
$kindnull | string
$valuemixed
$translationmixed
returnsmixed

Strip($schema, $translation)

staticTranslations.php:114
static function Strip(array $schema, mixed $translation): ?array
$schemaarray
$translationmixedwhat a client sent, cleaned by the type (SectionType::clean)
returnsnull | arraywhat a translation keeps of it: the texts that say something, and nothing else -- null when there is none

Version($version, $language, $types)

staticTranslations.php:147
static function Version(array $version, ?string $language, MMO\editor\cms\SectionTypes $types): array
$versionarray
$languagenull | stringone of its languages; null, or its first: the default one
$typesSectionTypes
returnsarraymixed> $version in $language: its texts translated, the default language's where they are not; language says which it is