diff options
author | Derrell Lipman <derrell@samba.org> | 2007-02-06 03:23:52 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:44:34 -0500 |
commit | ef256c958066c19bb10cbe9745bdf96b6514762d (patch) | |
tree | dbe379cb3021c5af2d1b8f74528e4fff968fc712 /webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale | |
parent | a8d0f5df6266aeacdb20326094c0401618ab62e8 (diff) | |
download | samba-ef256c958066c19bb10cbe9745bdf96b6514762d.tar.gz samba-ef256c958066c19bb10cbe9745bdf96b6514762d.tar.bz2 samba-ef256c958066c19bb10cbe9745bdf96b6514762d.zip |
r21167: - Upgrade to latest released qooxdoo. This is step 1 of the upgrade process,
which involves adding the latest SDK. This new version has not 2, but 4
icon themes. In order to quiet Andrew B. who thinks that 9000+ files in a
gui api is too many (come on, disk space is free these days :-), I have
removed 3 of the 4 icon themes, leaving only the default, Nuvola. That
lowers the file count by 1/3. I'm sure Andrew still isn't happy, but I hope
he's a bit happier... Step 2 will make him happier yet.
(This used to be commit d161c1382c36238105b85d0499d5a1011f580f52)
Diffstat (limited to 'webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale')
6 files changed, 1003 insertions, 0 deletions
diff --git a/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Date.js b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Date.js new file mode 100644 index 0000000000..7383bd5a17 --- /dev/null +++ b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Date.js @@ -0,0 +1,429 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2007 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL: http://www.gnu.org/licenses/lgpl.html + EPL: http://www.eclipse.org/org/documents/epl-v10.php + See the LICENSE file in the project's top-level directory for details. + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + * Fabian Jakobs (fjakobs) + +************************************************************************ */ + +/** + * Create a new instance of qx.nls.Date + */ +qx.OO.defineClass("qx.locale.Date"); + + +/** + * Get AM marker for time definitions + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} translated AM marker. + */ +qx.Class.getAmMarker = function(locale) { + return new qx.locale.LocalizedString("cldr_am", [], locale); +}; + + +/** + * Get PM marker for time definitions + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} translated PM marker. + */ +qx.Class.getPmMarker = function(locale) { + return new qx.locale.LocalizedString("cldr_pm", [], locale); +}; + + +/** + * Return localized names of day names + * + * @param length {String} format of the day names. + * Possible values: "abbreviated", "narrow", "wide" + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString[]} array of localized day names starting with sunday. + */ +qx.Class.getDayNames = function(length, locale) { + if ( + length != "abbreviated" && + length != "narrow" && + length != "wide" + ) { + throw new Error('format must be one of "abbreviated", "narrow", "wide"'); + } + var days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; + var names = []; + for (var i=0; i<days.length; i++) { + var key = "cldr_day_" + length + "_" + days[i]; + names.push(new qx.locale.LocalizedString(key, [], locale)); + } + return names; +}; + + +/** + * Return localized name of a week day name + * + * @param length {String} format of the day name. + * Possible values: "abbreviated", "narrow", "wide" + * @param day {Integer} day number. 0=sunday, 1=monday, ... + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} localized day name + */ +qx.Class.getDayName = function(length, day, locale) { + if ( + length != "abbreviated" && + length != "narrow" && + length != "wide" + ) { + throw new Error('format must be one of "abbreviated", "narrow", "wide"'); + } + var days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; + var key = "cldr_day_" + length + "_" + days[day]; + return new qx.locale.LocalizedString(key, [], locale); +}; + + +/** + * Return localized names of month names + * + * @param length {String} format of the month names. + * Possible values: "abbreviated", "narrow", "wide" + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString[]} array of localized month names starting with january. + */ +qx.Class.getMonthNames = function(length, locale) { + if ( + length != "abbreviated" && + length != "narrow" && + length != "wide" + ) { + throw new Error('format must be one of "abbreviated", "narrow", "wide"'); + } + var names = []; + for (var i=0; i<12; i++) { + var key = "cldr_month_" + length + "_" + (i+1); + names.push(new qx.locale.LocalizedString(key, [], locale)); + } + return names; +}; + + +/** + * Return localized name of a month + * + * @param length {String} format of the month names. + * Possible values: "abbreviated", "narrow", "wide" + * @param month {Integer} index of the month. 0=january, 1=februrary, ... + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} localized month name + */ +qx.Class.getMonthName = function(length, month, locale) { + if ( + length != "abbreviated" && + length != "narrow" && + length != "wide" + ) { + throw new Error('format must be one of "abbreviated", "narrow", "wide"'); + } + var key = "cldr_month_" + length + "_" + (month+1); + return new qx.locale.LocalizedString(key, [], locale); +}; + + +/** + * Return localized date format string to be used with @{link qx.util.format.DateFormat}. + * + * @param size {String} format of the date format. + * Possible values: "short", "medium", "long", "full" + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} localized date format string + */ +qx.Class.getDateFormat = function(size, locale) { + if ( + size != "short" && + size != "medium" && + size != "long" && + size != "full" + ) { + throw new Error('format must be one of "short", "medium", "long", "full"'); + } + var key = "cldr_date_format_" + size; + return new qx.locale.LocalizedString(key, [], locale) +}; + + +/** + * Try to localize a date/time format string. + * + * If now localization is availible take the fallback format string + * + * @param canonical {String} format string containing only field information, and in a canonical order. + * Examples are "yyyyMMMM" for year + full month, or "MMMd" for abbreviated month + day. + * @param fallback {String} fallback format string if no localized version is found + * @param locale {String} optional locale to be used + * @return {String} best matching format string + */ +qx.Class.getDateTimeFormat = function(canonical, fallback, locale) { + var key = "cldr_date_time_format_" + canonical; + var localizedFormat = qx.locale.Manager.getInstance().translate(key, [], locale); + if (localizedFormat == key) { + localizedFormat = fallback; + } + return localizedFormat; +}; + + +/** + * Return localized time format string to be used with {@link qx.util.format.DateFormat}. + * + * @param size {String} format of the time pattern. + * Possible values: "short", "medium", "long", "full" + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} localized time format string + */ +qx.Class.getTimeFormat = function(size, locale) { + if ( + size != "short" && + size != "medium" && + size != "long" && + size != "full" + ) { + throw new Error('format must be one of "short", "medium", "long", "full"'); + } + switch (size) { + case "short": + case "medium": + return qx.locale.Date.getDateTimeFormat("HHmm", "HH:mm"); + + case "long": + return qx.locale.Date.getDateTimeFormat("HHmmss", "HH:mm:ss"); + + case "full": + return qx.locale.Date.getDateTimeFormat("HHmmsszz", "HH:mm:ss zz"); + + default: + throw new Error("This case should never happen."); + } +}; + + +/** + * Return the day the week starts with + * + * Reference: Common Locale Data Repository (cldr) supplementalData.xml + * + * @param locale {String} optional locale to be used + * @return {Integer} index of the first day of the week. 0=sunday, 1=monday, ... + */ +qx.Class.getWeekStart = function(locale) { + var weekStart = { + // default is monday + + "MV": 5, // friday + + "AE": 6, // saturday + "AF": 6, + "BH": 6, + "DJ": 6, + "DZ": 6, + "EG": 6, + "ER": 6, + "ET": 6, + "IQ": 6, + "IR": 6, + "JO": 6, + "KE": 6, + "KW": 6, + "LB": 6, + "LY": 6, + "MA": 6, + "OM": 6, + "QA": 6, + "SA": 6, + "SD": 6, + "SO": 6, + "TN": 6, + "YE": 6, + + "AS": 0, // sunday + "AU": 0, + "AZ": 0, + "BW": 0, + "CA": 0, + "CN": 0, + "FO": 0, + "GE": 0, + "GL": 0, + "GU": 0, + "HK": 0, + "IE": 0, + "IL": 0, + "IS": 0, + "JM": 0, + "JP": 0, + "KG": 0, + "KR": 0, + "LA": 0, + "MH": 0, + "MN": 0, + "MO": 0, + "MP": 0, + "MT": 0, + "NZ": 0, + "PH": 0, + "PK": 0, + "SG": 0, + "TH": 0, + "TT": 0, + "TW": 0, + "UM": 0, + "US": 0, + "UZ": 0, + "VI": 0, + "ZA": 0, + "ZW": 0, + + "ET": 0, + "MW": 0, + "NG": 0, + "TJ": 0 + }; + var territory = qx.locale.Date._getTerritory(locale); + // default is monday + return weekStart[territory] != null ? weekStart[territory] : 1; +}; + + +/** + * Return the day the weekend starts with + * + * Reference: Common Locale Data Repository (cldr) supplementalData.xml + * + * @param locale {String} optional locale to be used + * @return {Integer} index of the first day of the weekend. 0=sunday, 1=monday, ... + */ +qx.Class.getWeekendStart = function(locale) { + var weekendStart = { + // default is saturday + + "EG": 5, // friday + "IL": 5, + "SY": 5, + + "IN": 0, // sunday + + "AE": 4, // thursday + "BH": 4, + "DZ": 4, + "IQ": 4, + "JO": 4, + "KW": 4, + "LB": 4, + "LY": 4, + "MA": 4, + "OM": 4, + "QA": 4, + "SA": 4, + "SD": 4, + "TN": 4, + "YE": 4 + }; + var territory = qx.locale.Date._getTerritory(locale); + // default is saturday + return weekendStart[territory] != null ? weekendStart[territory] : 6; +}; + + +/** + * Return the day the weekend ends with + * + * Reference: Common Locale Data Repository (cldr) supplementalData.xml + * + * @param locale {String} optional locale to be used + * @return {Integer} index of the last day of the weekend. 0=sunday, 1=monday, ... + */ +qx.Class.getWeekendEnd = function(locale) { + var weekendEnd = { + // default is sunday + + "AE": 5, // friday + "BH": 5, + "DZ": 5, + "IQ": 5, + "JO": 5, + "KW": 5, + "LB": 5, + "LY": 5, + "MA": 5, + "OM": 5, + "QA": 5, + "SA": 5, + "SD": 5, + "TN": 5, + "YE": 5, + "AF": 5, + "IR": 5, + + "EG": 6, // saturday + "IL": 6, + "SY": 6 + } + var territory = qx.locale.Date._getTerritory(locale); + // default is sunday + return weekendEnd[territory] != null ? weekendEnd[territory] : 0; +}; + + +/** + * Returns whether a certain day of week belongs to the week end. + * + * @param day {Integer} index of the day. 0=sunday, 1=monday, ... + * @param locale {String} optional locale to be used + * @return {Boolean} whether the given day is a weekend day + */ +qx.Class.isWeekend = function(day, locale) { + var weekendStart = qx.locale.Date.getWeekendStart(locale); + var weekendEnd = qx.locale.Date.getWeekendEnd(locale); + if (weekendEnd > weekendStart) { + return ( + (day >= weekendStart) && + (day <= weekendEnd) + ); + } else { + return ( + (day >= weekendStart) || + (day <= weekendEnd) + ); + } +}; + + +/** + * Extract the territory part from a locale + * + * @param locale {String} the locale + * @return {String} territory + */ +qx.Class._getTerritory = function(locale) { + if (locale) { + var territory = locale.split("_")[1] || locale; + } else { + territory = + qx.locale.Manager.getInstance().getTerritory() || + qx.locale.Manager.getInstance().getLanguage(); + }; + return territory.toUpperCase(); +};
\ No newline at end of file diff --git a/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Key.js b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Key.js new file mode 100644 index 0000000000..beabac08f3 --- /dev/null +++ b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Key.js @@ -0,0 +1,116 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2007 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL: http://www.gnu.org/licenses/lgpl.html + EPL: http://www.eclipse.org/org/documents/epl-v10.php + See the LICENSE file in the project's top-level directory for details. + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + * Fabian Jakobs (fjakobs) + +************************************************************************ */ + +/** + * Create a new instance of qx.nls.Date + */ +qx.OO.defineClass("qx.locale.Key"); + + +/** + * Return localized name of a key identifier + * @{link qx.event.handler.KeyEventHandler} + * + * @param size {String} format of the key identifier. + * Possible values: "short", "full" + * @param keyIdentifier {String} key identifier to translate {@link qx.event.handler.KeyEventHandler} + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} localized key name + */ +qx.Class.getKeyName = function(size, keyIdentifier, locale) { + if ( + size != "short" && + size != "full" + ) { + throw new Error('format must be one of: "short", "full"'); + } + + var key = "key_" + size + "_" + keyIdentifier; + var localizedKey = new qx.locale.LocalizedString(key, [], locale); + if (localizedKey == key) { + return qx.locale.Key._keyNames[key] || keyIdentifier; + } else { + return localizedKey; + } +}; + + +( function() { + var keyNames = {}; + var Manager = qx.locale.Manager; + + // TRANSLATION: short representation of key names + keyNames[Manager.marktr("key_short_Backspace")] = "Backspace"; + keyNames[Manager.marktr("key_short_Tab")] = "Tab"; + keyNames[Manager.marktr("key_short_Space")] = "Space"; + keyNames[Manager.marktr("key_short_Enter")] = "Enter"; + keyNames[Manager.marktr("key_short_Shift")] = "Shift"; + keyNames[Manager.marktr("key_short_Control")] = "Ctrl"; + keyNames[Manager.marktr("key_short_Alt")] = "Alt"; + keyNames[Manager.marktr("key_short_CapsLock")] = "Caps"; + keyNames[Manager.marktr("key_short_Meta")] = "Meta"; + keyNames[Manager.marktr("key_short_Escape")] = "Esc"; + keyNames[Manager.marktr("key_short_Left")] = "Left"; + keyNames[Manager.marktr("key_short_Up")] = "Up"; + keyNames[Manager.marktr("key_short_Right")] = "Right"; + keyNames[Manager.marktr("key_short_Down")] = "Down"; + keyNames[Manager.marktr("key_short_PageUp")] = "PgUp"; + keyNames[Manager.marktr("key_short_PageDown")] = "PgDn"; + keyNames[Manager.marktr("key_short_End")] = "End"; + keyNames[Manager.marktr("key_short_Home")] = "Home"; + keyNames[Manager.marktr("key_short_Insert")] = "Ins"; + keyNames[Manager.marktr("key_short_Delete")] = "Del"; + keyNames[Manager.marktr("key_short_NumLock")] = "Num"; + keyNames[Manager.marktr("key_short_PrintScreen")] = "Print"; + keyNames[Manager.marktr("key_short_Scroll")] = "Scroll"; + keyNames[Manager.marktr("key_short_Pause")] = "Pause"; + keyNames[Manager.marktr("key_short_Win")] = "Win"; + keyNames[Manager.marktr("key_short_Apps")] = "Apps"; + + // TRANSLATION: full/long representation of key names + keyNames[Manager.marktr("key_full_Backspace")] = "Backspace"; + keyNames[Manager.marktr("key_full_Tab")] = "Tabulator"; + keyNames[Manager.marktr("key_full_Space")] = "Space"; + keyNames[Manager.marktr("key_full_Enter")] = "Enter"; + keyNames[Manager.marktr("key_full_Shift")] = "Shift"; + keyNames[Manager.marktr("key_full_Control")] = "Control"; + keyNames[Manager.marktr("key_full_Alt")] = "Alt"; + keyNames[Manager.marktr("key_full_CapsLock")] = "CapsLock"; + keyNames[Manager.marktr("key_full_Meta")] = "Meta"; + keyNames[Manager.marktr("key_full_Escape")] = "Escape"; + keyNames[Manager.marktr("key_full_Left")] = "Left"; + keyNames[Manager.marktr("key_full_Up")] = "Up"; + keyNames[Manager.marktr("key_full_Right")] = "Right"; + keyNames[Manager.marktr("key_full_Down")] = "Down"; + keyNames[Manager.marktr("key_full_PageUp")] = "PageUp"; + keyNames[Manager.marktr("key_full_PageDown")] = "PageDown"; + keyNames[Manager.marktr("key_full_End")] = "End"; + keyNames[Manager.marktr("key_full_Home")] = "Home"; + keyNames[Manager.marktr("key_full_Insert")] = "Insert"; + keyNames[Manager.marktr("key_full_Delete")] = "Delete"; + keyNames[Manager.marktr("key_full_NumLock")] = "NumLock"; + keyNames[Manager.marktr("key_full_PrintScreen")] = "PrintScreen"; + keyNames[Manager.marktr("key_full_Scroll")] = "Scroll"; + keyNames[Manager.marktr("key_full_Pause")] = "Pause"; + keyNames[Manager.marktr("key_full_Win")] = "Win"; + keyNames[Manager.marktr("key_full_Apps")] = "Apps"; + qx.Class._keyNames = keyNames; +}) ();
\ No newline at end of file diff --git a/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/LocalizedString.js b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/LocalizedString.js new file mode 100644 index 0000000000..a1c350e624 --- /dev/null +++ b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/LocalizedString.js @@ -0,0 +1,70 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2007 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL: http://www.gnu.org/licenses/lgpl.html + EPL: http://www.eclipse.org/org/documents/epl-v10.php + See the LICENSE file in the project's top-level directory for details. + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + * Fabian Jakobs (fjakobs) + +************************************************************************ */ + +/** + * Create a new instance of qx.locale.LocalizedString + * + * @see qx.lang.String.format + * + * @param messageId {String} message id (may contain format strings) + * @param args {Object[]} array of objects, which are inserted into the format string. + * @param locale {String} optional locale to be used for translation + */ +qx.OO.defineClass("qx.locale.LocalizedString", qx.core.Object, +function(messageId, args, locale) { + qx.core.Object.call(this); + + this.setId(messageId); + this._locale = locale; + + var storedArguments = []; + for (var i=0; i<args.length; i++) + { + var arg = args[i]; + if (arg instanceof qx.locale.LocalizedString) { + // defer conversion to string + storedArguments.push(arg); + } else { + // force conversion to string + storedArguments.push(arg + ""); + } + } + + this.setArgs(storedArguments); +}); + + +/** message id */ +qx.OO.addProperty({ name: "id"}); + +/** list of arguments to be applied to the format string */ +qx.OO.addProperty({ name: "args"}); + + +/** + * Return translation of the string using the current locale + * + * @return {String} translation using the current locale + */ +qx.Proto.toString = function () { + return qx.locale.Manager.getInstance().translate(this.getId(), this.getArgs(), this._locale); +}; + diff --git a/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Manager.js b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Manager.js new file mode 100644 index 0000000000..0b30e9456f --- /dev/null +++ b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Manager.js @@ -0,0 +1,261 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2007 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL: http://www.gnu.org/licenses/lgpl.html + EPL: http://www.eclipse.org/org/documents/epl-v10.php + See the LICENSE file in the project's top-level directory for details. + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + * Fabian Jakobs (fjakobs) + +************************************************************************ */ + + +/** + * Create a new instance of qx.locale.Manager + */ +qx.OO.defineClass("qx.locale.Manager", qx.manager.object.ObjectManager, +function() { + qx.manager.object.ObjectManager.call(this); + + this._translationCatalog = {}; + this.setLocale(qx.core.Client.getInstance().getLocale() || this._defaultLocale); +}); + + +/** current locale. locale is an language code like de, de_AT, en, en_GB, fr, ... */ +qx.OO.addProperty({ name: "locale"}); + +qx.Proto._defaultLocale = "C"; + + +/** + * Get the language code of the currnt locale + * + * This is the first part of a locale definition. The language for "de_DE" would be "de" + * + * @return {String} language code + */ +qx.Proto.getLanguage = function() { + return this._language; +}; + + +/** + * Get the territory code of the currnt locale + * + * This is the second part of a locale definition. The territory for "de_DE" would be "DE" + * + * @return {String} territory code + */ +qx.Proto.getTerritory = function() { + return this.getLocale().split("_")[1] || ""; +} + + +/** + * Return the available application locales + * + * This corresponds to the Makefile APPLICATION_LOCALES setting + * + * @return {String[]} array of available locales + */ +qx.Proto.getAvailableLocales = function() { + var locales = []; + for (var locale in this._translationCatalog) { + if (locale != this._defaultLocale) { + locales.push(locale); + } + } + return locales; +}; + + +/** + * Extract the language part from a locale. + * + * @param locale {String} locale to be used + * @return {String} language + */ +qx.Proto._extractLanguage = function(locale) { + var language; + var pos = locale.indexOf("_"); + if (pos == -1) { + language = locale; + } else { + language = locale.substring(0, pos); + } + return language; +}; + + +qx.Proto._modifyLocale = function(propValue, propOldValue, propData) { + this._locale = propValue; + + var pos = propValue.indexOf("_"); + this._language = this._extractLanguage(propValue); + + return true; +}; + + +/** + * Add a translation to the translation manager + * + * @param languageCode {String} language code of the translation like de, de_AT, en, en_GB, fr, ... + * @param translationMap {Map} mapping of message identifiers (english text) to the target language + */ +qx.Proto.addTranslation = function(languageCode, translationMap) { + + if (this._translationCatalog[languageCode]) + { + for (var key in translationMap) { + this._translationCatalog[languageCode][key] = translationMap[key]; + } + } + else + { + this._translationCatalog[languageCode] = translationMap; + } +}; + + +/** + * Translate a message + * @see qx.lang.String.format + * + * @param messageId {String} message id (may contain format strings) + * @param varargs {Object} variable number of argumes applied to the format string + * @return {qx.locale.LocalizedString} + */ +qx.Class.tr = function(messageId, varargs) +{ + var args = qx.lang.Array.fromArguments(arguments); + args.splice(0, 1); + + return new qx.locale.LocalizedString(messageId, args); +}; + + +/** + * Translate a plural message + * + * Depending on the third argument the plursl or the singular form is chosen. + * + * @see qx.lang.String.format + * + * @param singularMessageId {String} message id of the singular form (may contain format strings) + * @param pluralMessageId {String} message id of the plural form (may contain format strings) + * @param count {Integer} if greater than 1 the plural form otherwhise the singular form is returned. + * @param varargs {Object} variable number of argumes applied to the format string + * @return {qx.locale.LocalizedString} + */ +qx.Class.trn = function(singularMessageId, pluralMessageId, count, varargs) +{ + var args = qx.lang.Array.fromArguments(arguments); + args.splice(0, 3); + + if (count > 1) + { + return new qx.locale.LocalizedString(pluralMessageId, args); + } + else + { + return new qx.locale.LocalizedString(singularMessageId, args); + } +}; + + +/** + * Translate a message with translation hint + * + * Depending on the third argument the plursl or the singular form is chosen. + * + * @see qx.lang.String.format + * + * @param hint {String} hint for the translator of the message. Will be included in the .pot file. + * @param messageId {String} message id (may contain format strings) + * @param varargs {Object} variable number of argumes applied to the format string + * @return {qx.locale.LocalizedString} + */ +qx.Class.trc = function(hint, messageId, varargs) +{ + var args = qx.lang.Array.fromArguments(arguments); + args.splice(0, 2); + + return new qx.locale.LocalizedString(messageId, args); +} + + +/** + * Mark the message for translation but return the original message. + * + * @param messageId {String} the message ID + * @return {String} messageId + */ +qx.Class.marktr = function(messageId) { + return messageId; +}; + + +/** + * Translate a message using the current locale and apply format string to the arguments. + * + * @param messageId {String} message id (may contain format strings) + * @param args {Object[]} array of objects, which are inserted into the format string. + * @param locale {String} optional locale to be used for translation + * @return {String} translated message. + */ +qx.Proto.translate = function(messageId, args, locale) +{ + var txt; + + if (locale) { + var language = this._extractLanguage(locale); + } else { + locale = this._locale; + language = this._language; + } + + if (!txt && this._translationCatalog[locale]) { + txt = this._translationCatalog[locale][messageId]; + } + + if (!txt && this._translationCatalog[language]) { + txt = this._translationCatalog[language][messageId]; + } + + if (!txt && this._translationCatalog[this._defaultLocale]) { + txt = this._translationCatalog[this._defaultLocale][messageId]; + } + + if (!txt) { + txt = messageId; + } + + if (args.length > 0) { + txt = qx.lang.String.format(txt, args) + } + return txt; +}; + + +/* +--------------------------------------------------------------------------- + DEFER SINGLETON INSTANCE +--------------------------------------------------------------------------- +*/ + +/** + * Singleton Instance Getter + */ +qx.Class.getInstance = qx.lang.Function.returnInstance;
\ No newline at end of file diff --git a/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Number.js b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Number.js new file mode 100644 index 0000000000..09b3ed12fe --- /dev/null +++ b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/Number.js @@ -0,0 +1,58 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2007 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL: http://www.gnu.org/licenses/lgpl.html + EPL: http://www.eclipse.org/org/documents/epl-v10.php + See the LICENSE file in the project's top-level directory for details. + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + * Fabian Jakobs (fjakobs) + +************************************************************************ */ + +/** + * Create a new instance of qx.locale.Number + */ +qx.OO.defineClass("qx.locale.Number"); + + +/** + * Get deciaml separator for number formatting + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} deciaml separator. + */ +qx.Class.getDecimalSeparator = function(locale) { + return new qx.locale.LocalizedString("cldr_number_decimal_separator", [], locale); +}; + + +/** + * Get thousand grouping separator for number formatting + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} group separator. + */ +qx.Class.getGroupSeparator = function(locale) { + return new qx.locale.LocalizedString("cldr_number_group_separator", [], locale); +}; + + +/** + * Get percent format string + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} percent format string. + */ +qx.Class.getPercentFormat = function(locale) { + return new qx.locale.LocalizedString("cldr_number_percent_format", [], locale); +};
\ No newline at end of file diff --git a/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/String.js b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/String.js new file mode 100644 index 0000000000..0c3725bd04 --- /dev/null +++ b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/locale/String.js @@ -0,0 +1,69 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2007 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL: http://www.gnu.org/licenses/lgpl.html + EPL: http://www.eclipse.org/org/documents/epl-v10.php + See the LICENSE file in the project's top-level directory for details. + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + * Fabian Jakobs (fjakobs) + +************************************************************************ */ + +/** + * Create a new instance of qx.locale.String + */ +qx.OO.defineClass("qx.locale.String"); + + +/** + * Get quotation start sign + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} quotation start sign + */ +qx.Class.getQuotationStart = function(locale) { + return new qx.locale.LocalizedString("cldr_quotationStart", [], locale); +}; + + +/** + * Get quotation end sign + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} quotation end sign + */ +qx.Class.getQuotationEnd = function(locale) { + return new qx.locale.LocalizedString("cldr_quotationEnd", [], locale); +}; + + +/** + * Get quotation alternative start sign + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} alternative quotation start sign + */ +qx.Class.getQuotationStart = function(locale) { + return new qx.locale.LocalizedString("cldr_alternateQuotationStart", [], locale); +}; + + +/** + * Get quotation alternative end sign + * + * @param locale {String} optional locale to be used + * @return {qx.locale.LocalizedString} alternative quotation end sign + */ +qx.Class.getQuotationEnd = function(locale) { + return new qx.locale.LocalizedString("cldr_alternateQuotationEnd", [], locale); +};
\ No newline at end of file |