mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
New languages - Portuguese (Std/Brazil) & Norwegian (Bokmål) (#1236)
* Update jquery.i18n to 1.07, add extended plurals support * Add additional languages - Portuguese, Portuguese (Brazil), Norwegian (Bokmål)
This commit is contained in:
607
assets/webconfig/js/lib/jquery.i18n/CLDRPluralRuleParser.js
Normal file
607
assets/webconfig/js/lib/jquery.i18n/CLDRPluralRuleParser.js
Normal file
@@ -0,0 +1,607 @@
|
||||
/**
|
||||
* cldrpluralparser.js
|
||||
* A parser engine for CLDR plural rules.
|
||||
*
|
||||
* Copyright 2012-2014 Santhosh Thottingal and other contributors
|
||||
* Released under the MIT license
|
||||
* http://opensource.org/licenses/MIT
|
||||
*
|
||||
* @source https://github.com/santhoshtr/CLDRPluralRuleParser
|
||||
* @author Santhosh Thottingal <santhosh.thottingal@gmail.com>
|
||||
* @author Timo Tijhof
|
||||
* @author Amir Aharoni
|
||||
*/
|
||||
|
||||
/**
|
||||
* Evaluates a plural rule in CLDR syntax for a number
|
||||
* @param {string} rule
|
||||
* @param {integer} number
|
||||
* @return {boolean} true if evaluation passed, false if evaluation failed.
|
||||
*/
|
||||
|
||||
// UMD returnExports https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
(function(root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like environments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.pluralRuleParser = factory();
|
||||
}
|
||||
}(this, function() {
|
||||
|
||||
function pluralRuleParser(rule, number) {
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Syntax: see http://unicode.org/reports/tr35/#Language_Plural_Rules
|
||||
-----------------------------------------------------------------
|
||||
condition = and_condition ('or' and_condition)*
|
||||
('@integer' samples)?
|
||||
('@decimal' samples)?
|
||||
and_condition = relation ('and' relation)*
|
||||
relation = is_relation | in_relation | within_relation
|
||||
is_relation = expr 'is' ('not')? value
|
||||
in_relation = expr (('not')? 'in' | '=' | '!=') range_list
|
||||
within_relation = expr ('not')? 'within' range_list
|
||||
expr = operand (('mod' | '%') value)?
|
||||
operand = 'n' | 'i' | 'f' | 't' | 'v' | 'w'
|
||||
range_list = (range | value) (',' range_list)*
|
||||
value = digit+
|
||||
digit = 0|1|2|3|4|5|6|7|8|9
|
||||
range = value'..'value
|
||||
samples = sampleRange (',' sampleRange)* (',' ('…'|'...'))?
|
||||
sampleRange = decimalValue '~' decimalValue
|
||||
decimalValue = value ('.' value)?
|
||||
*/
|
||||
|
||||
// We don't evaluate the samples section of the rule. Ignore it.
|
||||
rule = rule.split('@')[0].replace(/^\s*/, '').replace(/\s*$/, '');
|
||||
|
||||
if (!rule.length) {
|
||||
// Empty rule or 'other' rule.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Indicates the current position in the rule as we parse through it.
|
||||
// Shared among all parsing functions below.
|
||||
var pos = 0,
|
||||
operand,
|
||||
expression,
|
||||
relation,
|
||||
result,
|
||||
whitespace = makeRegexParser(/^\s+/),
|
||||
value = makeRegexParser(/^\d+/),
|
||||
_n_ = makeStringParser('n'),
|
||||
_i_ = makeStringParser('i'),
|
||||
_f_ = makeStringParser('f'),
|
||||
_t_ = makeStringParser('t'),
|
||||
_v_ = makeStringParser('v'),
|
||||
_w_ = makeStringParser('w'),
|
||||
_is_ = makeStringParser('is'),
|
||||
_isnot_ = makeStringParser('is not'),
|
||||
_isnot_sign_ = makeStringParser('!='),
|
||||
_equal_ = makeStringParser('='),
|
||||
_mod_ = makeStringParser('mod'),
|
||||
_percent_ = makeStringParser('%'),
|
||||
_not_ = makeStringParser('not'),
|
||||
_in_ = makeStringParser('in'),
|
||||
_within_ = makeStringParser('within'),
|
||||
_range_ = makeStringParser('..'),
|
||||
_comma_ = makeStringParser(','),
|
||||
_or_ = makeStringParser('or'),
|
||||
_and_ = makeStringParser('and');
|
||||
|
||||
function debug() {
|
||||
// console.log.apply(console, arguments);
|
||||
}
|
||||
|
||||
debug('pluralRuleParser', rule, number);
|
||||
|
||||
// Try parsers until one works, if none work return null
|
||||
function choice(parserSyntax) {
|
||||
return function() {
|
||||
var i, result;
|
||||
|
||||
for (i = 0; i < parserSyntax.length; i++) {
|
||||
result = parserSyntax[i]();
|
||||
|
||||
if (result !== null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
// Try several parserSyntax-es in a row.
|
||||
// All must succeed; otherwise, return null.
|
||||
// This is the only eager one.
|
||||
function sequence(parserSyntax) {
|
||||
var i, parserRes,
|
||||
originalPos = pos,
|
||||
result = [];
|
||||
|
||||
for (i = 0; i < parserSyntax.length; i++) {
|
||||
parserRes = parserSyntax[i]();
|
||||
|
||||
if (parserRes === null) {
|
||||
pos = originalPos;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
result.push(parserRes);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Run the same parser over and over until it fails.
|
||||
// Must succeed a minimum of n times; otherwise, return null.
|
||||
function nOrMore(n, p) {
|
||||
return function() {
|
||||
var originalPos = pos,
|
||||
result = [],
|
||||
parsed = p();
|
||||
|
||||
while (parsed !== null) {
|
||||
result.push(parsed);
|
||||
parsed = p();
|
||||
}
|
||||
|
||||
if (result.length < n) {
|
||||
pos = originalPos;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
// Helpers - just make parserSyntax out of simpler JS builtin types
|
||||
function makeStringParser(s) {
|
||||
var len = s.length;
|
||||
|
||||
return function() {
|
||||
var result = null;
|
||||
|
||||
if (rule.substr(pos, len) === s) {
|
||||
result = s;
|
||||
pos += len;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
function makeRegexParser(regex) {
|
||||
return function() {
|
||||
var matches = rule.substr(pos).match(regex);
|
||||
|
||||
if (matches === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
pos += matches[0].length;
|
||||
|
||||
return matches[0];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer digits of n.
|
||||
*/
|
||||
function i() {
|
||||
var result = _i_();
|
||||
|
||||
if (result === null) {
|
||||
debug(' -- failed i', parseInt(number, 10));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result = parseInt(number, 10);
|
||||
debug(' -- passed i ', result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Absolute value of the source number (integer and decimals).
|
||||
*/
|
||||
function n() {
|
||||
var result = _n_();
|
||||
|
||||
if (result === null) {
|
||||
debug(' -- failed n ', number);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result = parseFloat(number, 10);
|
||||
debug(' -- passed n ', result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visible fractional digits in n, with trailing zeros.
|
||||
*/
|
||||
function f() {
|
||||
var result = _f_();
|
||||
|
||||
if (result === null) {
|
||||
debug(' -- failed f ', number);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (number + '.').split('.')[1] || 0;
|
||||
debug(' -- passed f ', result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visible fractional digits in n, without trailing zeros.
|
||||
*/
|
||||
function t() {
|
||||
var result = _t_();
|
||||
|
||||
if (result === null) {
|
||||
debug(' -- failed t ', number);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (number + '.').split('.')[1].replace(/0$/, '') || 0;
|
||||
debug(' -- passed t ', result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of visible fraction digits in n, with trailing zeros.
|
||||
*/
|
||||
function v() {
|
||||
var result = _v_();
|
||||
|
||||
if (result === null) {
|
||||
debug(' -- failed v ', number);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (number + '.').split('.')[1].length || 0;
|
||||
debug(' -- passed v ', result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of visible fraction digits in n, without trailing zeros.
|
||||
*/
|
||||
function w() {
|
||||
var result = _w_();
|
||||
|
||||
if (result === null) {
|
||||
debug(' -- failed w ', number);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (number + '.').split('.')[1].replace(/0$/, '').length || 0;
|
||||
debug(' -- passed w ', result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// operand = 'n' | 'i' | 'f' | 't' | 'v' | 'w'
|
||||
operand = choice([n, i, f, t, v, w]);
|
||||
|
||||
// expr = operand (('mod' | '%') value)?
|
||||
expression = choice([mod, operand]);
|
||||
|
||||
function mod() {
|
||||
var result = sequence(
|
||||
[operand, whitespace, choice([_mod_, _percent_]), whitespace, value]
|
||||
);
|
||||
|
||||
if (result === null) {
|
||||
debug(' -- failed mod');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
debug(' -- passed ' + parseInt(result[0], 10) + ' ' + result[2] + ' ' + parseInt(result[4], 10));
|
||||
|
||||
return parseFloat(result[0]) % parseInt(result[4], 10);
|
||||
}
|
||||
|
||||
function not() {
|
||||
var result = sequence([whitespace, _not_]);
|
||||
|
||||
if (result === null) {
|
||||
debug(' -- failed not');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return result[1];
|
||||
}
|
||||
|
||||
// is_relation = expr 'is' ('not')? value
|
||||
function is() {
|
||||
var result = sequence([expression, whitespace, choice([_is_]), whitespace, value]);
|
||||
|
||||
if (result !== null) {
|
||||
debug(' -- passed is : ' + result[0] + ' == ' + parseInt(result[4], 10));
|
||||
|
||||
return result[0] === parseInt(result[4], 10);
|
||||
}
|
||||
|
||||
debug(' -- failed is');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// is_relation = expr 'is' ('not')? value
|
||||
function isnot() {
|
||||
var result = sequence(
|
||||
[expression, whitespace, choice([_isnot_, _isnot_sign_]), whitespace, value]
|
||||
);
|
||||
|
||||
if (result !== null) {
|
||||
debug(' -- passed isnot: ' + result[0] + ' != ' + parseInt(result[4], 10));
|
||||
|
||||
return result[0] !== parseInt(result[4], 10);
|
||||
}
|
||||
|
||||
debug(' -- failed isnot');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function not_in() {
|
||||
var i, range_list,
|
||||
result = sequence([expression, whitespace, _isnot_sign_, whitespace, rangeList]);
|
||||
|
||||
if (result !== null) {
|
||||
debug(' -- passed not_in: ' + result[0] + ' != ' + result[4]);
|
||||
range_list = result[4];
|
||||
|
||||
for (i = 0; i < range_list.length; i++) {
|
||||
if (parseInt(range_list[i], 10) === parseInt(result[0], 10)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
debug(' -- failed not_in');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// range_list = (range | value) (',' range_list)*
|
||||
function rangeList() {
|
||||
var result = sequence([choice([range, value]), nOrMore(0, rangeTail)]),
|
||||
resultList = [];
|
||||
|
||||
if (result !== null) {
|
||||
resultList = resultList.concat(result[0]);
|
||||
|
||||
if (result[1][0]) {
|
||||
resultList = resultList.concat(result[1][0]);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
debug(' -- failed rangeList');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function rangeTail() {
|
||||
// ',' range_list
|
||||
var result = sequence([_comma_, rangeList]);
|
||||
|
||||
if (result !== null) {
|
||||
return result[1];
|
||||
}
|
||||
|
||||
debug(' -- failed rangeTail');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// range = value'..'value
|
||||
function range() {
|
||||
var i, array, left, right,
|
||||
result = sequence([value, _range_, value]);
|
||||
|
||||
if (result !== null) {
|
||||
debug(' -- passed range');
|
||||
|
||||
array = [];
|
||||
left = parseInt(result[0], 10);
|
||||
right = parseInt(result[2], 10);
|
||||
|
||||
for (i = left; i <= right; i++) {
|
||||
array.push(i);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
debug(' -- failed range');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function _in() {
|
||||
var result, range_list, i;
|
||||
|
||||
// in_relation = expr ('not')? 'in' range_list
|
||||
result = sequence(
|
||||
[expression, nOrMore(0, not), whitespace, choice([_in_, _equal_]), whitespace, rangeList]
|
||||
);
|
||||
|
||||
if (result !== null) {
|
||||
debug(' -- passed _in:' + result);
|
||||
|
||||
range_list = result[5];
|
||||
|
||||
for (i = 0; i < range_list.length; i++) {
|
||||
if (parseInt(range_list[i], 10) === parseFloat(result[0])) {
|
||||
return (result[1][0] !== 'not');
|
||||
}
|
||||
}
|
||||
|
||||
return (result[1][0] === 'not');
|
||||
}
|
||||
|
||||
debug(' -- failed _in ');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The difference between "in" and "within" is that
|
||||
* "in" only includes integers in the specified range,
|
||||
* while "within" includes all values.
|
||||
*/
|
||||
function within() {
|
||||
var range_list, result;
|
||||
|
||||
// within_relation = expr ('not')? 'within' range_list
|
||||
result = sequence(
|
||||
[expression, nOrMore(0, not), whitespace, _within_, whitespace, rangeList]
|
||||
);
|
||||
|
||||
if (result !== null) {
|
||||
debug(' -- passed within');
|
||||
|
||||
range_list = result[5];
|
||||
|
||||
if ((result[0] >= parseInt(range_list[0], 10)) &&
|
||||
(result[0] < parseInt(range_list[range_list.length - 1], 10))) {
|
||||
|
||||
return (result[1][0] !== 'not');
|
||||
}
|
||||
|
||||
return (result[1][0] === 'not');
|
||||
}
|
||||
|
||||
debug(' -- failed within ');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// relation = is_relation | in_relation | within_relation
|
||||
relation = choice([is, not_in, isnot, _in, within]);
|
||||
|
||||
// and_condition = relation ('and' relation)*
|
||||
function and() {
|
||||
var i,
|
||||
result = sequence([relation, nOrMore(0, andTail)]);
|
||||
|
||||
if (result) {
|
||||
if (!result[0]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < result[1].length; i++) {
|
||||
if (!result[1][i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
debug(' -- failed and');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// ('and' relation)*
|
||||
function andTail() {
|
||||
var result = sequence([whitespace, _and_, whitespace, relation]);
|
||||
|
||||
if (result !== null) {
|
||||
debug(' -- passed andTail' + result);
|
||||
|
||||
return result[3];
|
||||
}
|
||||
|
||||
debug(' -- failed andTail');
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
// ('or' and_condition)*
|
||||
function orTail() {
|
||||
var result = sequence([whitespace, _or_, whitespace, and]);
|
||||
|
||||
if (result !== null) {
|
||||
debug(' -- passed orTail: ' + result[3]);
|
||||
|
||||
return result[3];
|
||||
}
|
||||
|
||||
debug(' -- failed orTail');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// condition = and_condition ('or' and_condition)*
|
||||
function condition() {
|
||||
var i,
|
||||
result = sequence([and, nOrMore(0, orTail)]);
|
||||
|
||||
if (result) {
|
||||
for (i = 0; i < result[1].length; i++) {
|
||||
if (result[1][i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
result = condition();
|
||||
|
||||
/**
|
||||
* For success, the pos must have gotten to the end of the rule
|
||||
* and returned a non-null.
|
||||
* n.b. This is part of language infrastructure,
|
||||
* so we do not throw an internationalizable message.
|
||||
*/
|
||||
if (result === null) {
|
||||
throw new Error('Parse error at position ' + pos.toString() + ' for rule: ' + rule);
|
||||
}
|
||||
|
||||
if (pos !== rule.length) {
|
||||
debug('Warning: Rule not parsed completely. Parser stopped at ' + rule.substr(0, pos) + ' for rule: ' + rule);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return pluralRuleParser;
|
||||
|
||||
}));
|
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* jQuery Internationalization library
|
||||
*
|
||||
* Copyright (C) 2011-2013 Santhosh Thottingal, Neil Kandalgaonkar
|
||||
@@ -17,7 +17,7 @@
|
||||
'use strict';
|
||||
|
||||
var MessageParserEmitter = function () {
|
||||
this.language = $.i18n.languages[String.locale] || $.i18n.languages['default'];
|
||||
this.language = $.i18n.languages[ String.locale ] || $.i18n.languages[ 'default' ];
|
||||
};
|
||||
|
||||
MessageParserEmitter.prototype = {
|
||||
@@ -38,36 +38,36 @@
|
||||
messageParserEmitter = this;
|
||||
|
||||
switch ( typeof node ) {
|
||||
case 'string':
|
||||
case 'number':
|
||||
ret = node;
|
||||
break;
|
||||
case 'object':
|
||||
case 'string':
|
||||
case 'number':
|
||||
ret = node;
|
||||
break;
|
||||
case 'object':
|
||||
// node is an array of nodes
|
||||
subnodes = $.map( node.slice( 1 ), function ( n ) {
|
||||
return messageParserEmitter.emit( n, replacements );
|
||||
} );
|
||||
subnodes = $.map( node.slice( 1 ), function ( n ) {
|
||||
return messageParserEmitter.emit( n, replacements );
|
||||
} );
|
||||
|
||||
operation = node[0].toLowerCase();
|
||||
operation = node[ 0 ].toLowerCase();
|
||||
|
||||
if ( typeof messageParserEmitter[operation] === 'function' ) {
|
||||
ret = messageParserEmitter[operation]( subnodes, replacements );
|
||||
} else {
|
||||
throw new Error( 'unknown operation "' + operation + '"' );
|
||||
}
|
||||
if ( typeof messageParserEmitter[ operation ] === 'function' ) {
|
||||
ret = messageParserEmitter[ operation ]( subnodes, replacements );
|
||||
} else {
|
||||
throw new Error( 'unknown operation "' + operation + '"' );
|
||||
}
|
||||
|
||||
break;
|
||||
case 'undefined':
|
||||
break;
|
||||
case 'undefined':
|
||||
// Parsing the empty string (as an entire expression, or as a
|
||||
// paramExpression in a template) results in undefined
|
||||
// Perhaps a more clever parser can detect this, and return the
|
||||
// empty string? Or is that useful information?
|
||||
// The logical thing is probably to return the empty string here
|
||||
// when we encounter undefined.
|
||||
ret = '';
|
||||
break;
|
||||
default:
|
||||
throw new Error( 'unexpected type in AST: ' + typeof node );
|
||||
ret = '';
|
||||
break;
|
||||
default:
|
||||
throw new Error( 'unexpected type in AST: ' + typeof node );
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -80,7 +80,7 @@
|
||||
* in our children and pass them upwards
|
||||
*
|
||||
* @param {Array} nodes Mixed, some single nodes, some arrays of nodes.
|
||||
* @return String
|
||||
* @return {string}
|
||||
*/
|
||||
concat: function ( nodes ) {
|
||||
var result = '';
|
||||
@@ -106,11 +106,11 @@
|
||||
* @return {string} replacement
|
||||
*/
|
||||
replace: function ( nodes, replacements ) {
|
||||
var index = parseInt( nodes[0], 10 );
|
||||
var index = parseInt( nodes[ 0 ], 10 );
|
||||
|
||||
if ( index < replacements.length ) {
|
||||
// replacement is not a string, don't touch!
|
||||
return replacements[index];
|
||||
return replacements[ index ];
|
||||
} else {
|
||||
// index not found, fallback to displaying variable
|
||||
return '$' + ( index + 1 );
|
||||
@@ -124,11 +124,11 @@
|
||||
* convertNumber.
|
||||
*
|
||||
* @param {Array} nodes List [ {String|Number}, {String}, {String} ... ]
|
||||
* @return {String} selected pluralized form according to current
|
||||
* @return {string} selected pluralized form according to current
|
||||
* language.
|
||||
*/
|
||||
plural: function ( nodes ) {
|
||||
var count = parseFloat( this.language.convertNumber( nodes[0], 10 ) ),
|
||||
var count = parseFloat( this.language.convertNumber( nodes[ 0 ], 10 ) ),
|
||||
forms = nodes.slice( 1 );
|
||||
|
||||
return forms.length ? this.language.convertPlural( count, forms ) : '';
|
||||
@@ -139,10 +139,10 @@
|
||||
* {{gender:gender|masculine|feminine|neutral}}.
|
||||
*
|
||||
* @param {Array} nodes List [ {String}, {String}, {String} , {String} ]
|
||||
* @return {String} selected gender form according to current language
|
||||
* @return {string} selected gender form according to current language
|
||||
*/
|
||||
gender: function ( nodes ) {
|
||||
var gender = nodes[0],
|
||||
var gender = nodes[ 0 ],
|
||||
forms = nodes.slice( 1 );
|
||||
|
||||
return this.language.gender( gender, forms );
|
||||
@@ -153,12 +153,12 @@
|
||||
* putting {{grammar:form|word}} in a message
|
||||
*
|
||||
* @param {Array} nodes List [{Grammar case eg: genitive}, {String word}]
|
||||
* @return {String} selected grammatical form according to current
|
||||
* @return {string} selected grammatical form according to current
|
||||
* language.
|
||||
*/
|
||||
grammar: function ( nodes ) {
|
||||
var form = nodes[0],
|
||||
word = nodes[1];
|
||||
var form = nodes[ 0 ],
|
||||
word = nodes[ 1 ];
|
||||
|
||||
return word && form && this.language.convertGrammar( word, form );
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* jQuery Internationalization library
|
||||
*
|
||||
* Copyright (C) 2012 Santhosh Thottingal
|
||||
@@ -11,7 +11,7 @@
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
* @licence MIT License
|
||||
*/
|
||||
( function ( $, undefined ) {
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n = $.i18n || {};
|
||||
@@ -45,7 +45,6 @@
|
||||
'crh-cyrl': [ 'ru' ],
|
||||
csb: [ 'pl' ],
|
||||
cv: [ 'ru' ],
|
||||
'de-DE': [ 'de' ],
|
||||
'de-at': [ 'de' ],
|
||||
'de-ch': [ 'de' ],
|
||||
'de-formal': [ 'de' ],
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* jQuery Internationalization library
|
||||
*
|
||||
* Copyright (C) 2012 Santhosh Thottingal
|
||||
@@ -16,7 +16,7 @@
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
var nav, I18N,
|
||||
var I18N,
|
||||
slice = Array.prototype.slice;
|
||||
/**
|
||||
* @constructor
|
||||
@@ -30,61 +30,52 @@
|
||||
this.locale = this.options.locale;
|
||||
this.messageStore = this.options.messageStore;
|
||||
this.languages = {};
|
||||
|
||||
this.init();
|
||||
};
|
||||
|
||||
I18N.prototype = {
|
||||
/**
|
||||
* Initialize by loading locales and setting up
|
||||
* String.prototype.toLocaleString and String.locale.
|
||||
* Localize a given messageKey to a locale.
|
||||
* @param {string} messageKey
|
||||
* @return {string} Localized message
|
||||
*/
|
||||
init: function () {
|
||||
var i18n = this;
|
||||
localize: function ( messageKey ) {
|
||||
var localeParts, localePartIndex, locale, fallbackIndex,
|
||||
tryingLocale, message;
|
||||
|
||||
// Set locale of String environment
|
||||
String.locale = i18n.locale;
|
||||
locale = this.locale;
|
||||
fallbackIndex = 0;
|
||||
|
||||
// Override String.localeString method
|
||||
String.prototype.toLocaleString = function () {
|
||||
var localeParts, localePartIndex, value, locale, fallbackIndex,
|
||||
tryingLocale, message;
|
||||
while ( locale ) {
|
||||
// Iterate through locales starting at most-specific until
|
||||
// localization is found. As in fi-Latn-FI, fi-Latn and fi.
|
||||
localeParts = locale.split( '-' );
|
||||
localePartIndex = localeParts.length;
|
||||
|
||||
value = this.valueOf();
|
||||
locale = i18n.locale;
|
||||
fallbackIndex = 0;
|
||||
do {
|
||||
tryingLocale = localeParts.slice( 0, localePartIndex ).join( '-' );
|
||||
message = this.messageStore.get( tryingLocale, messageKey );
|
||||
|
||||
while ( locale ) {
|
||||
// Iterate through locales starting at most-specific until
|
||||
// localization is found. As in fi-Latn-FI, fi-Latn and fi.
|
||||
localeParts = locale.split( '-' );
|
||||
localePartIndex = localeParts.length;
|
||||
|
||||
do {
|
||||
tryingLocale = localeParts.slice( 0, localePartIndex ).join( '-' );
|
||||
message = i18n.messageStore.get( tryingLocale, value );
|
||||
|
||||
if ( message ) {
|
||||
return message;
|
||||
}
|
||||
|
||||
localePartIndex--;
|
||||
} while ( localePartIndex );
|
||||
|
||||
if ( locale === 'en' ) {
|
||||
break;
|
||||
if ( message ) {
|
||||
return message;
|
||||
}
|
||||
|
||||
locale = ( $.i18n.fallbacks[i18n.locale] && $.i18n.fallbacks[i18n.locale][fallbackIndex] ) ||
|
||||
i18n.options.fallbackLocale;
|
||||
$.i18n.log( 'Trying fallback locale for ' + i18n.locale + ': ' + locale );
|
||||
localePartIndex--;
|
||||
} while ( localePartIndex );
|
||||
|
||||
fallbackIndex++;
|
||||
if ( locale === this.options.fallbackLocale ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// key not found
|
||||
return '';
|
||||
};
|
||||
locale = ( $.i18n.fallbacks[ this.locale ] &&
|
||||
$.i18n.fallbacks[ this.locale ][ fallbackIndex ] ) ||
|
||||
this.options.fallbackLocale;
|
||||
$.i18n.log( 'Trying fallback locale for ' + this.locale + ': ' + locale + ' (' + messageKey + ')' );
|
||||
|
||||
fallbackIndex++;
|
||||
}
|
||||
|
||||
// key not found
|
||||
return '';
|
||||
},
|
||||
|
||||
/*
|
||||
@@ -132,26 +123,28 @@
|
||||
* If the data argument is null/undefined/false,
|
||||
* all cached messages for the i18n instance will get reset.
|
||||
*
|
||||
* @param {String|Object} source
|
||||
* @param {String} locale Language tag
|
||||
* @returns {jQuery.Promise}
|
||||
* @param {string|Object} source
|
||||
* @param {string} locale Language tag
|
||||
* @return {jQuery.Promise}
|
||||
*/
|
||||
load: function ( source, locale ) {
|
||||
var fallbackLocales, locIndex, fallbackLocale, sourceMap = {};
|
||||
if ( !source && !locale ) {
|
||||
source = 'i18n';
|
||||
source = 'i18n/' + $.i18n().locale + '.json';
|
||||
locale = $.i18n().locale;
|
||||
}
|
||||
if ( typeof source === 'string' &&
|
||||
source.split( '.' ).pop() !== 'json'
|
||||
if ( typeof source === 'string' &&
|
||||
// source extension should be json, but can have query params after that.
|
||||
source.split( '?' )[ 0 ].split( '.' ).pop() !== 'json'
|
||||
) {
|
||||
// Load specified locale then check for fallbacks when directory is specified in load()
|
||||
sourceMap[locale] = source + '/' + locale + '.json';
|
||||
fallbackLocales = ( $.i18n.fallbacks[locale] || [] )
|
||||
// Load specified locale then check for fallbacks when directory is
|
||||
// specified in load()
|
||||
sourceMap[ locale ] = source + '/' + locale + '.json';
|
||||
fallbackLocales = ( $.i18n.fallbacks[ locale ] || [] )
|
||||
.concat( this.options.fallbackLocale );
|
||||
for ( locIndex in fallbackLocales ) {
|
||||
fallbackLocale = fallbackLocales[locIndex];
|
||||
sourceMap[fallbackLocale] = source + '/' + fallbackLocale + '.json';
|
||||
for ( locIndex = 0; locIndex < fallbackLocales.length; locIndex++ ) {
|
||||
fallbackLocale = fallbackLocales[ locIndex ];
|
||||
sourceMap[ fallbackLocale ] = source + '/' + fallbackLocale + '.json';
|
||||
}
|
||||
return this.load( sourceMap );
|
||||
} else {
|
||||
@@ -168,11 +161,11 @@
|
||||
* @return {string}
|
||||
*/
|
||||
parse: function ( key, parameters ) {
|
||||
var message = key.toLocaleString();
|
||||
var message = this.localize( key );
|
||||
// FIXME: This changes the state of the I18N object,
|
||||
// should probably not change the 'this.parser' but just
|
||||
// pass it to the parser.
|
||||
this.parser.language = $.i18n.languages[$.i18n().locale] || $.i18n.languages['default'];
|
||||
this.parser.language = $.i18n.languages[ $.i18n().locale ] || $.i18n.languages[ 'default' ];
|
||||
if ( message === '' ) {
|
||||
message = key;
|
||||
}
|
||||
@@ -202,7 +195,7 @@
|
||||
// NOTE: It should only change language for this one call.
|
||||
// Then cache instances of I18N somewhere.
|
||||
if ( options && options.locale && i18n && i18n.locale !== options.locale ) {
|
||||
String.locale = i18n.locale = options.locale;
|
||||
i18n.locale = options.locale;
|
||||
}
|
||||
|
||||
if ( !i18n ) {
|
||||
@@ -231,28 +224,38 @@
|
||||
i18n = new I18N();
|
||||
$.data( document, 'i18n', i18n );
|
||||
}
|
||||
String.locale = i18n.locale;
|
||||
|
||||
return this.each( function () {
|
||||
var $this = $( this ),
|
||||
messageKey = $this.data( 'i18n' );
|
||||
messageKey = $this.data( 'i18n' ),
|
||||
lBracket, rBracket, type, key;
|
||||
|
||||
if ( messageKey ) {
|
||||
$this.text( i18n.parse( messageKey ) );
|
||||
lBracket = messageKey.indexOf( '[' );
|
||||
rBracket = messageKey.indexOf( ']' );
|
||||
if ( lBracket !== -1 && rBracket !== -1 && lBracket < rBracket ) {
|
||||
type = messageKey.slice( lBracket + 1, rBracket );
|
||||
key = messageKey.slice( rBracket + 1 );
|
||||
if ( type === 'html' ) {
|
||||
$this.html( i18n.parse( key ) );
|
||||
} else {
|
||||
$this.attr( type, i18n.parse( key ) );
|
||||
}
|
||||
} else {
|
||||
$this.text( i18n.parse( messageKey ) );
|
||||
}
|
||||
} else {
|
||||
$this.find( '[data-i18n]' ).i18n();
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
String.locale = String.locale || $( 'html' ).attr( 'lang' );
|
||||
|
||||
if ( !String.locale ) {
|
||||
if ( typeof window.navigator !== 'undefined' ) {
|
||||
nav = window.navigator;
|
||||
String.locale = nav.language || nav.userLanguage || '';
|
||||
} else {
|
||||
String.locale = '';
|
||||
function getDefaultLocale() {
|
||||
var locale = $( 'html' ).attr( 'lang' );
|
||||
if ( !locale ) {
|
||||
locale = navigator.language || navigator.userLanguage || '';
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
$.i18n.languages = {};
|
||||
@@ -262,7 +265,7 @@
|
||||
parse: function ( message, parameters ) {
|
||||
return message.replace( /\$(\d+)/g, function ( str, match ) {
|
||||
var index = parseInt( match, 10 ) - 1;
|
||||
return parameters[index] !== undefined ? parameters[index] : '$' + match;
|
||||
return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match;
|
||||
} );
|
||||
},
|
||||
emitter: {}
|
||||
@@ -276,7 +279,7 @@
|
||||
};
|
||||
/* Static members */
|
||||
I18N.defaults = {
|
||||
locale: String.locale,
|
||||
locale: getDefaultLocale(),
|
||||
fallbackLocale: 'en',
|
||||
parser: $.i18n.parser,
|
||||
messageStore: $.i18n.messageStore
|
@@ -1,7 +1,8 @@
|
||||
/*global pluralRuleParser */
|
||||
/* global pluralRuleParser */
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
// jscs:disable
|
||||
var language = {
|
||||
// CLDR plural rules generated using
|
||||
// libs/CLDRPluralRuleParser/tools/PluralXML2JSON.html
|
||||
@@ -19,6 +20,16 @@
|
||||
few: 'n % 100 = 3..10',
|
||||
many: 'n % 100 = 11..99'
|
||||
},
|
||||
ars: {
|
||||
zero: 'n = 0',
|
||||
one: 'n = 1',
|
||||
two: 'n = 2',
|
||||
few: 'n % 100 = 3..10',
|
||||
many: 'n % 100 = 11..99'
|
||||
},
|
||||
as: {
|
||||
one: 'i = 0 or n = 1'
|
||||
},
|
||||
be: {
|
||||
one: 'n % 10 = 1 and n % 100 != 11',
|
||||
few: 'n % 10 = 2..4 and n % 100 != 12..14',
|
||||
@@ -55,6 +66,11 @@
|
||||
da: {
|
||||
one: 'n = 1 or t != 0 and i = 0,1'
|
||||
},
|
||||
dsb: {
|
||||
one: 'v = 0 and i % 100 = 1 or f % 100 = 1',
|
||||
two: 'v = 0 and i % 100 = 2 or f % 100 = 2',
|
||||
few: 'v = 0 and i % 100 = 3..4 or f % 100 = 3..4'
|
||||
},
|
||||
fa: {
|
||||
one: 'i = 0 or n = 1'
|
||||
},
|
||||
@@ -62,7 +78,7 @@
|
||||
one: 'i = 0,1'
|
||||
},
|
||||
fil: {
|
||||
one: 'i = 0..1 and v = 0'
|
||||
one: 'v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9'
|
||||
},
|
||||
fr: {
|
||||
one: 'i = 0,1'
|
||||
@@ -85,9 +101,10 @@
|
||||
one: 'n = 0..1'
|
||||
},
|
||||
gv: {
|
||||
one: 'n % 10 = 1',
|
||||
two: 'n % 10 = 2',
|
||||
few: 'n % 100 = 0,20,40,60'
|
||||
one: 'v = 0 and i % 10 = 1',
|
||||
two: 'v = 0 and i % 10 = 2',
|
||||
few: 'v = 0 and i % 100 = 0,20,40,60,80',
|
||||
many: 'v != 0'
|
||||
},
|
||||
he: {
|
||||
one: 'i = 1 and v = 0',
|
||||
@@ -101,6 +118,11 @@
|
||||
one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
|
||||
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
|
||||
},
|
||||
hsb: {
|
||||
one: 'v = 0 and i % 100 = 1 or f % 100 = 1',
|
||||
two: 'v = 0 and i % 100 = 2 or f % 100 = 2',
|
||||
few: 'v = 0 and i % 100 = 3..4 or f % 100 = 3..4'
|
||||
},
|
||||
hy: {
|
||||
one: 'i = 0,1'
|
||||
},
|
||||
@@ -175,20 +197,20 @@
|
||||
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
|
||||
many: 'v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14'
|
||||
},
|
||||
prg: {
|
||||
zero: 'n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19',
|
||||
one: 'n % 10 = 1 and n % 100 != 11 or v = 2 and f % 10 = 1 and f % 100 != 11 or v != 2 and f % 10 = 1'
|
||||
},
|
||||
pt: {
|
||||
one: 'i = 1 and v = 0 or i = 0 and t = 1'
|
||||
one: 'i = 0..1'
|
||||
},
|
||||
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||
pt_PT: {
|
||||
one: 'n = 1 and v = 0'
|
||||
},
|
||||
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||
ro: {
|
||||
one: 'i = 1 and v = 0',
|
||||
few: 'v != 0 or n = 0 or n != 1 and n % 100 = 1..19'
|
||||
},
|
||||
ru: {
|
||||
one: 'v = 0 and i % 10 = 1 and i % 100 != 11',
|
||||
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
|
||||
many: 'v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14'
|
||||
},
|
||||
se: {
|
||||
@@ -244,7 +266,7 @@
|
||||
one: 'n = 0..1'
|
||||
},
|
||||
tl: {
|
||||
one: 'i = 0..1 and v = 0'
|
||||
one: 'v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9'
|
||||
},
|
||||
tzm: {
|
||||
one: 'n = 0..1 or n = 11..99'
|
||||
@@ -261,21 +283,22 @@
|
||||
one: 'i = 0 or n = 1'
|
||||
}
|
||||
},
|
||||
// jscs:enable
|
||||
|
||||
/**
|
||||
* Plural form transformations, needed for some languages.
|
||||
*
|
||||
* @param count
|
||||
* integer Non-localized quantifier
|
||||
* @param forms
|
||||
* array List of plural forms
|
||||
* @return string Correct form for quantifier in this language
|
||||
* @param {integer} count
|
||||
* Non-localized quantifier
|
||||
* @param {Array} forms
|
||||
* List of plural forms
|
||||
* @return {string} Correct form for quantifier in this language
|
||||
*/
|
||||
convertPlural: function ( count, forms ) {
|
||||
var pluralRules,
|
||||
pluralFormIndex,
|
||||
index,
|
||||
explicitPluralPattern = new RegExp( '\\d+=', 'i' ),
|
||||
explicitPluralPattern = /\d+=/i,
|
||||
formCount,
|
||||
form;
|
||||
|
||||
@@ -285,13 +308,13 @@
|
||||
|
||||
// Handle for Explicit 0= & 1= values
|
||||
for ( index = 0; index < forms.length; index++ ) {
|
||||
form = forms[index];
|
||||
form = forms[ index ];
|
||||
if ( explicitPluralPattern.test( form ) ) {
|
||||
formCount = parseInt( form.substring( 0, form.indexOf( '=' ) ), 10 );
|
||||
formCount = parseInt( form.slice( 0, form.indexOf( '=' ) ), 10 );
|
||||
if ( formCount === count ) {
|
||||
return ( form.substr( form.indexOf( '=' ) + 1 ) );
|
||||
return ( form.slice( form.indexOf( '=' ) + 1 ) );
|
||||
}
|
||||
forms[index] = undefined;
|
||||
forms[ index ] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,25 +324,25 @@
|
||||
}
|
||||
} );
|
||||
|
||||
pluralRules = this.pluralRules[$.i18n().locale];
|
||||
pluralRules = this.pluralRules[ $.i18n().locale ];
|
||||
|
||||
if ( !pluralRules ) {
|
||||
// default fallback.
|
||||
return ( count === 1 ) ? forms[0] : forms[1];
|
||||
return ( count === 1 ) ? forms[ 0 ] : forms[ 1 ];
|
||||
}
|
||||
|
||||
pluralFormIndex = this.getPluralForm( count, pluralRules );
|
||||
pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 );
|
||||
|
||||
return forms[pluralFormIndex];
|
||||
return forms[ pluralFormIndex ];
|
||||
},
|
||||
|
||||
/**
|
||||
* For the number, get the plural for index
|
||||
*
|
||||
* @param number
|
||||
* @param pluralRules
|
||||
* @return plural form index
|
||||
* @param {integer} number
|
||||
* @param {Object} pluralRules
|
||||
* @return {integer} plural form index
|
||||
*/
|
||||
getPluralForm: function ( number, pluralRules ) {
|
||||
var i,
|
||||
@@ -327,8 +350,8 @@
|
||||
pluralFormIndex = 0;
|
||||
|
||||
for ( i = 0; i < pluralForms.length; i++ ) {
|
||||
if ( pluralRules[pluralForms[i]] ) {
|
||||
if ( pluralRuleParser( pluralRules[pluralForms[i]], number ) ) {
|
||||
if ( pluralRules[ pluralForms[ i ] ] ) {
|
||||
if ( pluralRuleParser( pluralRules[ pluralForms[ i ] ], number ) ) {
|
||||
return pluralFormIndex;
|
||||
}
|
||||
|
||||
@@ -344,6 +367,7 @@
|
||||
*
|
||||
* @param {number} num Value to be converted
|
||||
* @param {boolean} integer Convert the return value to an integer
|
||||
* @return {string} The number converted into a String.
|
||||
*/
|
||||
convertNumber: function ( num, integer ) {
|
||||
var tmp, item, i,
|
||||
@@ -360,28 +384,28 @@
|
||||
|
||||
// Check if the restore to Latin number flag is set:
|
||||
if ( integer ) {
|
||||
if ( parseFloat( num ) === num ) {
|
||||
if ( parseFloat( num, 10 ) === num ) {
|
||||
return num;
|
||||
}
|
||||
|
||||
tmp = [];
|
||||
|
||||
for ( item in transformTable ) {
|
||||
tmp[transformTable[item]] = item;
|
||||
tmp[ transformTable[ item ] ] = item;
|
||||
}
|
||||
|
||||
transformTable = tmp;
|
||||
}
|
||||
|
||||
for ( i = 0; i < numberString.length; i++ ) {
|
||||
if ( transformTable[numberString[i]] ) {
|
||||
convertedNumber += transformTable[numberString[i]];
|
||||
if ( transformTable[ numberString[ i ] ] ) {
|
||||
convertedNumber += transformTable[ numberString[ i ] ];
|
||||
} else {
|
||||
convertedNumber += numberString[i];
|
||||
convertedNumber += numberString[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
return integer ? parseFloat( convertedNumber ) : convertedNumber;
|
||||
return integer ? parseFloat( convertedNumber, 10 ) : convertedNumber;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -390,11 +414,12 @@
|
||||
* Override this method for languages that need special grammar rules
|
||||
* applied dynamically.
|
||||
*
|
||||
* @param word {String}
|
||||
* @param form {String}
|
||||
* @return {String}
|
||||
* @param {string} word
|
||||
* @param {string} form
|
||||
* @return {string}
|
||||
*/
|
||||
convertGrammar: function ( word, form ) { /*jshint unused: false */
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
convertGrammar: function ( word, form ) {
|
||||
return word;
|
||||
},
|
||||
|
||||
@@ -405,12 +430,12 @@
|
||||
*
|
||||
* These details may be overriden per language.
|
||||
*
|
||||
* @param gender
|
||||
* string male, female, or anything else for neutral.
|
||||
* @param forms
|
||||
* array List of gender forms
|
||||
* @param {string} gender
|
||||
* male, female, or anything else for neutral.
|
||||
* @param {Array} forms
|
||||
* List of gender forms
|
||||
*
|
||||
* @return string
|
||||
* @return {string}
|
||||
*/
|
||||
gender: function ( gender, forms ) {
|
||||
if ( !forms || forms.length === 0 ) {
|
||||
@@ -418,25 +443,26 @@
|
||||
}
|
||||
|
||||
while ( forms.length < 2 ) {
|
||||
forms.push( forms[forms.length - 1] );
|
||||
forms.push( forms[ forms.length - 1 ] );
|
||||
}
|
||||
|
||||
if ( gender === 'male' ) {
|
||||
return forms[0];
|
||||
return forms[ 0 ];
|
||||
}
|
||||
|
||||
if ( gender === 'female' ) {
|
||||
return forms[1];
|
||||
return forms[ 1 ];
|
||||
}
|
||||
|
||||
return ( forms.length === 3 ) ? forms[2] : forms[0];
|
||||
return ( forms.length === 3 ) ? forms[ 2 ] : forms[ 0 ];
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the digit transform table for the given language
|
||||
* See http://cldr.unicode.org/translation/numbering-systems
|
||||
* @param language
|
||||
* @returns {Array|boolean} List of digits in the passed language or false
|
||||
*
|
||||
* @param {string} language
|
||||
* @return {Array|boolean} List of digits in the passed language or false
|
||||
* representation, or boolean false if there is no information.
|
||||
*/
|
||||
digitTransformTable: function ( language ) {
|
||||
@@ -448,6 +474,7 @@
|
||||
lo: '໐໑໒໓໔໕໖໗໘໙',
|
||||
or: '୦୧୨୩୪୫୬୭୮୯',
|
||||
kh: '០១២៣៤៥៦៧៨៩',
|
||||
nqo: '߀߁߂߃߄߅߆߇߈߉', // Note that the digits go right to left
|
||||
pa: '੦੧੨੩੪੫੬੭੮੯',
|
||||
gu: '૦૧૨૩૪૫૬૭૮૯',
|
||||
hi: '०१२३४५६७८९',
|
||||
@@ -458,15 +485,15 @@
|
||||
bo: '༠༡༢༣༤༥༦༧༨༩' // FIXME use iso 639 codes
|
||||
};
|
||||
|
||||
if ( !tables[language] ) {
|
||||
if ( !tables[ language ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return tables[language].split( '' );
|
||||
return tables[ language ].split( '' );
|
||||
}
|
||||
};
|
||||
|
||||
$.extend( $.i18n.languages, {
|
||||
'default': language
|
||||
default: language
|
||||
} );
|
||||
}( jQuery ) );
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* jQuery Internationalization library - Message Store
|
||||
*
|
||||
* Copyright (C) 2012 Santhosh Thottingal
|
||||
@@ -12,7 +12,7 @@
|
||||
* @licence MIT License
|
||||
*/
|
||||
|
||||
( function ( $, window, undefined ) {
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
var MessageStore = function () {
|
||||
@@ -20,6 +20,20 @@
|
||||
this.sources = {};
|
||||
};
|
||||
|
||||
function jsonMessageLoader( url ) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
$.getJSON( url )
|
||||
.done( deferred.resolve )
|
||||
.fail( function ( jqxhr, settings, exception ) {
|
||||
$.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
|
||||
// Ignore 404 exception, because we are handling fallabacks explicitly
|
||||
deferred.resolve();
|
||||
} );
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
/**
|
||||
* See https://github.com/wikimedia/jquery.i18n/wiki/Specification#wiki-Message_File_Loading
|
||||
*/
|
||||
@@ -41,25 +55,22 @@
|
||||
* null/undefined/false,
|
||||
* all cached messages for the i18n instance will get reset.
|
||||
*
|
||||
* @param {String|Object} source
|
||||
* @param {String} locale Language tag
|
||||
* @param {string|Object} source
|
||||
* @param {string} locale Language tag
|
||||
* @return {jQuery.Promise}
|
||||
*/
|
||||
load: function ( source, locale ) {
|
||||
var key = null,
|
||||
deferred = null,
|
||||
deferreds = [],
|
||||
messageStore = this;
|
||||
|
||||
if ( typeof source === 'string' ) {
|
||||
// This is a URL to the messages file.
|
||||
$.i18n.log( 'Loading messages from: ' + source );
|
||||
deferred = jsonMessageLoader( source )
|
||||
.done( function ( localization ) {
|
||||
messageStore.set( locale, localization );
|
||||
return jsonMessageLoader( source )
|
||||
.then( function ( localization ) {
|
||||
return messageStore.load( localization, locale );
|
||||
} );
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
if ( locale ) {
|
||||
@@ -74,7 +85,7 @@
|
||||
locale = key;
|
||||
// No {locale} given, assume data is a group of languages,
|
||||
// call this function again for each language.
|
||||
deferreds.push( messageStore.load( source[key], locale ) );
|
||||
deferreds.push( messageStore.load( source[ key ], locale ) );
|
||||
}
|
||||
}
|
||||
return $.when.apply( $, deferreds );
|
||||
@@ -85,41 +96,28 @@
|
||||
/**
|
||||
* Set messages to the given locale.
|
||||
* If locale exists, add messages to the locale.
|
||||
* @param locale
|
||||
* @param messages
|
||||
*
|
||||
* @param {string} locale
|
||||
* @param {Object} messages
|
||||
*/
|
||||
set: function ( locale, messages ) {
|
||||
if ( !this.messages[locale] ) {
|
||||
this.messages[locale] = messages;
|
||||
if ( !this.messages[ locale ] ) {
|
||||
this.messages[ locale ] = messages;
|
||||
} else {
|
||||
this.messages[locale] = $.extend( this.messages[locale], messages );
|
||||
this.messages[ locale ] = $.extend( this.messages[ locale ], messages );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* @param messageKey
|
||||
* @returns {Boolean}
|
||||
* @param {string} locale
|
||||
* @param {string} messageKey
|
||||
* @return {boolean}
|
||||
*/
|
||||
get: function ( locale, messageKey ) {
|
||||
return this.messages[locale] && this.messages[locale][messageKey];
|
||||
return this.messages[ locale ] && this.messages[ locale ][ messageKey ];
|
||||
}
|
||||
};
|
||||
|
||||
function jsonMessageLoader( url ) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
$.getJSON( url )
|
||||
.done( deferred.resolve )
|
||||
.fail( function ( jqxhr, settings, exception ) {
|
||||
$.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
|
||||
// Ignore 404 exception, because we are handling fallabacks explicitly
|
||||
deferred.resolve();
|
||||
} );
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
$.extend( $.i18n.messageStore, new MessageStore() );
|
||||
}( jQuery, window ) );
|
||||
}( jQuery ) );
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* jQuery Internationalization library
|
||||
*
|
||||
* Copyright (C) 2011-2013 Santhosh Thottingal, Neil Kandalgaonkar
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
var MessageParser = function ( options ) {
|
||||
this.options = $.extend( {}, $.i18n.parser.defaults, options );
|
||||
this.language = $.i18n.languages[String.locale] || $.i18n.languages['default'];
|
||||
this.language = $.i18n.languages[ String.locale ] || $.i18n.languages[ 'default' ];
|
||||
this.emitter = $.i18n.parser.emitter;
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
return message.replace( /\$(\d+)/g, function ( str, match ) {
|
||||
var index = parseInt( match, 10 ) - 1;
|
||||
|
||||
return parameters[index] !== undefined ? parameters[index] : '$' + match;
|
||||
return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match;
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
return this.simpleParse( message, replacements );
|
||||
}
|
||||
|
||||
this.emitter.language = $.i18n.languages[$.i18n().locale] ||
|
||||
$.i18n.languages['default'];
|
||||
this.emitter.language = $.i18n.languages[ $.i18n().locale ] ||
|
||||
$.i18n.languages[ 'default' ];
|
||||
|
||||
return this.emitter.emit( this.ast( message ), replacements );
|
||||
},
|
||||
@@ -58,7 +58,7 @@
|
||||
var i, result;
|
||||
|
||||
for ( i = 0; i < parserSyntax.length; i++ ) {
|
||||
result = parserSyntax[i]();
|
||||
result = parserSyntax[ i ]();
|
||||
|
||||
if ( result !== null ) {
|
||||
return result;
|
||||
@@ -78,7 +78,7 @@
|
||||
result = [];
|
||||
|
||||
for ( i = 0; i < parserSyntax.length; i++ ) {
|
||||
res = parserSyntax[i]();
|
||||
res = parserSyntax[ i ]();
|
||||
|
||||
if ( res === null ) {
|
||||
pos = originalPos;
|
||||
@@ -123,7 +123,7 @@
|
||||
return function () {
|
||||
var result = null;
|
||||
|
||||
if ( message.substr( pos, len ) === s ) {
|
||||
if ( message.slice( pos, pos + len ) === s ) {
|
||||
result = s;
|
||||
pos += len;
|
||||
}
|
||||
@@ -134,15 +134,15 @@
|
||||
|
||||
function makeRegexParser( regex ) {
|
||||
return function () {
|
||||
var matches = message.substr( pos ).match( regex );
|
||||
var matches = message.slice( pos ).match( regex );
|
||||
|
||||
if ( matches === null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
pos += matches[0].length;
|
||||
pos += matches[ 0 ].length;
|
||||
|
||||
return matches[0];
|
||||
return matches[ 0 ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -152,9 +152,9 @@
|
||||
anyCharacter = makeRegexParser( /^./ );
|
||||
dollar = makeStringParser( '$' );
|
||||
digits = makeRegexParser( /^\d+/ );
|
||||
regularLiteral = makeRegexParser( /^[^{}\[\]$\\]/ );
|
||||
regularLiteralWithoutBar = makeRegexParser( /^[^{}\[\]$\\|]/ );
|
||||
regularLiteralWithoutSpace = makeRegexParser( /^[^{}\[\]$\s]/ );
|
||||
regularLiteral = makeRegexParser( /^[^{}[\]$\\]/ );
|
||||
regularLiteralWithoutBar = makeRegexParser( /^[^{}[\]$\\|]/ );
|
||||
regularLiteralWithoutSpace = makeRegexParser( /^[^{}[\]$\s]/ );
|
||||
|
||||
// There is a general pattern:
|
||||
// parse a thing;
|
||||
@@ -189,7 +189,7 @@
|
||||
function escapedLiteral() {
|
||||
var result = sequence( [ backslash, anyCharacter ] );
|
||||
|
||||
return result === null ? null : result[1];
|
||||
return result === null ? null : result[ 1 ];
|
||||
}
|
||||
|
||||
choice( [ escapedLiteral, regularLiteralWithoutSpace ] );
|
||||
@@ -203,13 +203,13 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
return [ 'REPLACE', parseInt( result[1], 10 ) - 1 ];
|
||||
return [ 'REPLACE', parseInt( result[ 1 ], 10 ) - 1 ];
|
||||
}
|
||||
|
||||
templateName = transform(
|
||||
// see $wgLegalTitleChars
|
||||
// not allowing : due to the need to catch "PLURAL:$1"
|
||||
makeRegexParser( /^[ !"$&'()*,.\/0-9;=?@A-Z\^_`a-z~\x80-\xFF+\-]+/ ),
|
||||
makeRegexParser( /^[ !"$&'()*,./0-9;=?@A-Z^_`a-z~\x80-\xFF+-]+/ ),
|
||||
|
||||
function ( result ) {
|
||||
return result.toString();
|
||||
@@ -224,23 +224,23 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
expr = result[1];
|
||||
expr = result[ 1 ];
|
||||
|
||||
// use a "CONCAT" operator if there are multiple nodes,
|
||||
// otherwise return the first node, raw.
|
||||
return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[0];
|
||||
return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[ 0 ];
|
||||
}
|
||||
|
||||
function templateWithReplacement() {
|
||||
var result = sequence( [ templateName, colon, replacement ] );
|
||||
|
||||
return result === null ? null : [ result[0], result[2] ];
|
||||
return result === null ? null : [ result[ 0 ], result[ 2 ] ];
|
||||
}
|
||||
|
||||
function templateWithOutReplacement() {
|
||||
var result = sequence( [ templateName, colon, paramExpression ] );
|
||||
|
||||
return result === null ? null : [ result[0], result[2] ];
|
||||
return result === null ? null : [ result[ 0 ], result[ 2 ] ];
|
||||
}
|
||||
|
||||
templateContents = choice( [
|
||||
@@ -254,7 +254,7 @@
|
||||
nOrMore( 0, templateParam )
|
||||
] );
|
||||
|
||||
return res === null ? null : res[0].concat( res[1] );
|
||||
return res === null ? null : res[ 0 ].concat( res[ 1 ] );
|
||||
},
|
||||
function () {
|
||||
var res = sequence( [ templateName, nOrMore( 0, templateParam ) ] );
|
||||
@@ -263,7 +263,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
return [ res[0] ].concat( res[1] );
|
||||
return [ res[ 0 ] ].concat( res[ 1 ] );
|
||||
}
|
||||
] );
|
||||
|
||||
@@ -273,7 +273,7 @@
|
||||
function template() {
|
||||
var result = sequence( [ openTemplate, templateContents, closeTemplate ] );
|
||||
|
||||
return result === null ? null : result[1];
|
||||
return result === null ? null : result[ 1 ];
|
||||
}
|
||||
|
||||
expression = choice( [ template, replacement, literal ] );
|
||||
@@ -294,7 +294,8 @@
|
||||
/*
|
||||
* For success, the pos must have gotten to the end of the input
|
||||
* and returned a non-null.
|
||||
* n.b. This is part of language infrastructure, so we do not throw an internationalizable message.
|
||||
* n.b. This is part of language infrastructure, so we do not throw an
|
||||
* internationalizable message.
|
||||
*/
|
||||
if ( result === null || pos !== message.length ) {
|
||||
throw new Error( 'Parse error at position ' + pos.toString() + ' in input: ' + message );
|
22
assets/webconfig/js/lib/jquery.i18n/languages/bs.js
Normal file
22
assets/webconfig/js/lib/jquery.i18n/languages/bs.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Bosnian (bosanski) language functions
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.bs = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
switch ( form ) {
|
||||
case 'instrumental': // instrumental
|
||||
word = 's ' + word;
|
||||
break;
|
||||
case 'lokativ': // locative
|
||||
word = 'o ' + word;
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
|
||||
}( jQuery ) );
|
22
assets/webconfig/js/lib/jquery.i18n/languages/dsb.js
Normal file
22
assets/webconfig/js/lib/jquery.i18n/languages/dsb.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Lower Sorbian (Dolnoserbski) language functions
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.dsb = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
switch ( form ) {
|
||||
case 'instrumental': // instrumental
|
||||
word = 'z ' + word;
|
||||
break;
|
||||
case 'lokatiw': // lokatiw
|
||||
word = 'wo ' + word;
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
|
||||
}( jQuery ) );
|
49
assets/webconfig/js/lib/jquery.i18n/languages/fi.js
Normal file
49
assets/webconfig/js/lib/jquery.i18n/languages/fi.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Finnish (Suomi) language functions
|
||||
*
|
||||
* @author Santhosh Thottingal
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.fi = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
// vowel harmony flag
|
||||
var aou = word.match( /[aou][^äöy]*$/i ),
|
||||
origWord = word;
|
||||
if ( word.match( /wiki$/i ) ) {
|
||||
aou = false;
|
||||
}
|
||||
|
||||
// append i after final consonant
|
||||
if ( word.match( /[bcdfghjklmnpqrstvwxz]$/i ) ) {
|
||||
word += 'i';
|
||||
}
|
||||
|
||||
switch ( form ) {
|
||||
case 'genitive':
|
||||
word += 'n';
|
||||
break;
|
||||
case 'elative':
|
||||
word += ( aou ? 'sta' : 'stä' );
|
||||
break;
|
||||
case 'partitive':
|
||||
word += ( aou ? 'a' : 'ä' );
|
||||
break;
|
||||
case 'illative':
|
||||
// Double the last letter and add 'n'
|
||||
word += word.slice( -1 ) + 'n';
|
||||
break;
|
||||
case 'inessive':
|
||||
word += ( aou ? 'ssa' : 'ssä' );
|
||||
break;
|
||||
default:
|
||||
word = origWord;
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
38
assets/webconfig/js/lib/jquery.i18n/languages/ga.js
Normal file
38
assets/webconfig/js/lib/jquery.i18n/languages/ga.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Irish (Gaeilge) language functions
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.ga = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
if ( form === 'ainmlae' ) {
|
||||
switch ( word ) {
|
||||
case 'an Domhnach':
|
||||
word = 'Dé Domhnaigh';
|
||||
break;
|
||||
case 'an Luan':
|
||||
word = 'Dé Luain';
|
||||
break;
|
||||
case 'an Mháirt':
|
||||
word = 'Dé Mháirt';
|
||||
break;
|
||||
case 'an Chéadaoin':
|
||||
word = 'Dé Chéadaoin';
|
||||
break;
|
||||
case 'an Déardaoin':
|
||||
word = 'Déardaoin';
|
||||
break;
|
||||
case 'an Aoine':
|
||||
word = 'Dé hAoine';
|
||||
break;
|
||||
case 'an Satharn':
|
||||
word = 'Dé Sathairn';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
31
assets/webconfig/js/lib/jquery.i18n/languages/he.js
Normal file
31
assets/webconfig/js/lib/jquery.i18n/languages/he.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Hebrew (עברית) language functions
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.he = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
switch ( form ) {
|
||||
case 'prefixed':
|
||||
case 'תחילית': // the same word in Hebrew
|
||||
// Duplicate prefixed "Waw", but only if it's not already double
|
||||
if ( word.slice( 0, 1 ) === 'ו' && word.slice( 0, 2 ) !== 'וו' ) {
|
||||
word = 'ו' + word;
|
||||
}
|
||||
|
||||
// Remove the "He" if prefixed
|
||||
if ( word.slice( 0, 1 ) === 'ה' ) {
|
||||
word = word.slice( 1 );
|
||||
}
|
||||
|
||||
// Add a hyphen (maqaf) before numbers and non-Hebrew letters
|
||||
if ( word.slice( 0, 1 ) < 'א' || word.slice( 0, 1 ) > 'ת' ) {
|
||||
word = '־' + word;
|
||||
}
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
21
assets/webconfig/js/lib/jquery.i18n/languages/hsb.js
Normal file
21
assets/webconfig/js/lib/jquery.i18n/languages/hsb.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Upper Sorbian (Hornjoserbsce) language functions
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.hsb = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
switch ( form ) {
|
||||
case 'instrumental': // instrumental
|
||||
word = 'z ' + word;
|
||||
break;
|
||||
case 'lokatiw': // lokatiw
|
||||
word = 'wo ' + word;
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
26
assets/webconfig/js/lib/jquery.i18n/languages/hu.js
Normal file
26
assets/webconfig/js/lib/jquery.i18n/languages/hu.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Hungarian language functions
|
||||
*
|
||||
* @author Santhosh Thottingal
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.hu = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
switch ( form ) {
|
||||
case 'rol':
|
||||
word += 'ról';
|
||||
break;
|
||||
case 'ba':
|
||||
word += 'ba';
|
||||
break;
|
||||
case 'k':
|
||||
word += 'k';
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
25
assets/webconfig/js/lib/jquery.i18n/languages/hy.js
Normal file
25
assets/webconfig/js/lib/jquery.i18n/languages/hy.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Armenian (Հայերեն) language functions
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.hy = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
if ( form === 'genitive' ) { // սեռական հոլով
|
||||
if ( word.slice( -1 ) === 'ա' ) {
|
||||
word = word.slice( 0, -1 ) + 'այի';
|
||||
} else if ( word.slice( -1 ) === 'ո' ) {
|
||||
word = word.slice( 0, -1 ) + 'ոյի';
|
||||
} else if ( word.slice( -4 ) === 'գիրք' ) {
|
||||
word = word.slice( 0, -4 ) + 'գրքի';
|
||||
} else {
|
||||
word = word + 'ի';
|
||||
}
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
54
assets/webconfig/js/lib/jquery.i18n/languages/la.js
Normal file
54
assets/webconfig/js/lib/jquery.i18n/languages/la.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Latin (lingua Latina) language functions
|
||||
*
|
||||
* @author Santhosh Thottingal
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.la = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
switch ( form ) {
|
||||
case 'genitive':
|
||||
// only a few declensions, and even for those mostly the singular only
|
||||
word = word.replace( /u[ms]$/i, 'i' ); // 2nd declension singular
|
||||
word = word.replace( /ommunia$/i, 'ommunium' ); // 3rd declension neuter plural (partly)
|
||||
word = word.replace( /a$/i, 'ae' ); // 1st declension singular
|
||||
word = word.replace( /libri$/i, 'librorum' ); // 2nd declension plural (partly)
|
||||
word = word.replace( /nuntii$/i, 'nuntiorum' ); // 2nd declension plural (partly)
|
||||
word = word.replace( /tio$/i, 'tionis' ); // 3rd declension singular (partly)
|
||||
word = word.replace( /ns$/i, 'ntis' );
|
||||
word = word.replace( /as$/i, 'atis' );
|
||||
word = word.replace( /es$/i, 'ei' ); // 5th declension singular
|
||||
break;
|
||||
case 'accusative':
|
||||
// only a few declensions, and even for those mostly the singular only
|
||||
word = word.replace( /u[ms]$/i, 'um' ); // 2nd declension singular
|
||||
word = word.replace( /ommunia$/i, 'am' ); // 3rd declension neuter plural (partly)
|
||||
word = word.replace( /a$/i, 'ommunia' ); // 1st declension singular
|
||||
word = word.replace( /libri$/i, 'libros' ); // 2nd declension plural (partly)
|
||||
word = word.replace( /nuntii$/i, 'nuntios' );// 2nd declension plural (partly)
|
||||
word = word.replace( /tio$/i, 'tionem' ); // 3rd declension singular (partly)
|
||||
word = word.replace( /ns$/i, 'ntem' );
|
||||
word = word.replace( /as$/i, 'atem' );
|
||||
word = word.replace( /es$/i, 'em' ); // 5th declension singular
|
||||
break;
|
||||
case 'ablative':
|
||||
// only a few declensions, and even for those mostly the singular only
|
||||
word = word.replace( /u[ms]$/i, 'o' ); // 2nd declension singular
|
||||
word = word.replace( /ommunia$/i, 'ommunibus' ); // 3rd declension neuter plural (partly)
|
||||
word = word.replace( /a$/i, 'a' ); // 1st declension singular
|
||||
word = word.replace( /libri$/i, 'libris' ); // 2nd declension plural (partly)
|
||||
word = word.replace( /nuntii$/i, 'nuntiis' ); // 2nd declension plural (partly)
|
||||
word = word.replace( /tio$/i, 'tione' ); // 3rd declension singular (partly)
|
||||
word = word.replace( /ns$/i, 'nte' );
|
||||
word = word.replace( /as$/i, 'ate' );
|
||||
word = word.replace( /es$/i, 'e' ); // 5th declension singular
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
98
assets/webconfig/js/lib/jquery.i18n/languages/ml.js
Normal file
98
assets/webconfig/js/lib/jquery.i18n/languages/ml.js
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* Malayalam language functions
|
||||
*
|
||||
* @author Santhosh Thottingal
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.ml = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
form = form.toLowerCase();
|
||||
switch ( form ) {
|
||||
case 'ഉദ്ദേശിക':
|
||||
case 'dative':
|
||||
if ( word.slice( -1 ) === 'ു' ||
|
||||
word.slice( -1 ) === 'ൂ' ||
|
||||
word.slice( -1 ) === 'ൗ' ||
|
||||
word.slice( -1 ) === 'ൌ'
|
||||
) {
|
||||
word += 'വിന്';
|
||||
} else if ( word.slice( -1 ) === 'ം' ) {
|
||||
word = word.slice( 0, -1 ) + 'ത്തിന്';
|
||||
} else if ( word.slice( -1 ) === 'ൻ' ) {
|
||||
// Atomic chillu n. അവൻ -> അവന്
|
||||
word = word.slice( 0, -1 ) + 'ന്';
|
||||
} else if ( word.slice( -3 ) === 'ന്\u200d' ) {
|
||||
// chillu n. അവൻ -> അവന്
|
||||
word = word.slice( 0, -1 );
|
||||
} else if ( word.slice( -1 ) === 'ൾ' || word.slice( -3 ) === 'ള്\u200d' ) {
|
||||
word += 'ക്ക്';
|
||||
} else if ( word.slice( -1 ) === 'ർ' || word.slice( -3 ) === 'ര്\u200d' ) {
|
||||
word += 'ക്ക്';
|
||||
} else if ( word.slice( -1 ) === 'ൽ' ) {
|
||||
// Atomic chillu ൽ , ഫയൽ -> ഫയലിന്
|
||||
word = word.slice( 0, -1 ) + 'ലിന്';
|
||||
} else if ( word.slice( -3 ) === 'ല്\u200d' ) {
|
||||
// chillu ല്\u200d , ഫയല്\u200d -> ഫയലിന്
|
||||
word = word.slice( 0, -2 ) + 'ിന്';
|
||||
} else if ( word.slice( -2 ) === 'ു്' ) {
|
||||
word = word.slice( 0, -2 ) + 'ിന്';
|
||||
} else if ( word.slice( -1 ) === '്' ) {
|
||||
word = word.slice( 0, -1 ) + 'ിന്';
|
||||
} else {
|
||||
// കാവ്യ -> കാവ്യയ്ക്ക്, ഹരി -> ഹരിയ്ക്ക്, മല -> മലയ്ക്ക്
|
||||
word += 'യ്ക്ക്';
|
||||
}
|
||||
|
||||
break;
|
||||
case 'സംബന്ധിക':
|
||||
case 'genitive':
|
||||
if ( word.slice( -1 ) === 'ം' ) {
|
||||
word = word.slice( 0, -1 ) + 'ത്തിന്റെ';
|
||||
} else if ( word.slice( -2 ) === 'ു്' ) {
|
||||
word = word.slice( 0, -2 ) + 'ിന്റെ';
|
||||
} else if ( word.slice( -1 ) === '്' ) {
|
||||
word = word.slice( 0, -1 ) + 'ിന്റെ';
|
||||
} else if ( word.slice( -1 ) === 'ു' ||
|
||||
word.slice( -1 ) === 'ൂ' ||
|
||||
word.slice( -1 ) === 'ൗ' ||
|
||||
word.slice( -1 ) === 'ൌ'
|
||||
) {
|
||||
word += 'വിന്റെ';
|
||||
} else if ( word.slice( -1 ) === 'ൻ' ) {
|
||||
// Atomic chillu n. അവൻ -> അവന്റെ
|
||||
word = word.slice( 0, -1 ) + 'ന്റെ';
|
||||
} else if ( word.slice( -3 ) === 'ന്\u200d' ) {
|
||||
// chillu n. അവൻ -> അവന്റെ
|
||||
word = word.slice( 0, -1 ) + 'റെ';
|
||||
} else if ( word.slice( -3 ) === 'ള്\u200d' ) {
|
||||
// chillu n. അവൾ -> അവളുടെ
|
||||
word = word.slice( 0, -2 ) + 'ുടെ';
|
||||
} else if ( word.slice( -1 ) === 'ൾ' ) {
|
||||
// Atomic chillu n. അവള്\u200d -> അവളുടെ
|
||||
word = word.slice( 0, -1 ) + 'ളുടെ';
|
||||
} else if ( word.slice( -1 ) === 'ൽ' ) {
|
||||
// Atomic l. മുയല്\u200d -> മുയലിന്റെ
|
||||
word = word.slice( 0, -1 ) + 'ലിന്റെ';
|
||||
} else if ( word.slice( -3 ) === 'ല്\u200d' ) {
|
||||
// chillu l. മുയല്\u200d -> അവളുടെ
|
||||
word = word.slice( 0, -2 ) + 'ിന്റെ';
|
||||
} else if ( word.slice( -3 ) === 'ര്\u200d' ) {
|
||||
// chillu r. അവര്\u200d -> അവരുടെ
|
||||
word = word.slice( 0, -2 ) + 'ുടെ';
|
||||
} else if ( word.slice( -1 ) === 'ർ' ) {
|
||||
// Atomic chillu r. അവർ -> അവരുടെ
|
||||
word = word.slice( 0, -1 ) + 'രുടെ';
|
||||
} else {
|
||||
word += 'യുടെ';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
75
assets/webconfig/js/lib/jquery.i18n/languages/os.js
Normal file
75
assets/webconfig/js/lib/jquery.i18n/languages/os.js
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Ossetian (Ирон) language functions
|
||||
*
|
||||
* @author Santhosh Thottingal
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.os = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
var endAllative, jot, hyphen, ending;
|
||||
|
||||
// Ending for allative case
|
||||
endAllative = 'мæ';
|
||||
// Variable for 'j' beetwen vowels
|
||||
jot = '';
|
||||
// Variable for "-" for not Ossetic words
|
||||
hyphen = '';
|
||||
// Variable for ending
|
||||
ending = '';
|
||||
|
||||
if ( word.match( /тæ$/i ) ) {
|
||||
// Checking if the $word is in plural form
|
||||
word = word.slice( 0, -1 );
|
||||
endAllative = 'æм';
|
||||
} else if ( word.match( /[аæеёиоыэюя]$/i ) ) {
|
||||
// Works if word is in singular form.
|
||||
// Checking if word ends on one of the vowels: е, ё, и, о, ы, э, ю,
|
||||
// я.
|
||||
jot = 'й';
|
||||
} else if ( word.match( /у$/i ) ) {
|
||||
// Checking if word ends on 'у'. 'У' can be either consonant 'W' or
|
||||
// vowel 'U' in cyrillic Ossetic.
|
||||
// Examples: {{grammar:genitive|аунеу}} = аунеуы,
|
||||
// {{grammar:genitive|лæппу}} = лæппуйы.
|
||||
if ( !word.slice( -2, -1 ).match( /[аæеёиоыэюя]$/i ) ) {
|
||||
jot = 'й';
|
||||
}
|
||||
} else if ( !word.match( /[бвгджзйклмнопрстфхцчшщьъ]$/i ) ) {
|
||||
hyphen = '-';
|
||||
}
|
||||
|
||||
switch ( form ) {
|
||||
case 'genitive':
|
||||
ending = hyphen + jot + 'ы';
|
||||
break;
|
||||
case 'dative':
|
||||
ending = hyphen + jot + 'æн';
|
||||
break;
|
||||
case 'allative':
|
||||
ending = hyphen + endAllative;
|
||||
break;
|
||||
case 'ablative':
|
||||
if ( jot === 'й' ) {
|
||||
ending = hyphen + jot + 'æ';
|
||||
} else {
|
||||
ending = hyphen + jot + 'æй';
|
||||
}
|
||||
break;
|
||||
case 'superessive':
|
||||
ending = hyphen + jot + 'ыл';
|
||||
break;
|
||||
case 'equative':
|
||||
ending = hyphen + jot + 'ау';
|
||||
break;
|
||||
case 'comitative':
|
||||
ending = hyphen + 'имæ';
|
||||
break;
|
||||
}
|
||||
|
||||
return word + ending;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
29
assets/webconfig/js/lib/jquery.i18n/languages/ru.js
Normal file
29
assets/webconfig/js/lib/jquery.i18n/languages/ru.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Russian (Русский) language functions
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.ru = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
if ( form === 'genitive' ) { // родительный падеж
|
||||
if ( word.slice( -1 ) === 'ь' ) {
|
||||
word = word.slice( 0, -1 ) + 'я';
|
||||
} else if ( word.slice( -2 ) === 'ия' ) {
|
||||
word = word.slice( 0, -2 ) + 'ии';
|
||||
} else if ( word.slice( -2 ) === 'ка' ) {
|
||||
word = word.slice( 0, -2 ) + 'ки';
|
||||
} else if ( word.slice( -2 ) === 'ти' ) {
|
||||
word = word.slice( 0, -2 ) + 'тей';
|
||||
} else if ( word.slice( -2 ) === 'ды' ) {
|
||||
word = word.slice( 0, -2 ) + 'дов';
|
||||
} else if ( word.slice( -3 ) === 'ник' ) {
|
||||
word = word.slice( 0, -3 ) + 'ника';
|
||||
}
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
26
assets/webconfig/js/lib/jquery.i18n/languages/sl.js
Normal file
26
assets/webconfig/js/lib/jquery.i18n/languages/sl.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Slovenian (Slovenščina) language functions
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.sl = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
switch ( form ) {
|
||||
// locative
|
||||
case 'mestnik':
|
||||
word = 'o ' + word;
|
||||
|
||||
break;
|
||||
// instrumental
|
||||
case 'orodnik':
|
||||
word = 'z ' + word;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
39
assets/webconfig/js/lib/jquery.i18n/languages/uk.js
Normal file
39
assets/webconfig/js/lib/jquery.i18n/languages/uk.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Ukrainian (Українська) language functions
|
||||
*/
|
||||
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
$.i18n.languages.uk = $.extend( {}, $.i18n.languages[ 'default' ], {
|
||||
convertGrammar: function ( word, form ) {
|
||||
switch ( form ) {
|
||||
case 'genitive': // родовий відмінок
|
||||
if ( word.slice( -1 ) === 'ь' ) {
|
||||
word = word.slice( 0, -1 ) + 'я';
|
||||
} else if ( word.slice( -2 ) === 'ія' ) {
|
||||
word = word.slice( 0, -2 ) + 'ії';
|
||||
} else if ( word.slice( -2 ) === 'ка' ) {
|
||||
word = word.slice( 0, -2 ) + 'ки';
|
||||
} else if ( word.slice( -2 ) === 'ти' ) {
|
||||
word = word.slice( 0, -2 ) + 'тей';
|
||||
} else if ( word.slice( -2 ) === 'ды' ) {
|
||||
word = word.slice( 0, -2 ) + 'дов';
|
||||
} else if ( word.slice( -3 ) === 'ник' ) {
|
||||
word = word.slice( 0, -3 ) + 'ника';
|
||||
}
|
||||
|
||||
break;
|
||||
case 'accusative': // знахідний відмінок
|
||||
if ( word.slice( -2 ) === 'ія' ) {
|
||||
word = word.slice( 0, -2 ) + 'ію';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
} );
|
||||
|
||||
}( jQuery ) );
|
@@ -1,8 +1,9 @@
|
||||
var storedAccess;
|
||||
var storedLang;
|
||||
var availLang = ['cs','de','en','es','fr','it','nl','pl','ro','sv','vi','ru','tr','zh-CN'];
|
||||
var availLangText = ['Čeština', 'Deutsch', 'English', 'Español', 'Français', 'Italiano', 'Nederlands', 'Polski', 'Română', 'Svenska', 'Tiếng Việt', 'русский', 'Türkçe', '汉语'];
|
||||
var availAccess = ['default','advanced','expert'];
|
||||
var availLang = ['cs', 'de', 'en', 'es', 'fr', 'it', 'nl', 'nb', 'pl', 'pt', 'ro', 'sv', 'vi', 'ru', 'tr', 'zh-CN'];
|
||||
var availLangText = ['Čeština', 'Deutsch', 'English', 'Español', 'Français', 'Italiano', 'Nederlands', 'Norsk Bokmål', 'Polski', 'Português', 'Română', 'Svenska', 'Tiếng Việt', 'русский', 'Türkçe', '汉语'];
|
||||
var availAccess = ['default', 'advanced', 'expert'];
|
||||
|
||||
//$.i18n.debug = true;
|
||||
|
||||
//Change Password
|
||||
|
Reference in New Issue
Block a user