ULS i18n performance fixes
* Since there is an API to load the i18n json files, avoid sending list of localizations to client. Previously this list was used to avoid 404s for json files. Now API takes care of it. Remove the caching for this list too. * Preload the i18n files on document ready. This avoids delay in initializing IME or ULS window after fetch i18n from server. * ApiULSLocalization can serve messages for all namespaces known if namespace parameter is not set Bug: 50391 Change-Id: I6b848da35f57353790bf460983cdf19a11bb238a
This commit is contained in:
@@ -120,31 +120,16 @@
|
||||
* i18n initialization
|
||||
*/
|
||||
function i18nInit() {
|
||||
var jsonLoader, locales, i18n;
|
||||
var jsonLoader = mw.util.wikiScript( 'api' ) + '?action=ulslocalization&language=';
|
||||
|
||||
jsonLoader = mw.util.wikiScript( 'api' ) + '?action=ulslocalization&language=';
|
||||
locales = mw.config.get( 'wgULSi18nLocales' );
|
||||
i18n = $.i18n( {
|
||||
$.i18n( {
|
||||
locale: currentLang,
|
||||
messageLocationResolver: function ( locale, messageKey ) {
|
||||
// Namespaces are not available in jquery.i18n yet. Developers prefix
|
||||
// the message key with a unique namespace like ext-uls-*
|
||||
if ( messageKey.indexOf( 'uls' ) === 0 ) {
|
||||
if ( $.inArray( locale, locales.uls ) >= 0 ) {
|
||||
return jsonLoader + locale + '&namespace=uls';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if ( messageKey.indexOf( 'ext-uls' ) === 0 ) {
|
||||
if ( $.inArray( locale, locales['ext-uls'] ) >= 0 ) {
|
||||
return jsonLoader + locale + '&namespace=ext-uls';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
messageLocationResolver: function ( locale ) {
|
||||
return jsonLoader + locale;
|
||||
}
|
||||
} );
|
||||
} )
|
||||
// Preload i18n for current language.
|
||||
.load( jsonLoader + currentLang, currentLang );
|
||||
}
|
||||
|
||||
$( document ).ready( function () {
|
||||
|
||||
Reference in New Issue
Block a user