Avoid 404s in non-localized locales

* Update jquery.i18n - if messageLocationResolver returns false for
  a locale, no server hit will be attempted
* Refactor i18n preparation code to a new method
* Use the ULS RL hooks to find out to which locales it is localized,
  pass that list to js to avoid hitting server.
* Also avoid directory scanning in each request by putting
  the locale list in cache

Fixes Bug 41454

Change-Id: I0c923b35db01b884e2dd55873dd5fb7384434645
This commit is contained in:
Santhosh Thottingal
2012-10-27 19:27:10 +05:30
committed by Gerrit Code Review
parent b86724b811
commit 427c94dbbf
3 changed files with 75 additions and 20 deletions

View File

@@ -49,7 +49,7 @@
// Override String.localeString method
String.prototype.toLocaleString = function () {
var localeParts, localePartIndex, value, locale, fallbackIndex;
var localeParts, messages, localePartIndex, value, locale, fallbackIndex;
value = this.valueOf();
locale = i18n.locale;
@@ -65,12 +65,11 @@
var _locale = localeParts.slice( 0, localePartIndex ).join( "-" );
if ( !i18n.messageStore.messages[_locale] && i18n.options.messageLocationResolver ) {
// FIXME If messageloading gives 404, it keep on trying to
// load the file again and again
i18n.messageStore.load(
i18n.options.messageLocationResolver( _locale ),
_locale
);
messages = i18n.options.messageLocationResolver( _locale, value );
if ( messages ) {
i18n.messageStore.load( messages, _locale );
}
}
var message = i18n.messageStore.get( _locale, value );