Page MenuHomePhabricator

Stop injecting LanguageNameLookup into WikibaseValueFormatterBuilders
Open, Needs TriagePublic


Currently, we inject the LanguageNameLookup service into the WikibaseValueFormatterBuilders class (WikibaseRepo.DefaultValueFormatterBuilders service). Since that service is deprecated, we should avoid that.

I think one option would be to use the LanguageNameLookupFactory service introduced in T281712. Most (all?) of the WikibaseValueFormatterBuilders methods take a FormatterOptions argument, which should(?) contain a language option (ValueFormatter::OPT_LANG); if we inject a language name lookup factory into the formatter builders, then each time we actually build a specific formatter from a set of options, we can use that factory to create a specific language name lookup.

That said, I’m not sure that the options actually contain a language each time. I suggest something like this (sketch code):

private function getLanguageNameLookup( FormatterOptions $options ) {
	if ( $options->hasOption( ValueFormatters::OPT_LANG ) ) {
		return $this->languageNameLookupFactory->getForLanguageCode( $options->getOption( ValueFormatters::OPT_LANG ) );
	} else {
		// TODO wfDeprecated() probably?
		return $this->languageNameLookupFactory->getForLanguage( WikibaseRepo::getUserLanguage() );