Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.Language.js |
— | — | @@ -6,9 +6,11 @@ |
7 | 7 | // TODO: make this a more common library, used by this and TimedText |
8 | 8 | mw.Language = { |
9 | 9 | |
| 10 | + defaultCode: 'en', // when we absolutely have no idea what language to preselect |
| 11 | + |
10 | 12 | initialized: false, |
11 | 13 | |
12 | | - UNKNOWN: 0, |
| 14 | + UNKNOWN: 'unknown', |
13 | 15 | |
14 | 16 | /** |
15 | 17 | * List of all languages mediaWiki supports ( Avoid an api call to get this same info ) |
— | — | @@ -398,15 +400,15 @@ |
399 | 401 | mw.Language.initialized = true; |
400 | 402 | }, |
401 | 403 | |
402 | | - getMenu: function(name, code, withUnknown) { |
| 404 | + getMenu: function(name, code) { |
403 | 405 | mw.Language.initialize(); |
404 | 406 | var $select = mw.Language.$_select.clone(); |
405 | 407 | $select.attr('name', name); |
406 | | - if (withUnknown) { |
| 408 | + if (code === mw.Language.UNKNOWN) { |
407 | 409 | // n.b. MediaWiki LanguageHandler has ability to add custom label for 'Unknown'; possibly as pseudo-label |
408 | 410 | $select.prepend($j('<option>').attr('value', mw.Language.UNKNOWN).append(gM('mwe-code-unknown'))); |
409 | | - } |
410 | | - if (code !== undefined) { |
| 411 | + $select.val(mw.Language.UNKNOWN); |
| 412 | + } else if (code !== undefined) { |
411 | 413 | $select.val(mw.Language.getClosest(code)); |
412 | 414 | } |
413 | 415 | return $select.get(0); |
— | — | @@ -419,7 +421,7 @@ |
420 | 422 | getClosest: function(code) { |
421 | 423 | mw.Language.initialize(); |
422 | 424 | if (typeof (code) != 'string' || code === null || code.length === 0) { |
423 | | - return undefined; |
| 425 | + return mw.Language.defaultCode; |
424 | 426 | } |
425 | 427 | if (code == 'nan' || code == 'minnan') { |
426 | 428 | return 'zh-min-nan'; |