From df4c6ca1c8cedf43d37f5333f85e7e715e386f50 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 9 Jan 2014 13:37:25 -0500 Subject: [PATCH] integrating client side translator into new languages tab in ACP --- public/src/translator.js | 17 +++++++---------- src/routes/api.js | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/public/src/translator.js b/public/src/translator.js index 0808bacff3..9923cf9517 100644 --- a/public/src/translator.js +++ b/public/src/translator.js @@ -5,15 +5,11 @@ /* * TODO: * - * 1. language en is hardcoded while system is developed. to switch language packs for now please edit DEFAULT_LANGUAGE - * b. need to write fallback system to default language if keys are missing (is this even necessary?) - * 2. recursion needed when parsing language keys (ex. topics:modal.delete.title), right now json is all one level deep - * 3. user side settings for preferred language + * 1. recursion needed when parsing language keys (ex. topics:modal.delete.title), right now json is all one level deep + * 2. user side settings for preferred language * */ - var DEFAULT_LANGUAGE = 'en'; - var translator = {}, files = { loaded: {}, @@ -30,7 +26,7 @@ }; translator.getLanguage = function() { - return DEFAULT_LANGUAGE; + return config.defaultLang; }; translator.get = function (key, callback) { @@ -140,7 +136,7 @@ files.loading[filename] = true; - jQuery.getJSON(RELATIVE_PATH + '/language/' + DEFAULT_LANGUAGE + '/' + filename + '.json?v=' + timestamp, function (language) { + jQuery.getJSON(RELATIVE_PATH + '/language/' + config.defaultLang + '/' + filename + '.json?v=' + timestamp, function (language) { files.loaded[filename] = language; if (callback) { @@ -161,9 +157,10 @@ var utils = require('./utils.js'), path = require('path'), - fs = require('fs'); + fs = require('fs'), + Meta = require('../../src/meta'); - utils.walk(path.join(__dirname, '../../', 'public/language/' + DEFAULT_LANGUAGE), function (err, data) { + utils.walk(path.join(__dirname, '../../', 'public/language/' + Meta.config.defaultLang), function (err, data) { var loaded = data.length; for (var d in data) { diff --git a/src/routes/api.js b/src/routes/api.js index 776660cec1..101e2f4328 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -44,6 +44,7 @@ var path = require('path'), config.allowFileUploads = meta.config.allowFileUploads; config.maximumFileSize = meta.config.maximumFileSize; config.emailSetup = !!meta.config['email:from']; + config.defaultLang = meta.config.defaultLang; res.json(200, config); });