Page MenuHomePhabricator

Separate Language static methods/members into service(s)
Closed, ResolvedPublic

Description

One service we would want is LanguageFactory to replace Language::factory(). Two questions:

  1. Do we want to put all the other static methods on LanguageFactory, or put them in a separate service? The name suggests that it's to make Language objects, not a collection of generic Language-related methods. SpecialPageFactory does have lots of other special-page-related methods.
  1. Some of the static methods are unlikely to ever need to track state, such as isWellFormedLanguageTag(). Is it okay to leave these static? I would figure that we may as well make them instance methods as well, in case at some future date they incorporate state like caching, but it seems a bit excessive to force dependency on a service just for that.

Details

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 7 2018, 11:58 AM
Legoktm added subscribers: Nikerabbit, TTO.

Just FYI there's also a new LanguageCode class that has some static methods related to validating language codes, I'm not sure whether isWellFormedLanguageTag() (I haven't looked at the method yet, just guessing based on the name) would belong there.

Legoktm added a subscriber: Fomafix.Aug 7 2018, 4:13 PM
CCicalese_WMF removed Simetrical as the assignee of this task.Aug 14 2018, 2:04 AM
CCicalese_WMF triaged this task as Low priority.
CCicalese_WMF moved this task from Inbox to CPT TEC13 Backlog on the Core-Platform-Team-Old board.

Change 450996 had a related patch set uploaded (by simetrical; owner: simetrical):
[mediawiki/core@master] Split Language static methods into LanguageFactory

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

Change 450996 abandoned by simetrical:
Split Language static methods into LanguageFactory

Reason:
This needs to be redone completely as a few separate services, as discussed.

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

Change 450996 restored by simetrical:
Split Language static methods into LanguageFactory

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

Change 532679 had a related patch set uploaded (by simetrical; owner: simetrical):
[mediawiki/core@master] Make LocalisationCache a service

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

Change 532680 had a related patch set uploaded (by simetrical; owner: simetrical):
[mediawiki/core@master] Split some Language methods to LanguageNameUtils

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

Change 532232 had a related patch set uploaded (by simetrical; owner: simetrical):
[mediawiki/core@master] New LanguageFallback service

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

Change 532240 had a related patch set uploaded (by simetrical; owner: simetrical):
[mediawiki/core@master] Inject grammar transform cache in Language

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

Change 532369 had a related patch set uploaded (by Daniel Kinzler; owner: simetrical):
[mediawiki/core@master] Remove Language::factory and getParentLanguage use

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

Change 532241 had a related patch set uploaded (by Daniel Kinzler; owner: simetrical):
[mediawiki/core@master] Cache nonexistence of grammar transformations

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

daniel raised the priority of this task from Low to High.EditedSep 30 2019, 9:03 PM
daniel added a project: MW-1.34-release.

Bumped to high, since this blocks T231866: Circular dependency when creating service! ContentLanguage, which we should fix for 1.34

Change 532679 merged by jenkins-bot:
[mediawiki/core@master] Make LocalisationCache a service

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

Change 541624 had a related patch set uploaded (by Jforrester; owner: simetrical):
[mediawiki/core@REL1_34] Make LocalisationCache a service

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

Change 541624 merged by jenkins-bot:
[mediawiki/core@REL1_34] Make LocalisationCache a service

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

Change 532680 merged by jenkins-bot:
[mediawiki/core@master] Split some Language methods to LanguageNameUtils

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

Change 541650 had a related patch set uploaded (by Ppchelko; owner: simetrical):
[mediawiki/core@REL1_34] Split some Language methods to LanguageNameUtils

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

Change 532232 merged by jenkins-bot:
[mediawiki/core@master] New LanguageFallback service

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

Change 532240 merged by jenkins-bot:
[mediawiki/core@master] Make grammar transform cache an instance member

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

Change 541650 merged by jenkins-bot:
[mediawiki/core@REL1_34] Split some Language methods to LanguageNameUtils

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

Change 450996 merged by jenkins-bot:
[mediawiki/core@master] LanguageFactory to replace Language::factory()

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

Remaining non-deprecated public static methods on Language:

  • isWellFormedLanguageTag()
  • getCodeFromFileName()
  • getMessagesFor()
  • getMessageFor()
  • getMessageKeysFor()

The getMessage() ones call the deprecated method getLocalisationCache(), and should just be deprecated. The other two are simple pure methods that are unlikely to ever need state unless we need to add caching, at which point we could move them someplace else if we want.

I think this can be resolved as soon as the getMessage*For() methods are deprecated.

Change 546670 had a related patch set uploaded (by simetrical; owner: simetrical):
[mediawiki/core@master] Deprecate Language::getMessage*For()

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

Change 546670 merged by jenkins-bot:
[mediawiki/core@master] Deprecate Language::getMessage*For()

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

Simetrical closed this task as Resolved.Tue, Oct 29, 10:21 AM
Simetrical claimed this task.