Page MenuHomePhabricator

Make language list injectable throughout frontend
Closed, ResolvedPublic

Description

Currently, the language list is fetched from ULS. We need to introduce an own service which we pass around. The initial implementation should just use ULS.

Event Timeline

I think it makes sense to do T75380 before this, since we again need to inject a service into ValueView.

Current users of language data I found:

  • ValueView needs language codes and names.
  • wikibase.Site (used by jquery.wikibase.linkitem and jquery.wikibase.sitelinkview) needs dir
  • getDirectionality (used by aliasview, descriptionview, labelview) needs dir
  • Special pages need language codes and names
  • getLanguageNameByCode (used by descriptionview, entitytermsforlanguagelistview, entitytermsforlanguageview, entityview, labelview) needs language codes and names

I would try to replace the usages in getLanguageNameByCode, getDirectionality and ValueView with the new service as a a start.

interface ContentLanguages
  getName( code )
  getAll()

class UlsBasedContentLanguages: ContentLanguages
  getName( code ) = getAll()[ code ]
  getAll() =  mw.config.get( 'wgULSLanguages' )

@thiemowmde @Snaterlicious What do you think about the interface? What do you think about doing T75380?

@Lydia_Pintscher @Tobi_WMDE_SW Are you ok with pulling T75380 into the sprint?

I think getAll should return an array of language codes, not codes and some names:

interface utils.ContentLanguages
  getName( code )
  getAll()

class UlsBasedContentLanguages: ContentLanguages
  getName( code ) = mw.config.get( 'wgULSLanguages' )[ code ]
  getAll() =  Object.keys(mw.config.get( 'wgULSLanguages' ))

That way it's easier to add more information to ContentLanguages, for example direction or names in different languages.

gerritbot subscribed.

Change 186229 had a related patch set uploaded (by Adrian Lang):
Pass ContentLanguages instance using ULS to ValueView

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

Patch-For-Review

We don't need T75380 for this, since we already have a ValueViewBuilder that's passed through all views.

Change 186229 merged by jenkins-bot:
Pass ContentLanguages instance using ULS to ValueView

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