Page MenuHomePhabricator

Language selector: Show suggested languages
Closed, ResolvedPublic4 Estimated Story Points

Description

Looking at the initial implementation of the language selector (T253303) available for Section Translation at test wiki, the list of suggested languages is not showing despite the large number of languages listed.

When the conditions are met, the list of languages is organized in two groups ("Suggested" and "All languages")

Copying from the spec in T253303:

Number of languages

  • 0–9 languages. Suggested languages are hidden. The list of languages has no label, and uses one column.
  • 10-29 languages. Suggested languages are shown using 2 columns. The list of languages uses one column. Both lists are labelled.
  • 30 or more languages. Suggested languages are shown. The lists of suggested and all languages use 3 columns (on wide screens). Additional space is added after each block of 5 rows.
0–9 languages10-29 languages30-* languages
short.png (310×348 px, 11 KB)
default.png (310×348 px, 19 KB)
3cols-and-suggested.png (448×512 px, 40 KB)

Layout spacing.png (768×1 px, 88 KB)

Suggested languages

  • The selector displays up to six suggested languages, using two or three columns depending on the number of languages (see responsive layout section).
  • By default suggested languages
  • Apps opening the selector can provide their own list of suggested languages, or hide the list.
  • When suggested languages are not show (or the list is empty), the list of "all languages" will have its title hidden.

Event Timeline

Pginer-WMF triaged this task as Medium priority.
abi_ set the point value for this task to 4.

The current ULS uses the following logic

/**
 * Get a list of codes for languages to show in
 * the "Common languages" section of the ULS.
 * The list consists of the user's current selected language,
 * the wiki's content language, the browser' UI language
 * and Accept-Language, user's previous selected languages
 * and finally, the languages of countryCode taken from the CLDR,
 * taken by default from the user's geolocation.
 *
 * @param {string} [countryCode] Uppercase country code.
 * @return {Array} List of language codes without duplicates.
 */
mw.uls.getFrequentLanguageList = function ( countryCode ) {
	const ret = [],
		lists = [
			[
				mw.config.get( 'wgUserLanguage' ),
				mw.config.get( 'wgContentLanguage' ),
				mw.uls.getBrowserLanguage()
			],
			mw.uls.getPreviousLanguages(),
			mw.uls.getAcceptLanguageList()
		];

	countryCode = countryCode || mw.uls.getCountryCode();
	if ( countryCode ) {
		lists.push( $.uls.data.getLanguagesInTerritory( countryCode ) );
	}
        ....
}
abi_ changed the task status from Open to In Progress.Feb 18 2026, 5:02 PM
abi_ claimed this task.
abi_ moved this task from Backlog to In progress on the LPL Projects (ULS rewrite) board.
abi_ moved this task from Backlog to In Progress on the LPL Essential (FY2025-26 Q3&4) board.

Change #1239999 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/UniversalLanguageSelector@master] ULS rewrite: Display supported languages

https://gerrit.wikimedia.org/r/1239999

The current ULS uses the following logic

/**
 * Get a list of codes for languages to show in
 * the "Common languages" section of the ULS.
 * The list consists of the user's current selected language,
 * the wiki's content language, the browser' UI language
 * and Accept-Language, user's previous selected languages
 * and finally, the languages of countryCode taken from the CLDR,
 * taken by default from the user's geolocation.
 *
 * @param {string} [countryCode] Uppercase country code.
 * @return {Array} List of language codes without duplicates.
 */
mw.uls.getFrequentLanguageList = function ( countryCode ) {
	const ret = [],
		lists = [
			[
				mw.config.get( 'wgUserLanguage' ),
				mw.config.get( 'wgContentLanguage' ),
				mw.uls.getBrowserLanguage()
			],
			mw.uls.getPreviousLanguages(),
			mw.uls.getAcceptLanguageList()
		];

	countryCode = countryCode || mw.uls.getCountryCode();
	if ( countryCode ) {
		lists.push( $.uls.data.getLanguagesInTerritory( countryCode ) );
	}
        ....
}

The current implementation includes everything mentioned above minus the languages in user territory. We can add that once we've included language data library.

Change #1239999 merged by jenkins-bot:

[mediawiki/extensions/UniversalLanguageSelector@master] ULS rewrite: Display suggested languages

https://gerrit.wikimedia.org/r/1239999

Here's how suggested languages are currently displayed:

  1. previously selected languages
  2. user language (wgUserLanguage)
  3. current wiki content language (wgContentLanguage)
  4. browser language
  5. accept language (wgULSAcceptLanguageList)

All items from the task are done. I'll create a separate task to also add languages based on the region into the list of suggestions