Update jquery.i18n from upstream

Follow up of Id533eb69

Change-Id: Ib32c044433ee6ba8f487a33137a704885003cfbb
This commit is contained in:
Santhosh Thottingal
2012-11-01 16:34:23 +05:30
parent cb78d33a0c
commit f6fbf13e05

View File

@@ -289,7 +289,7 @@
var $links = $( "link" );
var linksCount = $links.length;
// Check for <link rel="localization" hreflang="xyz" elements
while (linksCount--) {
while ( linksCount-- ) {
var $link = $( $links[linksCount] );
var rel = ( $link.attr( "rel" ) || "" ).toLowerCase().split( /\s+/ );
if ( $.inArray( "localizations", rel ) !== -1 ) {
@@ -297,8 +297,8 @@
messageStore.load( $link.attr( "href" ) );
} else if ( $.inArray( "localization", rel ) !== -1 ) {
// single localization
messageStore.queue( ( $link.attr( "hreflang" ) || "" )
.toLowerCase(), $link.attr( "href" ) );
messageStore.queue( ( $link.attr( "hreflang" ) || "" ).toLowerCase(),
$link.attr( "href" ) );
}
}
},
@@ -350,6 +350,7 @@
messageStore.log( "Loading messages from: " + data );
messageStore.jsonMessageLoader( data ).done( function ( localization, textStatus ) {
messageStore.load( localization, locale );
messageStore.queue( locale, data );
messageStore.markLoaded( locale, data );
} );
} else {
@@ -387,6 +388,12 @@
}
},
/**
* Mark a message Location for a locale loaded
*
* @param locale
* @param messageLocation
*/
markLoaded: function ( locale, messageLocation ) {
var i, queue = this.sources[locale];
@@ -394,7 +401,9 @@
this.queue( locale, messageLocation );
queue = this.sources[locale];
}
this.sources[locale] = this.sources[locale] || [];
for (i = 0; i < queue.length; i++) {
if ( queue[i].source.url === messageLocation ) {
queue[i].source.loaded = true;
@@ -403,11 +412,17 @@
}
},
/**
* Register the message location for a locale, will be loaded when required
*
* @param locale
* @param messageLocation
*/
queue: function ( locale, messageLocation ) {
var i,
queue = this.sources[locale];
var i, queue = this.sources[locale];
this.sources[locale] = this.sources[locale] || [];
if ( queue ) {
for (i = 0; i < queue.length; i++) {
if ( queue[i].source.url === messageLocation ) {
@@ -415,7 +430,8 @@
}
}
}
this.log( 'Source for: ' + locale + ' : ' + messageLocation + ' registered' );
this.log( 'Source for: ' + locale + ' is ' + messageLocation + ' registered' );
this.sources[locale].push( {
source: {
url: messageLocation,
@@ -433,7 +449,6 @@
var i,
queue = this.sources[locale];
if ( queue ) {
for (i = 0; i < queue.length; i++) {
if ( !queue[i].source.loaded ) {
@@ -454,6 +469,7 @@
}
}
}
return result;
},