add db based translations
load translations from files and adds option to translate string layers (i.e. keywords)
This commit is contained in:
parent
0a4c507346
commit
f93ece1ab7
22 changed files with 682 additions and 1 deletions
|
|
@ -15,6 +15,10 @@ pandora.ui.filter = function(id) {
|
|||
align: 'left',
|
||||
id: 'name',
|
||||
format: function(value) {
|
||||
var layer = Ox.getObjectById(pandora.site.layers, filter.id);
|
||||
if (layer && layer.translate) {
|
||||
value = Ox._(value)
|
||||
}
|
||||
return filter.flag
|
||||
? $('<div>')
|
||||
.append(
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ pandora.ui.mainMenu = function() {
|
|||
{ id: 'events', title: Ox._('Manage Events...'), disabled: !pandora.hasCapability('canManagePlacesAndEvents') },
|
||||
{},
|
||||
{ id: 'users', title: Ox._('Manage Users...'), disabled: !pandora.hasCapability('canManageUsers') },
|
||||
{ id: 'translations', title: Ox._('Manage Translations...'), disabled: !pandora.hasCapability('canManageTranslations') },
|
||||
{ id: 'statistics', title: Ox._('Statistics...'), disabled: !pandora.hasCapability('canManageUsers') },
|
||||
{},
|
||||
{ id: 'changelog', title: Ox._('Changelog...'), disabled: !pandora.hasCapability('canManageUsers') }
|
||||
|
|
@ -652,6 +653,8 @@ pandora.ui.mainMenu = function() {
|
|||
pandora.$ui.usersDialog = pandora.ui.usersDialog().open();
|
||||
} else if (data.id == 'statistics') {
|
||||
pandora.$ui.statisticsDialog = pandora.ui.statisticsDialog().open();
|
||||
} else if (data.id == 'translations') {
|
||||
pandora.$ui.translationsDialog = pandora.ui.translationsDialog().open();
|
||||
} else if (data.id == 'changelog') {
|
||||
pandora.$ui.changelogDialog = pandora.ui.changelogDialog().open();
|
||||
} else if (data.id == 'clearcache') {
|
||||
|
|
|
|||
234
static/js/translationsDialog.js
Normal file
234
static/js/translationsDialog.js
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
'use strict';
|
||||
|
||||
pandora.ui.translationsDialog = function() {
|
||||
|
||||
var height = Math.round((window.innerHeight - 48) * 0.9),
|
||||
width = 576 + Ox.UI.SCROLLBAR_SIZE,
|
||||
|
||||
$languageSelect = Ox.Select({
|
||||
id: 'selectlanguage',
|
||||
items: [{
|
||||
id: '',
|
||||
title: Ox._('All')
|
||||
}].concat(pandora.site.languages.filter(function(lang) {
|
||||
return lang != 'en'
|
||||
}).map(function(lang) {
|
||||
return {
|
||||
id: lang,
|
||||
title: Ox.LOCALE_NAMES[lang]
|
||||
}
|
||||
})),
|
||||
value: pandora.site.language,
|
||||
width: 96
|
||||
|
||||
})
|
||||
.css({float: 'right', margin: '4px'})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
var value = $findInput.options('value')
|
||||
var query = prepareQuery(value, data.value)
|
||||
$list.options({
|
||||
query: query,
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
$findInput = Ox.Input({
|
||||
changeOnKeypress: true,
|
||||
clear: true,
|
||||
placeholder: Ox._('Find'),
|
||||
width: 192
|
||||
})
|
||||
.css({float: 'right', margin: '4px'})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
var lang = $languageSelect.options('value')
|
||||
var query = prepareQuery(data.value, lang)
|
||||
$list.options({
|
||||
query: query,
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
$list = Ox.TableList({
|
||||
columns: [
|
||||
{
|
||||
id: 'id',
|
||||
title: Ox._('ID'),
|
||||
visible: false,
|
||||
width: 0
|
||||
},
|
||||
{
|
||||
id: 'key',
|
||||
operator: '+',
|
||||
removable: false,
|
||||
title: Ox._('Key'),
|
||||
format: function(data) {
|
||||
return Ox.encodeHTMLEntities(data)
|
||||
},
|
||||
visible: true,
|
||||
width: 256
|
||||
},
|
||||
{
|
||||
editable: true,
|
||||
id: 'value',
|
||||
operator: '+',
|
||||
title: Ox._('Value'),
|
||||
format: function(data) {
|
||||
return Ox.encodeHTMLEntities(data)
|
||||
},
|
||||
tooltip: Ox._('Edit Translation'),
|
||||
visible: true,
|
||||
width: 256
|
||||
},
|
||||
{
|
||||
id: 'lang',
|
||||
align: 'right',
|
||||
operator: '-',
|
||||
title: Ox._('Language'),
|
||||
format: function(lang) {
|
||||
return Ox.LOCALE_NAMES[lang]
|
||||
},
|
||||
visible: true,
|
||||
width: 64
|
||||
},
|
||||
],
|
||||
columnsVisible: true,
|
||||
items: pandora.api.findTranslations,
|
||||
max: 1,
|
||||
scrollbarVisible: true,
|
||||
sort: [{key: 'key', operator: '+'}],
|
||||
unique: 'id'
|
||||
})
|
||||
.bindEvent({
|
||||
init: function(data) {
|
||||
$status.html(
|
||||
Ox.toTitleCase(Ox.formatCount(data.items, 'translation'))
|
||||
);
|
||||
},
|
||||
open: function(data) {
|
||||
$list.find('.OxItem.OxSelected > .OxCell.OxColumnSortname')
|
||||
.trigger('mousedown')
|
||||
.trigger('mouseup');
|
||||
},
|
||||
select: function(data) {
|
||||
},
|
||||
submit: function(data) {
|
||||
Ox.Request.clearCache('findTranslations');
|
||||
console.log(data)
|
||||
pandora.api.editTranslation({
|
||||
id: data.id,
|
||||
value: data.value
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: [
|
||||
{},
|
||||
Ox.Button({
|
||||
title: Ox._('Done'),
|
||||
width: 48
|
||||
}).bindEvent({
|
||||
click: function() {
|
||||
that.close();
|
||||
}
|
||||
})
|
||||
],
|
||||
closeButton: true,
|
||||
content: Ox.SplitPanel({
|
||||
elements: [
|
||||
{
|
||||
element: Ox.Bar({size: 24})
|
||||
.append($status)
|
||||
.append(
|
||||
$findInput
|
||||
)
|
||||
.append(
|
||||
$languageSelect
|
||||
),
|
||||
size: 24
|
||||
},
|
||||
{
|
||||
element: $list
|
||||
}
|
||||
],
|
||||
orientation: 'vertical'
|
||||
}),
|
||||
height: height,
|
||||
maximizeButton: true,
|
||||
minHeight: 256,
|
||||
minWidth: 512,
|
||||
padding: 0,
|
||||
title: Ox._('Manage Translations'),
|
||||
width: width
|
||||
})
|
||||
.bindEvent({
|
||||
resizeend: function(data) {
|
||||
var width = (data.width - 64 - Ox.UI.SCROLLBAR_SIZE) / 2;
|
||||
[
|
||||
{id: 'name', width: Math.ceil(width)},
|
||||
{id: 'sortname', width: Math.floor(width)}
|
||||
].forEach(function(column) {
|
||||
$list.resizeColumn(column.id, column.width);
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
$status = $('<div>')
|
||||
.css({
|
||||
position: 'absolute',
|
||||
top: '4px',
|
||||
left: '128px',
|
||||
right: '32px',
|
||||
bottom: '4px',
|
||||
paddingTop: '2px',
|
||||
fontSize: '9px',
|
||||
textAlign: 'center'
|
||||
})
|
||||
.appendTo(that.find('.OxButtonsbar'));
|
||||
|
||||
|
||||
function prepareQuery(value, lang) {
|
||||
var query;
|
||||
if (value) {
|
||||
query = {
|
||||
conditions: [
|
||||
{
|
||||
key: 'key',
|
||||
operator: '=',
|
||||
value: value
|
||||
},
|
||||
{
|
||||
key: 'value',
|
||||
operator: '=',
|
||||
value: value
|
||||
}
|
||||
],
|
||||
operator: '|'
|
||||
}
|
||||
} else {
|
||||
query = {
|
||||
conditions: []
|
||||
};
|
||||
}
|
||||
if (lang != '') {
|
||||
query = {
|
||||
conditions: [
|
||||
query,
|
||||
{
|
||||
key: 'lang',
|
||||
operator: '==',
|
||||
value: lang
|
||||
}
|
||||
],
|
||||
operator: '&'
|
||||
}
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
@ -3062,9 +3062,13 @@ pandora.setLocale = function(locale, callback) {
|
|||
url = [
|
||||
'/static/json/locale.pandora.' + locale + '.json',
|
||||
'/static/json/locale.' + pandora.site.site.id + '.' + locale + '.json',
|
||||
'/api/locale.' + locale + '.json'
|
||||
];
|
||||
} else {
|
||||
url = '/static/json/locale.' + locale + '.json';
|
||||
url = [
|
||||
'/static/json/locale.' + locale + '.json',
|
||||
'/api/locale.' + locale + '.json'
|
||||
];
|
||||
}
|
||||
}
|
||||
Ox.setLocale(locale, url, callback);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue