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:
@@ -250,41 +250,6 @@ class UniversalLanguageSelectorHooks {
|
||||
$vars['wgULSPosition'] = $wgULSPosition;
|
||||
$vars['wgULSAnonCanChangeLanguage'] = $wgULSAnonCanChangeLanguage;
|
||||
|
||||
// ULS is localized using jquery.i18n library. Unless it knows
|
||||
// the localized locales, it can create 404 response. To avoid that,
|
||||
// send the locales available at server. Also avoid directory scanning
|
||||
// in each request by putting the locale list in cache.
|
||||
$cache = wfGetCache( CACHE_ANYTHING );
|
||||
$key = wfMemcKey( 'uls', 'i18n', 'locales' );
|
||||
$result = $cache->get( $key );
|
||||
|
||||
if ( $result ) {
|
||||
$vars['wgULSi18nLocales'] = $result;
|
||||
} else {
|
||||
$mwULSL10nFiles = glob( __DIR__ . '/i18n/*.json' );
|
||||
|
||||
$mwULSL10nLocales = array();
|
||||
foreach ( $mwULSL10nFiles as $localeFile ) {
|
||||
$mwULSL10nLocales[] = basename( $localeFile, '.json' );
|
||||
}
|
||||
|
||||
$mwULSL10nFiles = glob( __DIR__ . '/lib/jquery.uls/i18n/*.json' );
|
||||
|
||||
$jqueryULSL10nLocales = array();
|
||||
foreach ( $mwULSL10nFiles as $localeFile ) {
|
||||
$jqueryULSL10nLocales[] = basename( $localeFile, '.json' );
|
||||
}
|
||||
|
||||
$vars['wgULSi18nLocales'] = array(
|
||||
// Locales to which jQuery ULS is localized.
|
||||
'uls' => $jqueryULSL10nLocales,
|
||||
// Locales to which Mediawiki ULS is localized.
|
||||
'ext-uls' => $mwULSL10nLocales,
|
||||
);
|
||||
|
||||
// Cache it for 1 hour
|
||||
$cache->set( $key, $vars['wgULSi18nLocales'], 3600 );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user