问题
WikiMedia has a jquery plugin called jquery.uls (Universal Language Selector) for choosing a language in all kinds of fancy ways.
All MediaWiki sites seem to have it available to the JavaScript running on them via $.uls
. There is documentation for the ULS extension but it seems to only concern itself with the server side and how an end user would interact with it.
I want to know if I can use it to obtain a mapping from the English name of a language (such as "Vietnamese") to the ISO 639 language code for that language (such as "vi").
I can't seem to find this in the docs or find a method that does this among the exposed interfaces. Is it there and I just can't see it?
回答1:
You can use mw.config.get('wgULSLanguages')
to get an associative array where the keys are language codes and the values are language names in English.
Here there are other options you could use with this extension as well.
来源:https://stackoverflow.com/questions/29485489/can-i-use-jquery-uls-on-a-mediawiki-wiki-to-get-a-language-code-from-the-name-of