Nikki added a comment.

  I recently found out that the extension.json files support the key 
`ExtraLanguageNames` (see docs/config-schema.yaml 
<https://github.com/wikimedia/mediawiki/blob/master/docs/config-schema.yaml>).
  
  The documentation isn't clear enough for me to understand how I'm supposed to 
use it, but after some trial and error it seems if I add the following to 
extension-repo.json, I get an entry in the list of languages for that value 
that I'm able to use to create items and lexemes and add monolingual text 
statements:
  
    "config": {
        "ExtraLanguageNames": {
        "value": {
                "en-x-extjson": "English (from extension.json)"
        }
    },
  
  Would that perhaps be an option? As I understand it, that would essentially 
be adding it to `$wgExtraLanguageNames` from the extension itself instead of 
from Wikimedia's config. The description of this ticket says that using 
`$wmgExtraLanguageNames` "was bad for several reasons" but I'm not sure what 
those reasons actually are. The main thing I can think of is that adding them 
to Wikimedia's config doesn't make them available to third-party users, but if 
they're added in extension.json, they would be.
  
  In T273627#9020435 <https://phabricator.wikimedia.org/T273627#9020435>, 
@Lucas_Werkmeister_WMDE wrote:
  
  > @Michael pointed out one thing `$wmgExtraLanguageNames` //doesn’t// 
provide: language fallbacks. For example, `nan-hani` on Wikidata only falls 
back to `en`, not to `nan` (or `cdo`, `zh-hant`, `zh`, `zh-hans`). IMHO this 
might be worth tackling as part of this task (e.g., if we end up adding some 
place in the Wikibase config where autonyms of non-MediaWiki languages can be 
defined, perhaps that place should also support defining language fallbacks for 
them).
  
  Adding a language to Names.php doesn't provide language fallbacks either. 
Fallbacks (and direction) are defined separately in the 
`languages/messages/MessagesXx.php` files. I don't know why those 
MessagesXx.php files can't created in core if we've determined what the 
fallbacks/direction should be, but I discovered via includes/Hooks.php 
<https://gerrit.wikimedia.org/g/mediawiki/extensions/LandingCheck/+/master/includes/Hooks.php>
 and messages/MessagesEs_419.php 
<https://gerrit.wikimedia.org/g/mediawiki/extensions/LandingCheck/+/master/messages/MessagesEs_419.php>
 in the "LandingCheck" extension that it's possible for extensions to add their 
own MessagesXx.php files containing fallbacks/direction.
  
  I have no idea what I'm doing but I seem to have got my local test Wikibase 
to add fallbacks and direction for a custom language code by:
  
  creating `repo/messages/MessagesEn_x_extjson.php` with
  
    <?php
    
    $fallback = "yi, he, ar";
    $rtl = true;
  
  creating `repo/includes/Hooks/GetMessagesFileNameHandler.php` with
  
    <?php
    
    namespace Wikibase\Repo\Hooks;
    
    class GetMessagesFileNameHandler {
        public static function onGetMessagesFileName( $code, &$file ) {
                $filename = dirname( __DIR__ ) . '/../messages/Messages' . 
str_replace( '-', '_', ucfirst( $code ) ) . '.php';
                if (is_readable( $filename )) {
                        $file = $filename;
                }
        }
    }
  
  and then adding `"Language::getMessagesFileName": 
"\\Wikibase\\Repo\\Hooks\\GetMessagesFileNameHandler::onGetMessagesFileName",` 
to the "Hooks" section of extension-repo.json.

TASK DETAIL
  https://phabricator.wikimedia.org/T273627

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Nikki
Cc: Bugreporter, Michael, Mahir256, hoo, Manuel, Nikki, Lucas_Werkmeister_WMDE, 
Aklapper, Danny_Benjafield_WMDE, mrephabricator, Astuthiodit_1, MaryMunyoki, 
karapayneWMDE, Invadibot, maantietaja, ItamarWMDE, Akuckartz, Nandana, Lahi, 
Gq86, GoranSMilovanovic, QZanden, srishakatux, KimKelting, LawExplorer, 
_jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, Lydia_Pintscher, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to