Page MenuHomePhabricator

ResourceLoader: 'languageScripts' in the file module should look for fallback languages
Closed, ResolvedPublic


It is by design that ResourceLoader expects languageScripts to be complete (e.g. no partial fallback) because they are free-form javascript.

However we should still support fallbacks.

e.g. in a case of momentjs, jquery.i18n, or jquery.ui.datepicker like:

'jquery.ui.datepicker' => array(

		'languageScripts' => array(
			'af' => 'jquery.ui.datepicker-af.js',
			'cs' => 'jquery.ui.datepicker-cs.js',
			'de' => 'jquery.ui.datepicker-de.js',
			'el' => 'jquery.ui.datepicker-el.js',
			'en-gb' => 'jquery.ui.datepicker-en-GB.js',
			'ru' => 'jquery.ui.datepicker-ru.js',

When, for example, using de-formal, since it isn't specified, should result in 'de' being loaded instead. Not falling back straight to 'en'.

Same for 'ab' falling back to 'ru' etc.

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:28 AM
bzimport set Reference to bz58139.

Currently, only $wgExtensionMessagesFiles backed i18n supports proper fallback. jquery.ui.datepicker is just some random library, as far as I know.

This isn't about fallback of individual messages, because this is for logic files (as opposed to message blobs, which we already transport as JSON and resolve server-side using MediaWiki's localization framework).

E.g. files such as:

modules: {

'jquery.ui.datepicker': {
  languageScripts: {
    af: 'jquery.ui.datepicker-af.js'

'mediawiki.language': {
  languageScripts: {
    bs: 'languages/bs.js'

'jquery.i18n': {
  languageScripts: {
    bs: 'src/languages/bs.js'

'moment': {
  languageScripts: {
    ar: 'lang/ar.js'

In all of these cases, if the library doesn't have a specific file for the current language, wouldn't you want ResourceLoader to look at the fallbacks for that language and see if we can pick another one as fallback?

Right now if there isn't a language script for the specific language code, ResourceLoader will just use the default ('en').

Krinkle, Has this been worked on at all? Moving to 1.24

We want better i18n for smaller languages with fallbacks other than 'en'. Especially with upstream translations like jquery-ui and moment.js, having fallbacks here is useful to users.

Change 157180 had a related patch set uploaded by Legoktm:
ResourceLoaderFileModule: Support fallback in 'languageScripts'

Change 157180 merged by jenkins-bot:
ResourceLoaderFileModule: Support fallback in 'languageScripts'