Refactor all language, font change code to preview method
Avoids duplication of code and better organising language and font change logic Change-Id: I4e95cfc2de7b650a75e2bd550af547647d5b3eb3
This commit is contained in:
committed by
Santhosh
parent
a6a06823bf
commit
32bb03045f
@@ -108,11 +108,7 @@
|
|||||||
|
|
||||||
// Usually this is already loaded, but when changing language it
|
// Usually this is already loaded, but when changing language it
|
||||||
// might not be.
|
// might not be.
|
||||||
$.i18n().locale = this.uiLanguage;
|
this.preview( this.uiLanguage );
|
||||||
mw.uls.loadLocalization( this.uiLanguage )
|
|
||||||
.done( $.proxy( this.i18n, this ) );
|
|
||||||
|
|
||||||
this.$webfonts.refresh();
|
|
||||||
this.listen();
|
this.listen();
|
||||||
this.dirty = false;
|
this.dirty = false;
|
||||||
this.savedRegistry = $.extend( true, {}, mw.webfonts.preferences );
|
this.savedRegistry = $.extend( true, {}, mw.webfonts.preferences );
|
||||||
@@ -223,9 +219,6 @@
|
|||||||
$( 'div.uls-ui-languages button.button' ).removeClass( 'down' );
|
$( 'div.uls-ui-languages button.button' ).removeClass( 'down' );
|
||||||
button.addClass( 'down' );
|
button.addClass( 'down' );
|
||||||
displaySettings.prepareUIFonts();
|
displaySettings.prepareUIFonts();
|
||||||
// set the language for the settings panel so that webfonts
|
|
||||||
// are correctly applied.
|
|
||||||
displaySettings.$template.attr( 'lang', displaySettings.uiLanguage );
|
|
||||||
displaySettings.preview( displaySettings.uiLanguage );
|
displaySettings.preview( displaySettings.uiLanguage );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -344,9 +337,11 @@
|
|||||||
*/
|
*/
|
||||||
preview: function ( language ) {
|
preview: function ( language ) {
|
||||||
var displaySettings = this;
|
var displaySettings = this;
|
||||||
|
this.$template.attr( 'lang', language );
|
||||||
|
$.i18n().locale = language;
|
||||||
mw.uls.loadLocalization( language ).done( function () {
|
mw.uls.loadLocalization( language ).done( function () {
|
||||||
displaySettings.i18n();
|
displaySettings.i18n();
|
||||||
|
displaySettings.$webfonts.refresh();
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -618,7 +613,6 @@
|
|||||||
// Restore content and UI language
|
// Restore content and UI language
|
||||||
this.uiLanguage = this.getUILanguage();
|
this.uiLanguage = this.getUILanguage();
|
||||||
this.contentLanguage = this.getContentLanguage();
|
this.contentLanguage = this.getContentLanguage();
|
||||||
this.$template.attr( 'lang', this.uiLanguage );
|
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user