-/**
+/*!
* jQuery Internationalization library - Message Store
*
* Copyright (C) 2012 Santhosh Thottingal
* @licence MIT License
*/
-( function ( $, window, undefined ) {
+( function ( $ ) {
'use strict';
var MessageStore = function () {
this.sources = {};
};
+ function jsonMessageLoader( url ) {
+ var deferred = $.Deferred();
+
+ $.getJSON( url )
+ .done( deferred.resolve )
+ .fail( function ( jqxhr, settings, exception ) {
+ $.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
+ // Ignore 404 exception, because we are handling fallabacks explicitly
+ deferred.resolve();
+ } );
+
+ return deferred.promise();
+ }
+
/**
* See https://github.com/wikimedia/jquery.i18n/wiki/Specification#wiki-Message_File_Loading
*/
* null/undefined/false,
* all cached messages for the i18n instance will get reset.
*
- * @param {String|Object} source
- * @param {String} locale Language tag
+ * @param {string|Object} source
+ * @param {string} locale Language tag
* @return {jQuery.Promise}
*/
load: function ( source, locale ) {
locale = key;
// No {locale} given, assume data is a group of languages,
// call this function again for each language.
- deferreds.push( messageStore.load( source[key], locale ) );
+ deferreds.push( messageStore.load( source[ key ], locale ) );
}
}
return $.when.apply( $, deferreds );
/**
* Set messages to the given locale.
* If locale exists, add messages to the locale.
- * @param locale
- * @param messages
+ *
+ * @param {string} locale
+ * @param {Object} messages
*/
set: function ( locale, messages ) {
- if ( !this.messages[locale] ) {
- this.messages[locale] = messages;
+ if ( !this.messages[ locale ] ) {
+ this.messages[ locale ] = messages;
} else {
- this.messages[locale] = $.extend( this.messages[locale], messages );
+ this.messages[ locale ] = $.extend( this.messages[ locale ], messages );
}
},
/**
*
- * @param locale
- * @param messageKey
- * @returns {Boolean}
+ * @param {string} locale
+ * @param {string} messageKey
+ * @return {boolean}
*/
get: function ( locale, messageKey ) {
- return this.messages[locale] && this.messages[locale][messageKey];
+ return this.messages[ locale ] && this.messages[ locale ][ messageKey ];
}
};
- function jsonMessageLoader( url ) {
- var deferred = $.Deferred();
-
- $.getJSON( url )
- .done( deferred.resolve )
- .fail( function ( jqxhr, settings, exception ) {
- $.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
- // Ignore 404 exception, because we are handling fallabacks explicitly
- deferred.resolve();
- } );
-
- return deferred.promise();
- }
-
$.extend( $.i18n.messageStore, new MessageStore() );
-}( jQuery, window ) );
+}( jQuery ) );