-->

Can I use jquery.uls on a MediaWiki wiki to get a

2019-08-09 18:10发布

问题:

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.