diff --git a/lib/jquery.i18n/jquery.i18n.js b/lib/jquery.i18n/jquery.i18n.js index 7ac8ba87..ceff7940 100644 --- a/lib/jquery.i18n/jquery.i18n.js +++ b/lib/jquery.i18n/jquery.i18n.js @@ -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(); } diff --git a/lib/jquery.i18n/jquery.i18n.language.js b/lib/jquery.i18n/jquery.i18n.language.js index f4b31284..d5ab75fa 100644 --- a/lib/jquery.i18n/jquery.i18n.language.js +++ b/lib/jquery.i18n/jquery.i18n.language.js @@ -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; } diff --git a/lib/jquery.i18n/jquery.i18n.parser.js b/lib/jquery.i18n/jquery.i18n.parser.js index 8a9ca190..27d35661 100644 --- a/lib/jquery.i18n/jquery.i18n.parser.js +++ b/lib/jquery.i18n/jquery.i18n.parser.js @@ -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; diff --git a/lib/jquery.i18n/languages/fi.js b/lib/jquery.i18n/languages/fi.js index 82c56506..5c1f54e6 100644 --- a/lib/jquery.i18n/languages/fi.js +++ b/lib/jquery.i18n/languages/fi.js @@ -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ä' ); diff --git a/lib/jquery.i18n/languages/he.js b/lib/jquery.i18n/languages/he.js index 44d810b4..ce8a4c05 100644 --- a/lib/jquery.i18n/languages/he.js +++ b/lib/jquery.i18n/languages/he.js @@ -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; } } diff --git a/lib/jquery.i18n/languages/hy.js b/lib/jquery.i18n/languages/hy.js index 23bb0213..5ecf7ba5 100644 --- a/lib/jquery.i18n/languages/hy.js +++ b/lib/jquery.i18n/languages/hy.js @@ -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 + 'ի'; } diff --git a/lib/jquery.i18n/languages/ml.js b/lib/jquery.i18n/languages/ml.js index f3d67886..02bae2d2 100644 --- a/lib/jquery.i18n/languages/ml.js +++ b/lib/jquery.i18n/languages/ml.js @@ -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 += 'യുടെ'; } diff --git a/lib/jquery.i18n/languages/os.js b/lib/jquery.i18n/languages/os.js index fed63aea..90fcce06 100644 --- a/lib/jquery.i18n/languages/os.js +++ b/lib/jquery.i18n/languages/os.js @@ -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 = 'й'; } diff --git a/lib/jquery.i18n/languages/ru.js b/lib/jquery.i18n/languages/ru.js index 684660b6..60fefffa 100644 --- a/lib/jquery.i18n/languages/ru.js +++ b/lib/jquery.i18n/languages/ru.js @@ -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 ) + 'ника'; } } diff --git a/lib/jquery.i18n/languages/uk.js b/lib/jquery.i18n/languages/uk.js index bb99073e..7762e0a5 100644 --- a/lib/jquery.i18n/languages/uk.js +++ b/lib/jquery.i18n/languages/uk.js @@ -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;