allow language strings in menu items

v1.18.x
psychobunny 10 years ago
parent be06162f0d
commit 1774cf0b15

@ -2,46 +2,46 @@
{
"id": "unread-count",
"route": "/unread",
"title": "[[global:header.unread]]",
"title": "\\[\\[global:header.unread\\]\\]",
"enabled": true,
"iconClass": "fa-inbox",
"textClass": "visible-xs-inline",
"text": "[[global:header.unread]]",
"text": "\\[\\[global:header.unread\\]\\]",
"properties": {
"loggedIn": true
}
},
{
"route": "/recent",
"title": "[[global:header.recent]]",
"title": "\\[\\[global:header.recent\\]\\]",
"enabled": true,
"iconClass": "fa-clock-o",
"textClass": "visible-xs-inline",
"text": "[[global:header.recent]]"
"text": "\\[\\[global:header.recen\\t\\]]"
},
{
"route": "/tags",
"title": "[[global:header.tags]]",
"title": "\\[\\[global:header.tags\\]\\]",
"enabled": true,
"iconClass": "fa-tags",
"textClass": "visible-xs-inline",
"text": "[[global:header.tags]]"
"text": "\\[\\[global:header.tag\\s\\]]"
},
{
"route": "/popular",
"title": "[[global:header.popular]]",
"title": "\\[\\[global:header.popular\\]\\]",
"enabled": true,
"iconClass": "fa-fire",
"textClass": "visible-xs-inline",
"text": "[[global:header.popular]]"
"text": "\\[\\[global:header.popula\\r\\]]"
},
{
"route": "/users",
"title": "[[global:header.users]]",
"title": "\\[\\[global:header.users\\]\\]",
"enabled": true,
"iconClass": "fa-user",
"textClass": "visible-xs-inline",
"text": "[[global:header.users]]",
"text": "\\[\\[global:header.users\\]\\]",
"properties": {
"loggedIn": true,
"hideIfPrivate": true
@ -49,31 +49,31 @@
},
{
"route": "/groups",
"title": "[[global:header.groups]]",
"title": "\\[\\[global:header.groups\\]\\]",
"enabled": true,
"iconClass": "fa-group",
"textClass": "visible-xs-inline",
"text": "[[global:header.groups]]"
"text": "\\[\\[global:header.group\\s\\]]"
},
{
"route": "/admin",
"target": "_top",
"title": "[[global:header.admin]]",
"title": "\\[\\[global:header.admin\\]\\]",
"enabled": true,
"iconClass": "fa-cogs",
"textClass": "visible-xs-inline",
"text": "[[global:header.admin]]",
"text": "\\[\\[global:header.admin\\]\\]",
"properties": {
"adminOnly": true
}
},
{
"route": "/search",
"title": "[[global:header.search]]",
"title": "\\[\\[global:header.search\\]\\]",
"enabled": true,
"iconClass": "fa-search",
"textClass": "visible-xs-inline",
"text": "[[global:header.search]]",
"text": "\\[\\[global:header.search\\]\\]",
"properties": {
"installed": {
"search": true

@ -1,5 +1,5 @@
"use strict";
/* global define, app, ajaxify, socket, templates, bootbox */
/* global define, app, ajaxify, socket, templates, bootbox, translator */
define('admin/general/navigation', function() {
var navigation = {},
@ -8,6 +8,12 @@ define('admin/general/navigation', function() {
navigation.init = function() {
available = JSON.parse(ajaxify.variables.get('available'));
$('#enabled').html(translator.unescape($('#enabled').html()));
translator.translate(translator.unescape($('#available').html()), function(html) {
$('#available').html(html);
});
$('#enabled')
.on('click', '.delete', remove)
.on('click', '.toggle', toggle)
@ -33,7 +39,7 @@ define('admin/general/navigation', function() {
data = id === 'custom' ? {} : available[id];
templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function(li) {
li = $(li);
li = $(translator.unescape(li));
el.after(li);
el.remove();
});
@ -47,7 +53,7 @@ define('admin/general/navigation', function() {
data = {};
form.forEach(function(input) {
data[input.name] = input.value;
data[input.name] = translator.escape(input.value);
});
available.forEach(function(item) {

@ -4,13 +4,21 @@
var admin = {},
async = require('async'),
plugins = require('../plugins'),
db = require('../database');
db = require('../database'),
translator = require('../../public/src/translator');
admin.save = function(data, callback) {
var order = Object.keys(data),
items = data.map(function(item, idx) {
var data = {};
for (var i in item) {
if (item.hasOwnProperty(i)) {
item[i] = typeof item[i] === 'string' ? translator.escape(item[i]) : item[i];
}
}
data[idx] = item;
return JSON.stringify(data);
});

@ -21,7 +21,7 @@ var db = require('./database'),
schemaDate, thisSchemaDate,
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
latestSchema = Date.UTC(2015, 1, 25, 4);
latestSchema = Date.UTC(2015, 1, 25, 6);
Upgrade.check = function(callback) {
db.get('schemaDate', function(err, value) {
@ -943,7 +943,7 @@ Upgrade.upgrade = function(callback) {
}
},
function(next) {
thisSchemaDate = Date.UTC(2015, 1, 25, 4);
thisSchemaDate = Date.UTC(2015, 1, 25, 6);
if (schemaDate < thisSchemaDate) {
updatesMade = true;
winston.info('[2015/02/25] Upgrading menu items to dynamic navigation system');

Loading…
Cancel
Save