mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #6308
This commit is contained in:
@@ -103,7 +103,7 @@
|
||||
"topics_per_page": "Topics per Page",
|
||||
"posts_per_page": "Posts per Page",
|
||||
"max_items_per_page": "Maximum %1",
|
||||
|
||||
"acp_language": "Admin Page Language",
|
||||
"notification_sounds" : "Play a sound when you receive a notification",
|
||||
"notifications_and_sounds": "Notifications & Sounds",
|
||||
"incoming-message-sound": "Incoming message sound",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var _ = require('lodash');
|
||||
|
||||
var user = require('../../user');
|
||||
var languages = require('../../languages');
|
||||
@@ -40,6 +41,9 @@ settingsController.get = function (req, res, callback) {
|
||||
function (results, next) {
|
||||
userData.settings = results.settings;
|
||||
userData.languages = results.languages;
|
||||
if (userData.isAdmin && userData.isSelf) {
|
||||
userData.acpLanguages = _.cloneDeep(results.languages);
|
||||
}
|
||||
|
||||
var types = [
|
||||
'notification',
|
||||
@@ -135,6 +139,12 @@ settingsController.get = function (req, res, callback) {
|
||||
language.selected = language.code === userData.settings.userLang;
|
||||
});
|
||||
|
||||
if (userData.isAdmin && userData.isSelf) {
|
||||
userData.acpLanguages.forEach(function (language) {
|
||||
language.selected = language.code === userData.settings.acpLang;
|
||||
});
|
||||
}
|
||||
|
||||
var notifFreqOptions = [
|
||||
'all',
|
||||
'everyTen',
|
||||
|
||||
@@ -86,6 +86,7 @@ apiController.loadConfig = function (req, callback) {
|
||||
config.topicsPerPage = settings.topicsPerPage;
|
||||
config.postsPerPage = settings.postsPerPage;
|
||||
config.userLang = (req.query.lang ? validator.escape(String(req.query.lang)) : null) || settings.userLang || config.defaultLang;
|
||||
config.acpLang = (req.query.lang ? validator.escape(String(req.query.lang)) : null) || settings.acpLang;
|
||||
config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab;
|
||||
config.topicPostSort = settings.topicPostSort || config.topicPostSort;
|
||||
config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort;
|
||||
|
||||
@@ -71,12 +71,13 @@ Languages.list = function (callback) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var lang;
|
||||
try {
|
||||
var lang = JSON.parse(file);
|
||||
next(null, lang);
|
||||
lang = JSON.parse(file);
|
||||
} catch (e) {
|
||||
next(e);
|
||||
return next(e);
|
||||
}
|
||||
next(null, lang);
|
||||
});
|
||||
}, function (err, languages) {
|
||||
if (err) {
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = function (middleware) {
|
||||
plugins: [],
|
||||
authentication: [],
|
||||
};
|
||||
|
||||
res.locals.config = res.locals.config || {};
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
@@ -51,9 +51,6 @@ module.exports = function (middleware) {
|
||||
custom_header: function (next) {
|
||||
plugins.fireHook('filter:admin.header.build', custom_header, next);
|
||||
},
|
||||
config: function (next) {
|
||||
controllers.api.getConfig(req, res, next);
|
||||
},
|
||||
configs: function (next) {
|
||||
meta.configs.list(next);
|
||||
},
|
||||
@@ -64,8 +61,6 @@ module.exports = function (middleware) {
|
||||
userData.uid = req.uid;
|
||||
userData['email:confirmed'] = parseInt(userData['email:confirmed'], 10) === 1;
|
||||
|
||||
res.locals.config = results.config;
|
||||
|
||||
var acpPath = req.path.slice(1).split('/');
|
||||
acpPath.forEach(function (path, i) {
|
||||
acpPath[i] = path.charAt(0).toUpperCase() + path.slice(1);
|
||||
@@ -73,9 +68,9 @@ module.exports = function (middleware) {
|
||||
acpPath = acpPath.join(' > ');
|
||||
|
||||
var templateValues = {
|
||||
config: results.config,
|
||||
configJSON: jsesc(JSON.stringify(results.config), { isScriptContext: true }),
|
||||
relative_path: results.config.relative_path,
|
||||
config: res.locals.config,
|
||||
configJSON: jsesc(JSON.stringify(res.locals.config), { isScriptContext: true }),
|
||||
relative_path: res.locals.config.relative_path,
|
||||
adminConfigJSON: encodeURIComponent(JSON.stringify(results.configs)),
|
||||
user: userData,
|
||||
userJSON: jsesc(JSON.stringify(userData), { isScriptContext: true }),
|
||||
|
||||
@@ -120,6 +120,9 @@ module.exports = function (middleware) {
|
||||
|
||||
function translate(str, req, res, next) {
|
||||
var language = (res.locals.config && res.locals.config.userLang) || 'en-GB';
|
||||
if (res.locals.renderAdminHeader) {
|
||||
language = (res.locals.config && res.locals.config.acpLang) || 'en-GB';
|
||||
}
|
||||
language = req.query.lang ? validator.escape(String(req.query.lang)) : language;
|
||||
translator.translate(str, language, function (translated) {
|
||||
next(null, translator.unescape(translated));
|
||||
|
||||
@@ -70,6 +70,7 @@ module.exports = function (User) {
|
||||
settings.topicsPerPage = Math.min(settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : defaultTopicsPerPage, defaultTopicsPerPage);
|
||||
settings.postsPerPage = Math.min(settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : defaultPostsPerPage, defaultPostsPerPage);
|
||||
settings.userLang = settings.userLang || meta.config.defaultLang || 'en-GB';
|
||||
settings.acpLang = settings.acpLang || settings.userLang;
|
||||
settings.topicPostSort = getSetting(settings, 'topicPostSort', 'oldest_to_newest');
|
||||
settings.categoryTopicSort = getSetting(settings, 'categoryTopicSort', 'newest_to_oldest');
|
||||
settings.followTopicsOnCreate = parseInt(getSetting(settings, 'followTopicsOnCreate', 1), 10) === 1;
|
||||
@@ -118,6 +119,7 @@ module.exports = function (User) {
|
||||
topicsPerPage: Math.min(data.topicsPerPage, parseInt(maxTopicsPerPage, 10) || 20),
|
||||
postsPerPage: Math.min(data.postsPerPage, parseInt(maxPostsPerPage, 10) || 20),
|
||||
userLang: data.userLang || meta.config.defaultLang,
|
||||
acpLang: data.acpLang || meta.config.defaultLang,
|
||||
followTopicsOnCreate: data.followTopicsOnCreate,
|
||||
followTopicsOnReply: data.followTopicsOnReply,
|
||||
restrictChat: data.restrictChat,
|
||||
|
||||
Reference in New Issue
Block a user