Templates in the Grammar Engine

While many placeholder texts in English can be implemented by simply inserting values as-is, most other languages require more attention, handling declension, article selection, and other details.

As such it is possible for every placeholder in texts parsed by the Grammar Engine to optionally define one or multiple tags to specficy how to interpret the placeholder and/or an actual grammatical case to be used.

Implicit Detection

Most common use cases in many languages can be auto-detected by the Grammar Engine. For this to be possible, placeholders have to be directly preceded by the correct articles or prepositions in masculine form (even if the inserted placeholder value is known to never be masculine in the first place). For example, in German der <<1>> will cause the library to always insert the correct definite article in nominative case according to the value.

Explicit Declaration

In many cases the implicit detection might not be an option, for example when inserting only pronouns. In this case you can directly define grammatical case and/or the specific terms to be inserted as <<case:variable>>, <<case,tags:variable>>, or <<tags:variable>>.

Available Grammatical Cases

The Grammar Engine supports the following grammatical cases depending on the active language:

Code(s) Description
nom ime име Nominative case
gen rod род Genitive case
dat дат Dative case
acc akk vin вин Accusative case
loc lok Locative case
voc vok Vocative case
ins tvo тво Instrumental case
pre пре Prepositional case

Available Placeholder Tags

The Grammar Engine supports a whole range of extra tags to change the inserted value. For example, it's possible to create genitive/owner constructs, generate matching pronouns, and more. The following is just an excerpt of the most commonly used tags. For a full and up to date list, please refer to the official documentation.

Text Manipulation

Tag Description
x Insert generated text, but not the actual value.
X Insert the value as-is without trying to parse it first.
c Force first character to lowercase.
C Force first character to uppercase.
z Force all characters to lowercase.
Z Force all characters to Uppercase.
t Apply title case according to commonly accepted standards.
T Force title case on all words.

Text formatting

Tag Description
f Format/transform a numeric value from English to the current language's locale.
F Format/transform a numeric value from English to the current language's locale forcing thousand separators.
R Format a numeric value as a Roman literal.
q Apply single quotes, if the inserted value is considered a proper name.
Q Apply double quotes, if the inserted value is considered a proper name.

Articles

Tag Description
a Insert the value with an indefinite article.
A Insert the value with a definite article.
!A ~A Never insert any article.

Pronouns

Some tags accept a number argument (# below) with an optional gender to define the n-th person form to be used (e.g. o1 for first possessive pronoun or p3m for third person possessive masculine pronoun). If # is equal to 3 or omitted and no gender tag directly follows it, this typically assumes to third person based on the value.

Tag Description
d Insert the appropriate demonstrative pronoun together with the value.
D Insert the appropriate demonstrative pronoun without the value (equal to xd).
o# Insert the appropriate possessive pronoun, where # defines the person.
O# Insert the appropriate possessive pronoun used substitutionally, where # defines the person.
p# Insert the appropriate pronoun, where # defines the person.
P# Insert the appropriate pronoun in dative case, where # defines the person.
r# Insert the appropriate

Grammatical Cases

Tag Description
g Accepts two values (object and indefinite owner) to construct a genitive statement (e.g. object of an owner or owner's object).
G Accepts two values (object and definite owner) to construct a genitive statement (e.g. object of the owner or owner's object).

Switches

Sometimes it might be necessary to change parts of texts based on the singularity or plurality of a value or based on its gender. Both of these can be achieved by embedding all possible options within a placeholder, where the resulting text will depend on the value to be inserted (or actually be omitted).

Singular/Plural Switches

Placeholder Description
<<variable[singular/plural]>> Pick different text based on the numerical value.
<<variable[zero/singular/plural]>> Pick different text based on the numerical value.
<<variable[singular/plural 1/plural 2]>> Pick different text based on the numerical value for languages with multiple plural forms.

The individual values within brackets may contain %s, $s, %d, or $d placeholders, which will be replaced by the actual value. If the value is not a number, it will be treated as singular or plural based on its set gender.

Please note that the exact order, meaning, and availability of the options may vary by language.

Gender Switches

Placeholder Description
<<variable{m/f}>> Pick different text based on the grammatical gender of the value.
<<variable{m/f/n}>> Pick different text based on the grammatical gender of the value.
<<variable{m/f/n/p}>> Pick different text based on the grammatical gender of the value.
<<variable{m/f/pm/pf}>> Pick different text based on the grammatical gender of the value.

Please note that the exact order, meaning, and availability of the options may vary by language.