Page MenuHomePhabricator

Add API to check language code validity / get all valid language codes
Closed, ResolvedPublic

Related Objects

Event Timeline

Well, which one is it – do we add an API to check language code validity, or one to get all valid language codes? :)

Personally, I’d favor one to get all valid language codes for lexeme terms (i. e. lemmas, representations and glosses – currently we use the same validator for all of them), and expose it perhaps via action=query&meta=siteinfo as a new siprop.

Alternatively, for client-side checking we could also expose the list via a ResourceLoader module?

hoo added a comment.Aug 8 2018, 10:05 AM

It seems that we do this differently for Monolingual texts atm: There this is handled via wikibase.WikibaseContentLanguages which is basically an access wrapper for mw.config.get( 'wgULSLanguages' ) (some languages supported by the backed are missing, though). This is being discussed in T124758.

Input validation is then being handled by the api (after an attempt save).

hoo added a subscriber: Addshore.Aug 8 2018, 10:42 AM

Talking to @Addshore, we probably want to go for something along the lines of action=query&meta=wikibasecontentlanguages&context=gloss.

hoo added a comment.Aug 8 2018, 12:28 PM

One question I just came across… what language shall we show the available languages in? Shall we use autonyms (native names)? What about languages that are not in CLDR?

We can either integrate these names into the API output (which is ok for autonyms, but maybe a little uggly otherwise, if this depends on the user's lang) or fetch them from ULS (as far as they're available… does ULS have all CLDR langs?).

Alternatively we could just resort to language codes and not show any names…

Autonyms where possible. We do it in other places as well.

hoo moved this task from To Do to Doing on the Wikidata-Senses-Iteration2 board.Aug 9 2018, 2:59 PM

What’s the problem with including the names in the user language in the API output? That doesn’t feel ugly to me.

Perhaps the output structure could be something like this:

"wikibasecontentlanguages": {
  "en": {
    "code": "en",
    "autonym": "English",
    "name": "inglés"
  },
  // ...
}

with some kind of wbclprops parameter to select what you want (wbclprops=code|autonym|name).

Lucas_Werkmeister_WMDE added a subscriber: hoo.

Since I’m running out of other things to do, I’ll take a stab at implementing one suggestion for such an API module.

Change 452710 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] WIP: Centrally collect various kinds of content languages

https://gerrit.wikimedia.org/r/452710

Change 452711 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] WIP: Add API to query content languages

https://gerrit.wikimedia.org/r/452711

Change 452712 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Register lexicographical content languages

https://gerrit.wikimedia.org/r/452712

Change 454238 had a related patch set uploaded (by Hoo man; owner: Hoo man):
[mediawiki/extensions/Wikibase@master] Add WikibaseContentLanguagesProvider

https://gerrit.wikimedia.org/r/454238

Change 452710 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Centrally collect various kinds of content languages

https://gerrit.wikimedia.org/r/452710

Change 452712 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Register lexicographical content languages

https://gerrit.wikimedia.org/r/452712

Change 452711 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add API to query content languages

https://gerrit.wikimedia.org/r/452711

Lydia_Pintscher closed this task as Resolved.Aug 24 2018, 12:40 PM

Change 454238 abandoned by Hoo man:
Add WikibaseContentLanguagesProvider

https://gerrit.wikimedia.org/r/454238