Thread:Support/About MediaWiki:Translate-fs-userpage-level-X/reply (5)

Another difficulty is that we may need language-specific info about
 * the gender of the actually translated language name ($1) (most languages in French are masculine, if they have a defined adjective used as a substantive, but some languages don't and require an additional noun like "langue" with a complement qualifying the language, so that the whole become feminine),
 * sometimes the singular or plural number of this name (there are a few languages named in plural)
 * plus sometimes an info if the translated language name requires an alternate form for a surrounding word (E.g. in French, we need to replace sometime the definite article "le " or "la " into "l’" when it occurs before the language name, or to replace "de " by "d’" with the same rule, depending on whever the translated language name starts with a vowel or non-aspirated h).
 * some languages will need to change the grammatical case to infer a different suffix.
 * some languages will have mutating letters at the begining or end of the translate language name, depending on context.

To allow those forms, we should be able to provide multiple grammatical variant of the language name, according to its use (the number of variants needed is specific to the target translation language *and* to the referenced language name to translate). So translations should offer a way to add a variant, with a conventional semantic label whose value would be part of a set specific to the target translation language.

Then to translate a language name, we should use something like  instead of just.
 * Notes: if the  parameter is not specified, its default remains the current UI language of the viewing user; if the variant-label is not specified, it means to use the default variant for the specified or default target language; it should be invalid to specify a variant-label without specifying the target language in the second code.

For example, in French:
 * « Je suis un locuteur natif de  » would instruct to select the correct variant so that the translated language name will be prefixed by the correct definite article (le, la, l’, les).
 * For translating the language name for " ", we would provide the standard default variant as « anglais », but the variant labelled with  for the definite article would return « l’anglais ».
 * For translating the language name for " ", we would provide the standard default variant as « français », but the variant labelled with  for the definite article would return « le français »
 * For translating the language name for " ", we would provide the standard default variant as « langue des signes française », but the variant labelled with " " for the definite article would return « la langue des signes française »
 * Variants which should be added dynamically directly in the translation box interface to any translatable resource. The box would support it by adding a table listing the variants, plus a "add variant" button above it (all possible variants for the same resource and target language name must have a unique distinctive label for that resource).
 * Variants can be added/removed to a resource, independantly of the other languages. The set of labels are specific to each target language, there can be as many as needed in each target language, but those variants don't make sense in other languages.


 * Referencing variants in other translated messages and generating the text

If a resource is translated but does not define a variant with this label, the translation script would select the default variant, possibly through a template adding some default characters/words specific for a variant label but not to a specific language (e.g., the variant with label " " in French would implicitly format the default variant as "le $1", so that only languages that are feminine, or plural, or start with a vowel or unaspirated h would need to specify the variant using "la $1" or "les $1" or "l’$1".

This request is not specific to language names. Actually, there are reasons to include this feature with any other uses, and MediaWiki should offer the special template  instead of just   which only returns the default variant, and this syntax would be extremely useful to correctly select and insert the correct form of a translatable resource in the definition of another resource transcluding it.


 * Where to store and export the variants to MediaWiki

First we would need to be able to store variants as separate sources in the "mediawiki:" namespace. in this namespace, resources have names without a "/", but the first lsah is used to separate the language code for which it is translated. So we can add another "/" after the language code to include the variant label as another subpage. For example, suppose that the database of default variants for language names is :


 * MediaWiki:Language-name/de/en = "German"
 * MediaWiki:Language-name/de/fr = "allemand"
 * MediaWiki:Language-name/en/en = "English"
 * MediaWiki:Language-name/en/fr = "anglais"
 * MediaWiki:Language-name/fr/en = "French"
 * MediaWiki:Language-name/fr/fr = "français"
 * MediaWiki:Language-name/ja/en = "Japanese"
 * MediaWiki:Language-name/ja/fr = "japonais"
 * MediaWiki:Language-name/nl/en = "Dutch"
 * MediaWiki:Language-name/nl/fr = "néerlandais"
 * MediaWiki:Language-name/pt/en = "Portuguese"
 * MediaWiki:Language-name/pt/fr = "portugais"
 * MediaWiki:Language-name/sgn-fr/en = "French sign language"
 * MediaWiki:Language-name/sgn-fr/fr = "langue des signes française"


 * (Note that this database above is currently managed in a "special translations" interface, and stored as generated PHP scripts, preloaded within the MediaWiki server; but I don't see why we continue maintaining those scripts that can only be installed by migrating and deploying Mediawiki versions, when this could work online directly, the resources being loaded on demand and cached from the standard MediaWiki database.)

Then we can also add the French-specific variants labelled "le-nom" to these names:


 * MediaWiki:Language-name/de/fr/le-nom = "l’allemand"
 * MediaWiki:Language-name/en/fr/le-nom = "l’anglais"
 * MediaWiki:Language-name/fr/fr/le-nom = "le français"
 * MediaWiki:Language-name/nl/fr/le-nom = "le néerlandais"
 * MediaWiki:Language-name/ja/fr/le-nom = "le japonais"
 * MediaWiki:Language-name/pt/fr/le-nom = "le portugais"
 * MediaWiki:Language-name/sgn-fr/fr/le-nom = "la langue des signes française"

Then we need a way to provide defaults for common variants (above, in French, it very common that the "le" variant will just add the term "le " before the default language name, in most cases).

This means that if a variant is not found in, then the translator code will see if there's a resource named :

If such resource is found, it will insert the following Wikicode:

causing that alternate resource to be used as a regular template, which is also editable the same way as above (because it has a resource name "translation-variant:resource-name" also localisable in all languages like other resources. For example, the translations of this resource could be:


 * MediaWiki:translation-variant:Language-name/en = " " (dummy default variant, don't need to be physically present in the database)
 * MediaWiki:translation-variant:Language-name/fr = " " (dummy default variant, don't need to be physically present in the database)
 * MediaWiki:translation-variant:Language-name/fr/le-nom = " le " (default is masculine, not feminine, not plural, without apostrophe)
 * With this, we no longer need to add the (many) variant resources like:
 * MediaWiki:Language-name/fr/fr/le-nom = "le français"
 * MediaWiki:Language-name/ja/fr/le-nom = "le japonais"
 * MediaWiki:Language-name/nl/fr/le-nom = "le néerlandais"
 * MediaWiki:Language-name/pt/fr/le-nom = "le portugais"
 * because they are now template-generated (from the invokation of, or here with  which would use the same database) using directly the default variants from the core database above:
 * MediaWiki:Language-name/de/fr = "allemand"
 * MediaWiki:Language-name/en/fr = "anglais"
 * MediaWiki:Language-name/fr/fr = "français"
 * MediaWiki:Language-name/ja/fr = "japonais"
 * MediaWiki:Language-name/nl/fr = "néerlandais"
 * MediaWiki:Language-name/pt/fr = "portugais"
 * MediaWiki:Language-name/sgn-fr/fr = "langue des signes française"
 * But we still need to define the (much fewer) exceptions for the same invokation:
 * MediaWiki:Language-name/de/fr/le-nom = "l’allemand" or "l’", instead of the default "le " generated by the template invokation
 * MediaWiki:Language-name/en/fr/le-nom = "l’anglais" or "l’"
 * MediaWiki:Language-name/sgn-fr/fr/le-nom = "la langue des signes française" or "la "
 * MediaWiki:translation-variant:Language-name/fr/de-nom = " de " (default is masculine/feminine, singular/plural, without apostrophe)
 * But we just need to define the (much fewer) exceptions for the similar invokation of :
 * MediaWiki:Language-name/de/fr/de-nom = "d’allemand"
 * MediaWiki:Language-name/en/fr/de-nom = "d’anglais"
 * MediaWiki:Language-name/sgn-fr/fr/de-nom = "de langue des signes française"
 * MediaWiki:translation-variant:Language-name/de = " " (dummy default variant, don't need to be physically present in the database)
 * MediaWiki:translation-variant:Language-name/de/Name = " Sprache "
 * MediaWiki:translation-variant:Language-name/de/der-Namer = " der er Spacher " (genitive definite article and noun)
 * We still need the exception for MediaWiki:Language-name/sgn-fr/de/der-Name to avoid the repetition (and incorrect additional termination) of "Sprache" already in.
 * MediaWiki:translation-variant:Language-name/de/die-Name = " die Sprache " (nominative definite article and noun)
 * We still need the exception for MediaWiki:Language-name/sgn-fr/de/die-Name to avoid the repetition of "Sprache" already in.
 * MediaWiki:translation-variant:Language-name/de/der-Namer = " der er Spacher " (genitive definite article and noun)
 * We still need the exception for MediaWiki:Language-name/sgn-fr/de/der-Name to avoid the repetition (and incorrect additional termination) of "Sprache" already in.
 * MediaWiki:translation-variant:Language-name/de/die-Name = " die Sprache " (nominative definite article and noun)
 * We still need the exception for MediaWiki:Language-name/sgn-fr/de/die-Name to avoid the repetition of "Sprache" already in.

We can then make as many variants needed for each language to correctly infer variants, or mutate surrounding words. The choice of labels is fully open.

Finally, variant-labels are not just restricted to define variants, they could as well define other metadata, such as encoding directly the gender (masculine, feminine, neutral...), number (singular, plural, dual, ...), or only a part of the name (for example the initial letters subject to contextual mutations, as in Celtic languages or in Arabic), or its specific invariability according to other standard variants of the language (to avoid defining many other specific variants for the same resource in the same language). Those metadata can help implement more efficiently the default "translation-variant:..." templates with much less resources to define.