integrating client side translator into new languages tab in ACP

v1.18.x
Julian Lam 11 years ago
parent cd6af45afb
commit df4c6ca1c8

@ -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) {

@ -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);
});

Loading…
Cancel
Save