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();
}