Page MenuHomePhabricator

Allow override language name translations instead of only autonyms in system messages or config options
Open, Needs TriagePublicFeature

Description

Allow override language name translations instead of only autonyms in system messages or config options.

Use case(s):
When we override extra language names in $wgExtraLanguageNames , it only allow us to override the autonyms for now.

This behavior

  • Makes extra language names untranslatable (compared to when CLDR extension enabled)
  • Makes language name inconsistency when overriding deprecated codes (for example, als vs. gsw)

The hook onLanguageGetTranslatedLanguageNames can be used for providing translated language names. However, it cannot be easily configured.

We should provide an easier way to override language name translations.

Event Timeline

Arguably that is not the purpose of the global variable. Hook onLanguageGetTranslatedLanguageNames can be used for providing translated language names.

Winston_Sung renamed this task from Allow $wgExtraLanguageNames override language name translations instead of only autonyms to Allow override language name translations instead of only autonyms in system messages or config options.Jan 23 2024, 9:24 AM
Winston_Sung updated the task description. (Show Details)

The CLDR extension already provides two mechanisms for overriding translated language names:

  1. LocalNames/ PHP files — per-language overrides that take precedence over CLDR data (requires code deploy)
  2.  onLanguageGetTranslatedLanguageNames  hook — programmatic overrides at runtime

The gap identified here is ease of configuration — neither approach is accessible to wiki admins without PHP access.

Proposed solution (within the CLDR extension, no core changes needed):

A new config variable  $wgExtraTranslatedLanguageNames  that the CLDR extension reads in its hook handler. Shape:

$wgExtraTranslatedLanguageNames = [
    'fr' => [
        'als' => 'alémanique',
        'gsw' => 'alémanique',
    ],
    'en' => [
        'als' => 'Alemannic',
    ],
];

This would be checked in  LanguageNames::loadLanguage()  (or in the  Hooks  class), taking precedence over both CLDR data and LocalNames/ files.

Questions before implementation:

  1. Is this the right shape for the config? (Outer key = UI language, inner key = language code being named, value = display name.)
  2. Should it take precedence over LocalNames/ overrides, or sit between CLDR data and LocalNames/?
  3. Is there a concrete deployment where this would be used? The  als  vs  gsw  inconsistency mentioned in the description would be a good test case.
  4. An alternative approach using system messages (e.g.,  MediaWiki:Cldr-language-name-gsw/fr) is also possible via the existing i18n message system, but would require the CLDR extension to check for message overrides at runtime, which has performance implications.

An alternative approach using system messages (e.g.,  MediaWiki:Cldr-language-name-gsw/fr) is also possible via the existing i18n message system, but would require the CLDR extension to check for message overrides at runtime, which has performance implications.

See also: T231755#11884157

siebrand claimed this task.

The main pain point described in this task — language name translations
being inaccessible to the community and slow to deploy — is now
resolved. Translated language names for all supported locales can be
contributed and corrected directly on translatewiki.net and are published quickly, without requiring a CLDR
release cycle.

I am closing this task as resolved. If there is a concrete need for
per-wiki configuration overrides (e.g. a $wgExtraTranslatedLanguageNames
variable allowing wiki admins without PHP access to override translated
language names locally), please open a new, focused feature request for
that specific use case.

Reopen this task since this is requested in point 3 of T190129: Consolidate language metadata into a 'language-data' library and use in MediaWiki. Especially for wikis using stable MediaWiki verison, there are currently no way to hotfix errors in CLDR without modifying the json files in CLDR extension (which will be overwritten once the extension is upgraded).

A specific example: A wiki want to support Quenya language. For now neither name of "Quenya" nor name of other languages in Quenya can be set in on-wiki message. The only current way to do so is to modify i18n/LanguageNames/en.json file, which is a hack.