1

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?

hippietrail
  • 15,848
  • 18
  • 99
  • 158

1 Answers1

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.

Community
  • 1
  • 1
DanielMK
  • 581
  • 4
  • 14
  • No, you can see it mentioned in the question as not covering what I'm looking for. Unless you can point out the section that I can't see of course. – hippietrail Apr 07 '15 at 12:10
  • you can use `mw.config.get('wgULSLanguages')`, and you will get "an associative array where the keys are language codes and the values are language names in English". Isn't it what you needed? Or i might have miss understood something – DanielMK Apr 07 '15 at 13:56
  • I wasn't able to find that on my own. Let me play with it now ... Yes that is it! I want the code from the language name but that's still easy. Edit your comment above into the answer so I can vote it up. Thanks. – hippietrail Apr 07 '15 at 14:22