diff --git a/lib/i18n.js b/lib/i18n.js index 70aed66f4064f4a5723a555a9edd3ada5f30dbce..0210bb1bfadf6e798bb51b70e4ac70d7924ae060 100644 --- a/lib/i18n.js +++ b/lib/i18n.js @@ -18,7 +18,8 @@ var logger = require('./logging.js').logger, path = require('path'), util = require('util'), - fs = require('fs'); + fs = require('fs'), + gobbledygook = require('gobbledygook'); // existsSync moved from path in 0.6.x to fs in 0.8.x if (typeof fs.existsSync === 'function') { @@ -114,7 +115,10 @@ exports.abide = function (options) { var gt; - if (translations[locale]) { + if (lang.toLowerCase() === debug_lang) { + gt = gobbledygook; + resp.local('lang', 'db-LB'); + } else if (translations[locale]) { gt = function(sid) { return (translations[locale][sid] ? translations[locale][sid][1] : sid); }; diff --git a/lib/static_resources.js b/lib/static_resources.js index 31cf4e08e158a5cbb870a13daeec2bb4138b2b2e..87575a1375eea7c4f0ab9aace005ce4f8df9f019 100644 --- a/lib/static_resources.js +++ b/lib/static_resources.js @@ -23,9 +23,9 @@ var common_js = [ '/common/js/lib/ejs.js', '/common/js/lib/micrajax.js', '/common/js/lib/urlparse.js', + '/common/js/lib/gobbledygook.js', '/common/js/javascript-extensions.js', '/i18n/:locale/client.json', - '/common/js/gettext.js', '/common/js/browserid.js', '/common/js/lib/hub.js', '/common/js/lib/dom-jquery.js', @@ -39,6 +39,7 @@ var common_js = [ '/common/js/validation.js', '/common/js/helpers.js', '/common/js/dom-helpers.js', + '/common/js/gettext.js', '/common/js/screens.js', '/common/js/browser-support.js', '/common/js/enable_cookies_url.js', diff --git a/package.json b/package.json index 2d1810ee6348b898996d666ebd354ee317e9d2cd..fda87e86ad8085eed862b99af52c51f1902a6442 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "ejs": "0.4.3", "etagify": "0.0.2", "express": "2.5.0", + "gobbledygook": "0.0.3", "mustache": "0.3.1-dev", "jwcrypto": "0.3.2", "mysql": "0.9.5", diff --git a/resources/static/common/js/gettext.js b/resources/static/common/js/gettext.js index a5d3413949a8c464599e7114cad10564d8144a19..a8794883efadfdd829b5e79df8a6c2d29c0d88da 100644 --- a/resources/static/common/js/gettext.js +++ b/resources/static/common/js/gettext.js @@ -6,17 +6,25 @@ (function() { "use strict"; + var bid = BrowserID, + dom = bid.DOM; + function Gettext() { return { gettext: function (msgid) { + if (window.Gobbledygook && + dom.getAttr('html', 'lang') === 'db-LB') { + return window.Gobbledygook(msgid); + } + if (window.json_locale_data && json_locale_data["client"]) { - var dict = json_locale_data["client"]; + var dict = json_locale_data["client"]; if (dict[msgid] && dict[msgid].length >= 2 && dict[msgid][1].trim() != "") { return dict[msgid][1]; } - } - return msgid; + } + return msgid; }, // See lib/i18n.js format docs format: function (fmt, obj, named) { diff --git a/resources/static/common/js/lib/gobbledygook.js b/resources/static/common/js/lib/gobbledygook.js new file mode 120000 index 0000000000000000000000000000000000000000..1403b642aef4fd46ccca2f5868826d9027e9f02f --- /dev/null +++ b/resources/static/common/js/lib/gobbledygook.js @@ -0,0 +1 @@ +../../../../../node_modules/gobbledygook/gobbledygook.js \ No newline at end of file diff --git a/tests/static-resource-test.js b/tests/static-resource-test.js index 76307a47acec4dcc7023601ac53bdff5055bbc8c..8a91b133109db90b3c8a4414c105a5ddd234b66d 100755 --- a/tests/static-resource-test.js +++ b/tests/static-resource-test.js @@ -57,7 +57,7 @@ suite.addBatch({ }); // Fragile - filename with :locale... // When fixing this test case... console.log(res[Object.keys(res)[0]]); - var localeIndex = 8; + var localeIndex = 9; assert.notEqual(files[minFile][localeIndex], res[minRes][localeIndex]); var counter = 0;