Page MenuHomePhabricator

[S] Fix MediaSearch wiki i18n language error handling.
Closed, ResolvedPublic

Description is on the main cluster and uses Commons as its shared repository, and allows us to test MediaSearch in a non-Commons production equivalent environment, allowing rapid deployment and testing without requiring a community to be our guinea pig.

However, on test wikipedia, the interface language is given as "test", not as any actual interface language. That's likely a bug with test wikipedia. If we can deal with that error handling in MediaSearch - e.g, see if this language is a valid language - then we can handle it gracefully and provide a default value (English).

(Replicated on

RangeError: Incorrect locale information provided

at Number.toLocaleString (<anonymous>)
at VueComponent.resultsCount ()

		resultsCount: function () {
			return this.$i18n(
				this.totalHits[ this.mediaType ].toLocaleString( mw.config.get( 'wgUserLanguage' ) )

Seems we are assuming the value of mw.config.get('wgUserLanguage') is always going to be a valid arg for toLocaleString(). Unfortunately test wiki is returning:


Acceptance Criteria:

  • Implement error handling in MediaSearch to determine if the interface language is valid
  • Fail gracefully if the language is invalid and default to English
  • Determine if there are other production-level issues this uncovers, and create tickets for them

Event Timeline

CBogen renamed this task from Fix MediaSearch wiki i18n language error handling. to [S] Fix MediaSearch wiki i18n language error handling..Aug 17 2021, 4:57 PM

We may be able to use mw.language.convertNumber here as well.

Change 715008 had a related patch set uploaded (by Seddon; author: Seddon):

[mediawiki/extensions/MediaSearch@master] Fix MediaSearch wiki i18n language error handling.

Change 715008 merged by jenkins-bot:

[mediawiki/extensions/MediaSearch@master] Fix MediaSearch wiki i18n language error handling.

Etonkovidova added a subscriber: Etonkovidova.

Checked testwiki wmf 21: mw.config.get('wgUserLanguage') returns the user interface language that is set in Preferences (or with uselang=).

Not sure if "American sign language" option should fall to en. Currently the UI for ase language doesn't make much sense:

Screen Shot 2021-09-03 at 5.08.43 PM.png (1×2 px, 632 KB)