Skip to content

Languages (PRO)

Multilingual without copies of the resource tree and without separate MODX contexts. A language is the context_key of a block, a table row or a resource.

PageBlocks → Constructor → Languages.

A language

SettingWhat it does
KeyWhat goes into context_key. de, for instance. Required
NameHow the language is labelled in lists. Required
Culture keyThe folder in App/lang/ and the code for a translator. Same as the key by default
LocaleThe system locale, de_DE.UTF-8
URL prefixThe address segment. Empty means the key is used
TranslatorWho machine-translates — see Translators
SettingsJSON, applied as MODX settings for the duration of the request
DefaultThe language with no prefix in the address. There can be only one
ActiveAn inactive language is invisible to the site

Content is not duplicated

This is the main departure from the usual context-based approach. A row is not copied whole for every language — a translation has its own context_key, and that is all. What has not been translated stays as a single copy and needs no attention.

Per-language settings

The Settings field takes JSON and overrides MODX system settings for the request:

json
{"site_name": "Comstil", "emailsender": "info@example.com"}

So the German version has its own site name and its own mail sender, without a single condition in a template.

The default language never has a prefix

There is one of it, and its addresses are bare: /about, not /en/about. The others live under their prefix. Which means switching the default language changes every canonical address on the site — decide it before launch, not after.

© PageBlocks 2019-present