Introduce LanguageConverterFactory, to be injected into Language instances, when they are created by LanguageFactory. Introduce a new interface that exposes the methods in Language that are needed by LanguageConverterFactory.
Objective:
- Remove dependency of Language on Title (eventually - this is just a small step in that direction)
- Resolve circular dependency between Language and LanguageConverter
- Improve separation of concerns by removing remaining knowledge about language conversion from Language subclasses
- Remove the need for Language subclasses to exist just to instantiate the correct LanguageConverter.
Caveat:
- Find a way to resolve the chicken-and-egg issue we have when instantiating a Language object and a LanguageConverter object.
Acceptance criteria:
- Replace and remove Language::newConverter()
- Move the knowledge encoded in the various implementations of newConverter() into the respective LanguageConverter subclasses
- Remove $variants, $variantFallback, and similar parameters from the constructor signature of LanguageConverter, hard-coding the values insead.
- Create LanguageConverterFactory, managed by MediaWikiServices.
- Hard-code a mapping from language code to LanguageConverter subclass in LanguageConverterFactory.
- Make the LanguageConverter base class abstract.
Outlook:
Code that uses methods of Language that just delegate to LanguageConverter should use a LanguageConverter service directly. The respective methods in Language can then be deprecated. Eventually, this should remove the need for Language to know a LanguageConverter.