From 12cd05627746410e8e604d66c55fac3ae4bb726f Mon Sep 17 00:00:00 2001
From: Lloyd Hilaiel <lloyd@hilaiel.com>
Date: Fri, 13 Jul 2012 13:48:13 -0600
Subject: [PATCH] use gobbledygook for an always-available debug locale

---
 lib/i18n.js                                    |  8 ++++++--
 lib/static_resources.js                        |  3 ++-
 package.json                                   |  1 +
 resources/static/common/js/gettext.js          | 14 +++++++++++---
 resources/static/common/js/lib/gobbledygook.js |  1 +
 tests/static-resource-test.js                  |  2 +-
 6 files changed, 22 insertions(+), 7 deletions(-)
 create mode 120000 resources/static/common/js/lib/gobbledygook.js

diff --git a/lib/i18n.js b/lib/i18n.js
index 70aed66f4..0210bb1bf 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 31cf4e08e..87575a137 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 2d1810ee6..fda87e86a 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 a5d341394..a8794883e 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 000000000..1403b642a
--- /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 76307a47a..8a91b1331 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;
-- 
GitLab