Plato on Github
Report Home
dojo/testsDOH/i18n.js
Maintainability
75.82
Lines of code
55
Difficulty
13.80
Estimated Errors
0.39
Function weight
By Complexity
By SLOC
define(["doh/main", "../has", "../i18n", "require"], function(doh, has, i18n, require){ var getAsyncTest = function(value, locale){ return function(){ var def = new doh.Deferred(); require([i18n.getL10nName("dojo/testsDOH", "salutations", locale)], function(bundle){ doh.assertEqual(value, bundle.hello); def.callback(true); }); return def; }; }, getSyncTest = function(value, locale){ return function(){ doh.assertEqual(value, i18n.getLocalization("dojo/testsDOH", "salutations", locale).hello); }; }, getFixture = function(locale, value){ return { name: "salutations-"+locale, timeout: 2000, runTest: (require.async ? getAsyncTest : getSyncTest)(value, locale) }; }, testSet = [ // Locale which overrides root translation getFixture("de", "Hallo"), // Locale which does not override root translation getFixture("en", "Hello"), // Locale which overrides its parent getFixture("en-au", "G'day"), // Locale which does not override its parent getFixture("en-us", "Hello"), // Locale which overrides its parent getFixture("en-us-texas", "Howdy"), // 3rd level variant which overrides its parent getFixture("en-us-new_york", "Hello"), // Locale which overrides its grandparent getFixture("en-us-new_york-brooklyn", "Yo"), // Locale which does not have any translation available getFixture("xx", "Hello"), // A double-byte string. Everything should be read in as UTF-8 and treated as unicode within Javascript. getFixture("zh-cn", "\u4f60\u597d") ]; doh.register("testsDOH.i18n", testSet); if(has("host-browser")){ doh.register("testsDOH.i18n.extra.sync", require.toUrl("./i18n.html"), {async:0}); doh.register("testsDOH.i18n.extra.async", require.toUrl("./i18n.html"), {async:1}); } });