From 2ab4e592c9bf02cd8fb0404f83574b62ba54d4b1 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 26 Jan 2017 12:00:03 -0500 Subject: [PATCH] Add _tkeys_ language for translation debugging --- modules/core/context.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/core/context.js b/modules/core/context.js index 353285739..1026613c7 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -23,6 +23,24 @@ export function setAreaKeys(value) { export function coreContext() { + + // create a special translation that contains the keys in place of the strings + var tkeys = _.cloneDeep(dataEn); + var parents = []; + + function traverser(v, k, obj) { + parents.push(k); + if (_.isObject(v)) { + _.forOwn(v, traverser); + } else if (_.isString(v)) { + obj[k] = parents.join('.'); + } + parents.pop(); + } + + _.forOwn(tkeys, traverser); + addTranslation('_tkeys_', tkeys); + addTranslation('en', dataEn); setLocale('en');