PageFactory (Kirby Plugin)

Multi-Language Content

PageFactory extends Kirby's multi-language support.

Beyond just defining entire source files for different languages, you can define language dependent content in more fine grained ways:

Variables

In most cases, text resources are stored in YAML-files. Each text resource consists of a key (or key-phrase) and language translations on consecutive lines.

Example:

your-password:
    de: "Ihr Kennwort"
    _:  "Your password"       # <- default language
    fr: "Votre mot de passe"  # <- language snipped added by translator

Note:
You can transmit such YAML-files to translators who can add their translation for each element.
Seeing other translations helps translators understanding the propre meaning and context.

Note:
It is good practice to use unique keywords for these variables because that simplifies finding the definition of a variable when you just know the raw keyword.

→ to see raw keyword rather than translated variables, open the page with ?notranslate appended to the URL (requires Admin permission or working on localhost).

 

→ See chapter Multi-Language Content.

 

Language Variants (in Variables)

In many languages (other than English) there are sub-variants, most notably for formal and informal speech.

PageFactory has built-in support for such language variants.

For example, in order to invoke "informal German" you'd simply open the page as ./?lang=de2. For this to work, variable definitions need to be supplemented.

your-password:
    _:  "Your password"   # <- default language
    de: "Ihr Kennwort"    # <- German base variant
    de2: "Dein Kennwort"  # <- German informal variant

Note also that you only need to supply the variant where it differs from base language.
I.e. if there is no de2 element, PageFactory automatically falls back to using de.
(And if de is missing, PageFactory falls back to the default language _).

 

→ See chapter Support for Informal Language-Variants.

Language Specific Text-Blocks

Within a markdown source you can define → Div Blocks. You can define a language per DivBlock. Then, that block is rendered only if it matches the currently active language.

For example:

@@@ .box !lang=de
...
@@@ .box !lang=en
...
@@@

Language Specific Source-Files

Like Kirby, PageFactory selects language specific markdown files if they contain a language indicator of type filename.de.md.

Markdown files without such an indicator will always be rendered.

 

→ See Examples