[483] | 1 | define(["doh/main", "../has", "../i18n", "require"], function(doh, has, i18n, require){ |
---|
| 2 | var |
---|
| 3 | getAsyncTest = function(value, locale){ |
---|
| 4 | return function(){ |
---|
| 5 | var def = new doh.Deferred(); |
---|
| 6 | require([i18n.getL10nName("dojo/tests", "salutations", locale)], function(bundle){ |
---|
| 7 | doh.assertEqual(value, bundle.hello); |
---|
| 8 | def.callback(true); |
---|
| 9 | }); |
---|
| 10 | return def; |
---|
| 11 | }; |
---|
| 12 | }, |
---|
| 13 | |
---|
| 14 | getSyncTest = function(value, locale){ |
---|
| 15 | return function(){ |
---|
| 16 | doh.assertEqual(value, i18n.getLocalization("dojo/tests", "salutations", locale).hello); |
---|
| 17 | }; |
---|
| 18 | }, |
---|
| 19 | |
---|
| 20 | getFixture = function(locale, value){ |
---|
| 21 | return { |
---|
| 22 | name: "salutations-"+locale, |
---|
| 23 | timeout: 2000, |
---|
| 24 | runTest: (require.async ? getAsyncTest : getSyncTest)(value, locale) |
---|
| 25 | }; |
---|
| 26 | }, |
---|
| 27 | |
---|
| 28 | testSet = [ |
---|
| 29 | // Locale which overrides root translation |
---|
| 30 | getFixture("de", "Hallo"), |
---|
| 31 | // Locale which does not override root translation |
---|
| 32 | getFixture("en", "Hello"), |
---|
| 33 | // Locale which overrides its parent |
---|
| 34 | getFixture("en-au", "G'day"), |
---|
| 35 | // Locale which does not override its parent |
---|
| 36 | getFixture("en-us", "Hello"), |
---|
| 37 | // Locale which overrides its parent |
---|
| 38 | getFixture("en-us-texas", "Howdy"), |
---|
| 39 | // 3rd level variant which overrides its parent |
---|
| 40 | getFixture("en-us-new_york", "Hello"), |
---|
| 41 | // Locale which overrides its grandparent |
---|
| 42 | getFixture("en-us-new_york-brooklyn", "Yo"), |
---|
| 43 | // Locale which does not have any translation available |
---|
| 44 | getFixture("xx", "Hello"), |
---|
| 45 | // A double-byte string. Everything should be read in as UTF-8 and treated as unicode within Javascript. |
---|
| 46 | getFixture("zh-cn", "\u4f60\u597d") |
---|
| 47 | ]; |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | doh.register("tests.i18n", testSet); |
---|
| 51 | if(has("host-browser")){ |
---|
| 52 | doh.register("tests.i18n.extra.sync", require.toUrl("./i18n.html"), {async:0}); |
---|
| 53 | doh.register("tests.i18n.extra.async", require.toUrl("./i18n.html"), {async:1}); |
---|
| 54 | } |
---|
| 55 | }); |
---|