Skip to content
Code-Schnipsel Gruppen Projekte
Commit e98b647f erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'dev'

Übergeordnete 061edb09 a549e3bb
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
1 Merge Request!63Update 'next-2.x' with latest changes from 'main'
/**
* Locale translation class
*
* @module qui/classes/Locale
* @author www.pcg.de (Henning Leutz)
*
* @require qui/classes/DOM
*
* @event onError [ {String}, {this} ] - triggered if no_translation === false and no translation exist
*/
define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
{
define('qui/classes/Locale', ['qui/classes/DOM'], function (DOM) {
"use strict";
/**
......@@ -21,34 +17,33 @@ define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
*/
return new Class({
Extends : DOM,
Type : 'qui/classes/Locale',
Extends: DOM,
Type : 'qui/classes/Locale',
/**
* Current lang, use getCurrent() to get the lang
*/
current : 'en',
current: 'en',
/**
* Available langs
*/
langs : {},
langs: {},
/**
* No translation flag, makes no translation
* if true, get() returns the translation group
* usefull to show all translation groups
*/
no_translation : false,
no_translation: false,
/**
* init
*
* @param options - dom options
*/
initialize : function(options)
{
this.parent( options );
initialize: function (options) {
this.parent(options);
},
/**
......@@ -57,8 +52,7 @@ define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
* @method qui/classes/Locale#setCurrent
* @param {String} lang
*/
setCurrent : function(lang)
{
setCurrent: function (lang) {
this.current = lang;
},
......@@ -68,8 +62,7 @@ define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
* @method qui/classes/Locale#getCurrent
* @return {String}
*/
getCurrent : function()
{
getCurrent: function () {
return this.current;
},
......@@ -78,8 +71,7 @@ define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
*
* @returns {Array}
*/
getGroups : function()
{
getGroups: function () {
if (!(this.current in this.langs)) {
return [];
}
......@@ -100,32 +92,29 @@ define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
* @example Locale.set("en", "my/group", "my.translation.variable", "Some text is translated")
* @example Locale.set("de", "my/group", "my.translation.variable", "Ein Text der übersetzt wird")
*/
set : function(lang, group, values, value)
{
if ( !this.langs[ lang ] ) {
this.langs[ lang ] = {};
set: function (lang, group, values, value) {
if (!this.langs[lang]) {
this.langs[lang] = {};
}
if ( !this.langs[ lang ][ group ] ) {
this.langs[ lang ][ group ] = {};
if (!this.langs[lang][group]) {
this.langs[lang][group] = {};
}
if ( typeof value !== 'undefined' )
{
this.langs[ lang ][ group ][ values ] = value;
if (typeof value !== 'undefined') {
this.langs[lang][group][values] = value;
return this;
}
var _key = this.langs[ lang ][ group ];
var _key = this.langs[lang][group];
for ( var k in values )
{
if ( values.hasOwnProperty( k ) ) {
for (var k in values) {
if (values.hasOwnProperty(k)) {
_key[k] = values[k];
}
}
this.langs[ lang ][ group ] = _key;
this.langs[lang][group] = _key;
},
/**
......@@ -143,18 +132,19 @@ define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
* placeholder : 'my replace'
* })
*/
get : function(group, value, repl)
{
if ( typeof repl === 'undefined' ) {
return this.$get( group, value );
get: function (group, value, repl) {
if (typeof repl === 'undefined') {
return this.$get(group, value);
}
var result = this.$get( group, value );
var result = this.$get(group, value);
for ( group in repl )
{
if ( repl.hasOwnProperty( group ) ) {
result = result.replace('[' + group + ']', repl[group]);
for (group in repl) {
if (repl.hasOwnProperty(group)) {
result = result.replace(
new RegExp('\\[' + group + '\\]', "g"),
repl[group]
);
}
}
......@@ -170,32 +160,29 @@ define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
* @param {String} value - Translation value / name
* @return {String}
*/
$get : function(key, value)
{
if ( this.no_translation ) {
return '['+ key +'] '+ value;
$get: function (key, value) {
if (this.no_translation) {
return '[' + key + '] ' + value;
}
if ( this.langs[ this.current ] &&
this.langs[ this.current ][ key ] &&
this.langs[ this.current ][ key ][ value ] )
{
return this.langs[ this.current ][ key ][ value ];
if (this.langs[this.current] &&
this.langs[this.current][key] &&
this.langs[this.current][key][value]) {
return this.langs[this.current][key][value];
}
if ( this.langs[ this.current ] &&
this.langs[ this.current ][ key ] &&
typeof value === 'undefined' )
{
return this.langs[ this.current ][ key ];
if (this.langs[this.current] &&
this.langs[this.current][key] &&
typeof value === 'undefined') {
return this.langs[this.current][key];
}
this.fireEvent('error', [
'No translation found for ['+ key +'] '+ value,
this
'No translation found for [' + key + '] ' + value,
this
]);
return '['+ key +'] '+ value;
return '[' + key + '] ' + value;
},
/**
......@@ -206,19 +193,16 @@ define('qui/classes/Locale', ['qui/classes/DOM'], function(DOM)
*
* @returns {Boolean}
*/
exists : function(group, value)
{
exists: function (group, value) {
if (this.langs[this.current] &&
this.langs[this.current][group] &&
this.langs[this.current][group][value])
{
this.langs[this.current][group][value]) {
return true;
}
if (this.langs[this.current] &&
this.langs[this.current][group] &&
typeof value === 'undefined')
{
typeof value === 'undefined') {
return true;
}
......
......@@ -129,6 +129,11 @@ define('qui/controls/elements/FormList', [
elmResult = {};
for (c = 0, clen = elements.length; c < clen; c++) {
if (elements[c].type === 'checkbox') {
elmResult[elements[c].name] = !!elements[c].checked;
continue;
}
elmResult[elements[c].name] = elements[c].value;
}
......
......@@ -18,6 +18,8 @@
define('qui/controls/taskbar/Bar', [
'qui/Locale',
'qui/controls/Control',
'qui/controls/taskbar/Task',
'qui/controls/taskbar/Group',
......@@ -25,11 +27,16 @@ define('qui/controls/taskbar/Bar', [
'qui/controls/contextmenu/Menu',
'qui/controls/contextmenu/Item',
'qui/controls/taskbar/locale/de',
'qui/controls/taskbar/locale/en',
'css!qui/controls/taskbar/Bar.css'
], function (Control, TaskbarTask, TaskbarGroup, Button, Contextmenu, ContextmenuItem) {
], function (QUILocale, Control, TaskbarTask, TaskbarGroup, Button, Contextmenu, ContextmenuItem) {
"use strict";
var lg = 'qui/controls/taskbar/Bar';
/**
* @class qui/controls/taskbar/Bar
*
......@@ -688,7 +695,7 @@ define('qui/controls/taskbar/Bar', [
this.$ContextMenu.appendChild(
new ContextmenuItem({
name : 'close-task',
text : 'Task schließen',
text : QUILocale.get(lg, 'task.close.this'),
icon : 'icon-remove',
events: {
onClick: function (Item) {
......@@ -703,7 +710,7 @@ define('qui/controls/taskbar/Bar', [
).appendChild(
new ContextmenuItem({
name : 'close-other-task',
text : 'Andere Tasks schließen',
text : QUILocale.get(lg, 'task.close.other'),
icon : 'icon-remove-sign',
events: {
onClick: function (Item) {
......@@ -719,7 +726,7 @@ define('qui/controls/taskbar/Bar', [
).appendChild(
new ContextmenuItem({
name : 'close-all-task',
text : 'Alle Tasks schließen',
text : QUILocale.get(lg, 'task.close.all'),
icon : 'icon-remove-circle',
events: {
onClick: function () {
......
/**
* german translation utils
*
* @module qui/controls/taskbar/de
* @author www.pcsg.de (Jan Wennrich)
*/
define('qui/controls/taskbar/locale/de', ['qui/Locale'], function(Locale)
{
"use strict";
Locale.set("de", "qui/controls/taskbar/Bar", {
"task.close.this" : "Task schließen",
"task.close.other" : "Andere Tasks schließen",
"task.close.all" : "Alle Tasks schließen"
});
return Locale;
});
/**
* english translation utils
*
* @module qui/controls/taskbar/en
* @author www.pcsg.de (Jan Wennrich)
*/
define('qui/controls/taskbar/locale/en', ['qui/Locale'], function(Locale)
{
"use strict";
Locale.set("en", "qui/controls/taskbar/Bar", {
"task.close.this" : "Close task",
"task.close.other" : "Close other tasks",
"task.close.all" : "Close all tasks"
});
return Locale;
});
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren