Update jquery.i18n to dd14827

Changes:
* b00217d: build: Remove unused 'pkg' property in Gruntfile
* 5404f66: Use String#slice instead of String#substr or String#substring
* b612e92: Fix \t masquerading as a space
* 07c3fae: Add capability to set attributes and raw HTML

Change-Id: I5352032a1cef9de9afdcc3717804c4957528dfd3
This commit is contained in:
Kartik Mistry
2016-09-26 10:38:49 +05:30
committed by Amire80
parent 4b5bbcaf5b
commit 475c8a87d7
10 changed files with 105 additions and 92 deletions

View File

@@ -142,7 +142,7 @@
source = 'i18n/' + $.i18n().locale + '.json'; source = 'i18n/' + $.i18n().locale + '.json';
locale = $.i18n().locale; locale = $.i18n().locale;
} }
if ( typeof source === 'string' && if ( typeof source === 'string' &&
source.split( '.' ).pop() !== 'json' source.split( '.' ).pop() !== 'json'
) { ) {
// Load specified locale then check for fallbacks when directory is specified in load() // Load specified locale then check for fallbacks when directory is specified in load()
@@ -234,10 +234,23 @@
String.locale = i18n.locale; String.locale = i18n.locale;
return this.each( function () { return this.each( function () {
var $this = $( this ), var $this = $( this ),
messageKey = $this.data( 'i18n' ); messageKey = $this.data( 'i18n' ),
lBracket, rBracket, type, key;
if ( messageKey ) { 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 { } else {
$this.find( '[data-i18n]' ).i18n(); $this.find( '[data-i18n]' ).i18n();
} }

View File

@@ -287,9 +287,9 @@
for ( index = 0; index < forms.length; index++ ) { for ( index = 0; index < forms.length; index++ ) {
form = forms[ index ]; form = forms[ index ];
if ( explicitPluralPattern.test( form ) ) { if ( explicitPluralPattern.test( form ) ) {
formCount = parseInt( form.substring( 0, form.indexOf( '=' ) ), 10 ); formCount = parseInt( form.slice( 0, form.indexOf( '=' ) ), 10 );
if ( formCount === count ) { if ( formCount === count ) {
return ( form.substr( form.indexOf( '=' ) + 1 ) ); return ( form.slice( form.indexOf( '=' ) + 1 ) );
} }
forms[ index ] = undefined; forms[ index ] = undefined;
} }

View File

@@ -123,7 +123,7 @@
return function () { return function () {
var result = null; var result = null;
if ( message.substr( pos, len ) === s ) { if ( message.slice( pos, pos + len ) === s ) {
result = s; result = s;
pos += len; pos += len;
} }
@@ -134,7 +134,7 @@
function makeRegexParser( regex ) { function makeRegexParser( regex ) {
return function () { return function () {
var matches = message.substr( pos ).match( regex ); var matches = message.slice( pos ).match( regex );
if ( matches === null ) { if ( matches === null ) {
return null; return null;

View File

@@ -33,7 +33,7 @@
break; break;
case 'illative': case 'illative':
// Double the last letter and add 'n' // Double the last letter and add 'n'
word += word.substr( word.length - 1 ) + 'n'; word += word.slice( -1 ) + 'n';
break; break;
case 'inessive': case 'inessive':
word += ( aou ? 'ssa' : 'ssä' ); word += ( aou ? 'ssa' : 'ssä' );

View File

@@ -10,17 +10,17 @@
case 'prefixed': case 'prefixed':
case 'תחילית': // the same word in Hebrew case 'תחילית': // the same word in Hebrew
// Duplicate prefixed "Waw", but only if it's not already double // Duplicate prefixed "Waw", but only if it's not already double
if ( word.substr( 0, 1 ) === 'ו' && word.substr( 0, 2 ) !== 'וו' ) { if ( word.slice( 0, 1 ) === 'ו' && word.slice( 0, 2 ) !== 'וו' ) {
word = 'ו' + word; word = 'ו' + word;
} }
// Remove the "He" if prefixed // Remove the "He" if prefixed
if ( word.substr( 0, 1 ) === 'ה' ) { if ( word.slice( 0, 1 ) === 'ה' ) {
word = word.substr( 1, word.length ); word = word.slice( 1 );
} }
// Add a hyphen (maqaf) before numbers and non-Hebrew letters // Add a hyphen (maqaf) before numbers and non-Hebrew letters
if ( word.substr( 0, 1 ) < 'א' || word.substr( 0, 1 ) > 'ת' ) { if ( word.slice( 0, 1 ) < 'א' || word.slice( 0, 1 ) > 'ת' ) {
word = '־' + word; word = '־' + word;
} }
} }

View File

@@ -8,12 +8,12 @@
$.i18n.languages.hy = $.extend( {}, $.i18n.languages[ 'default' ], { $.i18n.languages.hy = $.extend( {}, $.i18n.languages[ 'default' ], {
convertGrammar: function ( word, form ) { convertGrammar: function ( word, form ) {
if ( form === 'genitive' ) { // սեռական հոլով if ( form === 'genitive' ) { // սեռական հոլով
if ( word.substr( -1 ) === 'ա' ) { if ( word.slice( -1 ) === 'ա' ) {
word = word.substr( 0, word.length - 1 ) + 'այի'; word = word.slice( 0, -1 ) + 'այի';
} else if ( word.substr( -1 ) === 'ո' ) { } else if ( word.slice( -1 ) === 'ո' ) {
word = word.substr( 0, word.length - 1 ) + 'ոյի'; word = word.slice( 0, -1 ) + 'ոյի';
} else if ( word.substr( -4 ) === 'գիրք' ) { } else if ( word.slice( -4 ) === 'գիրք' ) {
word = word.substr( 0, word.length - 4 ) + 'գրքի'; word = word.slice( 0, -4 ) + 'գրքի';
} else { } else {
word = word + 'ի'; word = word + 'ի';
} }

View File

@@ -13,34 +13,34 @@
switch ( form ) { switch ( form ) {
case 'ഉദ്ദേശിക': case 'ഉദ്ദേശിക':
case 'dative': case 'dative':
if ( word.substr( -1 ) === 'ു' || if ( word.slice( -1 ) === 'ു' ||
word.substr( -1 ) === 'ൂ' || word.slice( -1 ) === 'ൂ' ||
word.substr( -1 ) === 'ൗ' || word.slice( -1 ) === 'ൗ' ||
word.substr( -1 ) === 'ൌ' word.slice( -1 ) === 'ൌ'
) { ) {
word += 'വിന്'; word += 'വിന്';
} else if ( word.substr( -1 ) === '' ) { } else if ( word.slice( -1 ) === '' ) {
word = word.substr( 0, word.length - 1 ) + 'ത്തിന്'; word = word.slice( 0, -1 ) + 'ത്തിന്';
} else if ( word.substr( -1 ) === 'ൻ' ) { } else if ( word.slice( -1 ) === 'ൻ' ) {
// Atomic chillu n. അവൻ -> അവന് // Atomic chillu n. അവൻ -> അവന്
word = word.substr( 0, word.length - 1 ) + 'ന്'; word = word.slice( 0, -1 ) + 'ന്';
} else if ( word.substr( -3 ) === 'ന്\u200d' ) { } else if ( word.slice( -3 ) === 'ന്\u200d' ) {
// chillu n. അവൻ -> അവന് // chillu n. അവൻ -> അവന്
word = word.substr( 0, word.length - 1 ); word = word.slice( 0, -1 );
} else if ( word.substr( -1 ) === 'ൾ' || word.substr( -3 ) === 'ള്\u200d' ) { } else if ( word.slice( -1 ) === 'ൾ' || word.slice( -3 ) === 'ള്\u200d' ) {
word += 'ക്ക്'; word += 'ക്ക്';
} else if ( word.substr( -1 ) === 'ർ' || word.substr( -3 ) === 'ര്\u200d' ) { } else if ( word.slice( -1 ) === 'ർ' || word.slice( -3 ) === 'ര്\u200d' ) {
word += 'ക്ക്'; word += 'ക്ക്';
} else if ( word.substr( -1 ) === 'ൽ' ) { } else if ( word.slice( -1 ) === 'ൽ' ) {
// Atomic chillu ൽ , ഫയൽ -> ഫയലിന് // Atomic chillu ൽ , ഫയൽ -> ഫയലിന്
word = word.substr( 0, word.length - 1 ) + 'ലിന്'; word = word.slice( 0, -1 ) + 'ലിന്';
} else if ( word.substr( -3 ) === 'ല്\u200d' ) { } else if ( word.slice( -3 ) === 'ല്\u200d' ) {
// chillu ല്\u200d , ഫയല്\u200d -> ഫയലിന് // chillu ല്\u200d , ഫയല്\u200d -> ഫയലിന്
word = word.substr( 0, word.length - 2 ) + 'ിന്'; word = word.slice( 0, -2 ) + 'ിന്';
} else if ( word.substr( -2 ) === 'ു്' ) { } else if ( word.slice( -2 ) === 'ു്' ) {
word = word.substr( 0, word.length - 2 ) + 'ിന്'; word = word.slice( 0, -2 ) + 'ിന്';
} else if ( word.substr( -1 ) === '്' ) { } else if ( word.slice( -1 ) === '്' ) {
word = word.substr( 0, word.length - 1 ) + 'ിന്'; word = word.slice( 0, -1 ) + 'ിന്';
} else { } else {
// കാവ്യ -> കാവ്യയ്ക്ക്, ഹരി -> ഹരിയ്ക്ക്, മല -> മലയ്ക്ക് // കാവ്യ -> കാവ്യയ്ക്ക്, ഹരി -> ഹരിയ്ക്ക്, മല -> മലയ്ക്ക്
word += 'യ്ക്ക്'; word += 'യ്ക്ക്';
@@ -49,42 +49,42 @@
break; break;
case 'സംബന്ധിക': case 'സംബന്ധിക':
case 'genitive': case 'genitive':
if ( word.substr( -1 ) === '' ) { if ( word.slice( -1 ) === '' ) {
word = word.substr( 0, word.length - 1 ) + 'ത്തിന്റെ'; word = word.slice( 0, -1 ) + 'ത്തിന്റെ';
} else if ( word.substr( -2 ) === 'ു്' ) { } else if ( word.slice( -2 ) === 'ു്' ) {
word = word.substr( 0, word.length - 2 ) + 'ിന്റെ'; word = word.slice( 0, -2 ) + 'ിന്റെ';
} else if ( word.substr( -1 ) === '്' ) { } else if ( word.slice( -1 ) === '്' ) {
word = word.substr( 0, word.length - 1 ) + 'ിന്റെ'; word = word.slice( 0, -1 ) + 'ിന്റെ';
} else if ( word.substr( -1 ) === 'ു' || } else if ( word.slice( -1 ) === 'ു' ||
word.substr( -1 ) === 'ൂ' || word.slice( -1 ) === 'ൂ' ||
word.substr( -1 ) === 'ൗ' || word.slice( -1 ) === 'ൗ' ||
word.substr( -1 ) === 'ൌ' word.slice( -1 ) === 'ൌ'
) { ) {
word += 'വിന്റെ'; word += 'വിന്റെ';
} else if ( word.substr( -1 ) === 'ൻ' ) { } else if ( word.slice( -1 ) === 'ൻ' ) {
// Atomic chillu n. അവൻ -> അവന്റെ // Atomic chillu n. അവൻ -> അവന്റെ
word = word.substr( 0, word.length - 1 ) + 'ന്റെ'; word = word.slice( 0, -1 ) + 'ന്റെ';
} else if ( word.substr( -3 ) === 'ന്\u200d' ) { } else if ( word.slice( -3 ) === 'ന്\u200d' ) {
// chillu n. അവൻ -> അവന്റെ // chillu n. അവൻ -> അവന്റെ
word = word.substr( 0, word.length - 1 ) + 'റെ'; word = word.slice( 0, -1 ) + 'റെ';
} else if ( word.substr( -3 ) === 'ള്\u200d' ) { } else if ( word.slice( -3 ) === 'ള്\u200d' ) {
// chillu n. അവൾ -> അവളുടെ // chillu n. അവൾ -> അവളുടെ
word = word.substr( 0, word.length - 2 ) + 'ുടെ'; word = word.slice( 0, -2 ) + 'ുടെ';
} else if ( word.substr( -1 ) === 'ൾ' ) { } else if ( word.slice( -1 ) === 'ൾ' ) {
// Atomic chillu n. അവള്\u200d -> അവളുടെ // Atomic chillu n. അവള്\u200d -> അവളുടെ
word = word.substr( 0, word.length - 1 ) + 'ളുടെ'; word = word.slice( 0, -1 ) + 'ളുടെ';
} else if ( word.substr( -1 ) === 'ൽ' ) { } else if ( word.slice( -1 ) === 'ൽ' ) {
// Atomic l. മുയല്\u200d -> മുയലിന്റെ // Atomic l. മുയല്\u200d -> മുയലിന്റെ
word = word.substr( 0, word.length - 1 ) + 'ലിന്റെ'; word = word.slice( 0, -1 ) + 'ലിന്റെ';
} else if ( word.substr( -3 ) === 'ല്\u200d' ) { } else if ( word.slice( -3 ) === 'ല്\u200d' ) {
// chillu l. മുയല്\u200d -> അവളുടെ // chillu l. മുയല്\u200d -> അവളുടെ
word = word.substr( 0, word.length - 2 ) + 'ിന്റെ'; word = word.slice( 0, -2 ) + 'ിന്റെ';
} else if ( word.substr( -3 ) === 'ര്\u200d' ) { } else if ( word.slice( -3 ) === 'ര്\u200d' ) {
// chillu r. അവര്\u200d -> അവരുടെ // chillu r. അവര്\u200d -> അവരുടെ
word = word.substr( 0, word.length - 2 ) + 'ുടെ'; word = word.slice( 0, -2 ) + 'ുടെ';
} else if ( word.substr( -1 ) === 'ർ' ) { } else if ( word.slice( -1 ) === 'ർ' ) {
// Atomic chillu r. അവർ -> അവരുടെ // Atomic chillu r. അവർ -> അവരുടെ
word = word.substr( 0, word.length - 1 ) + 'രുടെ'; word = word.slice( 0, -1 ) + 'രുടെ';
} else { } else {
word += 'യുടെ'; word += 'യുടെ';
} }

View File

@@ -22,7 +22,7 @@
if ( word.match( /тæ$/i ) ) { if ( word.match( /тæ$/i ) ) {
// Checking if the $word is in plural form // Checking if the $word is in plural form
word = word.substring( 0, word.length - 1 ); word = word.slice( 0, -1 );
endAllative = 'æм'; endAllative = 'æм';
} else if ( word.match( /[аæеёиоыэюя]$/i ) ) { } else if ( word.match( /[аæеёиоыэюя]$/i ) ) {
// Works if word is in singular form. // Works if word is in singular form.
@@ -34,7 +34,7 @@
// vowel 'U' in cyrillic Ossetic. // vowel 'U' in cyrillic Ossetic.
// Examples: {{grammar:genitive|аунеу}} = аунеуы, // Examples: {{grammar:genitive|аунеу}} = аунеуы,
// {{grammar:genitive|лæппу}} = лæппуйы. // {{grammar:genitive|лæппу}} = лæппуйы.
if ( !word.substring( word.length - 2, word.length - 1 ) if ( !word.slice( -2, -1 )
.match( /[аæеёиоыэюя]$/i ) ) { .match( /[аæеёиоыэюя]$/i ) ) {
jot = 'й'; jot = 'й';
} }

View File

@@ -8,18 +8,18 @@
$.i18n.languages.ru = $.extend( {}, $.i18n.languages[ 'default' ], { $.i18n.languages.ru = $.extend( {}, $.i18n.languages[ 'default' ], {
convertGrammar: function ( word, form ) { convertGrammar: function ( word, form ) {
if ( form === 'genitive' ) { // родительный падеж if ( form === 'genitive' ) { // родительный падеж
if ( word.substr( -1 ) === 'ь' ) { if ( word.slice( -1 ) === 'ь' ) {
word = word.substr( 0, word.length - 1 ) + 'я'; word = word.slice( 0, -1 ) + 'я';
} else if ( word.substr( -2 ) === 'ия' ) { } else if ( word.slice( -2 ) === 'ия' ) {
word = word.substr( 0, word.length - 2 ) + 'ии'; word = word.slice( 0, -2 ) + 'ии';
} else if ( word.substr( -2 ) === 'ка' ) { } else if ( word.slice( -2 ) === 'ка' ) {
word = word.substr( 0, word.length - 2 ) + 'ки'; word = word.slice( 0, -2 ) + 'ки';
} else if ( word.substr( -2 ) === 'ти' ) { } else if ( word.slice( -2 ) === 'ти' ) {
word = word.substr( 0, word.length - 2 ) + 'тей'; word = word.slice( 0, -2 ) + 'тей';
} else if ( word.substr( -2 ) === 'ды' ) { } else if ( word.slice( -2 ) === 'ды' ) {
word = word.substr( 0, word.length - 2 ) + 'дов'; word = word.slice( 0, -2 ) + 'дов';
} else if ( word.substr( -3 ) === 'ник' ) { } else if ( word.slice( -3 ) === 'ник' ) {
word = word.substr( 0, word.length - 3 ) + 'ника'; word = word.slice( 0, -3 ) + 'ника';
} }
} }

View File

@@ -9,24 +9,24 @@
convertGrammar: function ( word, form ) { convertGrammar: function ( word, form ) {
switch ( form ) { switch ( form ) {
case 'genitive': // родовий відмінок case 'genitive': // родовий відмінок
if ( word.substr( -1 ) === 'ь' ) { if ( word.slice( -1 ) === 'ь' ) {
word = word.substr( 0, word.length - 1 ) + 'я'; word = word.slice( 0, -1 ) + 'я';
} else if ( word.substr( -2 ) === 'ія' ) { } else if ( word.slice( -2 ) === 'ія' ) {
word = word.substr( 0, word.length - 2 ) + 'ії'; word = word.slice( 0, -2 ) + 'ії';
} else if ( word.substr( -2 ) === 'ка' ) { } else if ( word.slice( -2 ) === 'ка' ) {
word = word.substr( 0, word.length - 2 ) + 'ки'; word = word.slice( 0, -2 ) + 'ки';
} else if ( word.substr( -2 ) === 'ти' ) { } else if ( word.slice( -2 ) === 'ти' ) {
word = word.substr( 0, word.length - 2 ) + 'тей'; word = word.slice( 0, -2 ) + 'тей';
} else if ( word.substr( -2 ) === 'ды' ) { } else if ( word.slice( -2 ) === 'ды' ) {
word = word.substr( 0, word.length - 2 ) + 'дов'; word = word.slice( 0, -2 ) + 'дов';
} else if ( word.substr( -3 ) === 'ник' ) { } else if ( word.slice( -3 ) === 'ник' ) {
word = word.substr( 0, word.length - 3 ) + 'ника'; word = word.slice( 0, -3 ) + 'ника';
} }
break; break;
case 'accusative': // знахідний відмінок case 'accusative': // знахідний відмінок
if ( word.substr( -2 ) === 'ія' ) { if ( word.slice( -2 ) === 'ія' ) {
word = word.substr( 0, word.length - 2 ) + 'ію'; word = word.slice( 0, -2 ) + 'ію';
} }
break; break;