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';
locale = $.i18n().locale;
}
if ( typeof source === 'string' &&
if ( typeof source === 'string' &&
source.split( '.' ).pop() !== 'json'
) {
// Load specified locale then check for fallbacks when directory is specified in load()
@@ -234,10 +234,23 @@
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();
}

View File

@@ -287,9 +287,9 @@
for ( index = 0; index < forms.length; 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;
}

View File

@@ -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,7 +134,7 @@
function makeRegexParser( regex ) {
return function () {
var matches = message.substr( pos ).match( regex );
var matches = message.slice( pos ).match( regex );
if ( matches === null ) {
return null;

View File

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

View File

@@ -10,17 +10,17 @@
case 'prefixed':
case 'תחילית': // the same word in Hebrew
// 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;
}
// Remove the "He" if prefixed
if ( word.substr( 0, 1 ) === 'ה' ) {
word = word.substr( 1, word.length );
if ( word.slice( 0, 1 ) === 'ה' ) {
word = word.slice( 1 );
}
// 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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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