comahe-de / i18n4k

Internationalization for Kotlin
Apache License 2.0
78 stars 9 forks source link

Declension-Pattern #46

Closed comahe-de closed 7 months ago

comahe-de commented 12 months ago

For languages that have irregular declension, a declension-provider is needed to find the declined form of a word.

Format:

{ PARAMETER_NUMBER, declension-DECLENSION_FORM, DEFAULT_VALUE }

In many cases the declension form can be built on general rules. For this cases for regular declension pattern should be provided per locale. If the declension-provider does not return a declined value, this pattern should be used to build a regular declension form of the parameter value. E.g. for the German "genitive" it would be {0}{0, gender, m/n: {0, grammatical-number, one: s | ? } | ? }

A general declension-provider may be based on large directories. But this is an extensive task. Therefor the default implementation will use the attributes of the LocalizedString (#43).

Example:

These subjects-strings should be defined in a separate MessageBundle where also the declension-form attribute is defined. The value of "DECLENSION_FORM" is the name of the attribute that is looked up.

For files storing the attribute, the name of the attribute is appended as extension after the locale tag via “-x-attr-declension-NAME“

subjects_en.properties

spark=spark
storm=storm

No declension for English.

subjects_de.properties

spark=Funke
storm=Sturm

subjects_de_-x-attr-declension-genitive.properties

spark=Funkens

(“Sturm” has regular declension and doesn’t need a declension entry.)