Page MenuHomePhabricator

Librarize language-specific text transformations
Open, In Progress, Needs TriagePublic

Description

Description

The goal of this task is to librarize language-specific text transformation—such as pluralization, grammatical adjustments, gender-based selection, and bidirectional formatting—into dedicated handlers within the Leximorph library.

Next Steps:

  • Create a patch for the core library under the includes/libs/Leximorph
  • Create a feature flag configuration
  • Create LeximorphFactory for Manager and Provider
  • Integrate UseLeximorph flag into CoreParserFunctions.php
  • Integrate UseLeximorph flag into Language.php
  • Integrate UseLeximorph flag into LocalisationCache.php
  • Update relevant extensions using text transformations
  • Enable and run feature-flagged tests on translatewiki.net (T402009)
  • Announce on wikitech-l and in Tech News
  • Create separate Leximorph library (T390289)

Event Timeline

Change #1128045 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] Modularize language-specific text transformations

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

Dogu changed the task status from Open to In Progress.Mar 18 2025, 11:15 PM
Dogu claimed this task.
Dogu renamed this task from Modularize language-specific text transformations to Librarize language-specific text transformations.Mar 24 2025, 10:46 PM
Dogu updated the task description. (Show Details)

Change #1132203 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] Librarize language-specific text transformations

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

Change #1132203 abandoned by Abaris:

[mediawiki/core@master] Librarize language-specific text transformations

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

Change #1128045 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] Librarize language-specific text transformations

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

Change #1132203 restored by Abaris:

[mediawiki/core@master] Librarize language-specific text transformations

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

Change #1176757 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] Create Leximorph lib for language-specific text transformations

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

Change #1176803 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] Introduce UseLeximorph feature flag

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

Change #1176804 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] Integrate UseLeximorph flag into CoreParserFunctions

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

Change #1178494 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] Integrate UseLeximorph flag into Language

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

Change #1176757 merged by jenkins-bot:

[mediawiki/core@master] Create Leximorph lib for language-specific text transformations

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

Change #1176803 merged by jenkins-bot:

[mediawiki/core@master] config: Introduce UseLeximorph feature flag

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

Dogu updated the task description. (Show Details)

Change #1178992 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] includes/libs/Leximorph: Validate fallback nodes and log warnings

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

Change #1178920 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] includes/libs/Leximorph: Support override forms in Grammar

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

Change #1128383 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/extensions/Translate@master] scripts/plural-comparison.php: Use Leximorph provider with feature flag

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

Change #1131864 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/extensions/cldr@master] Hooks: Use Leximorph provider with feature flag

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

Change #1179130 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] includes/language/LocalisationCache: Use Leximorph with feature flag

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

Change #1179186 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] services: Introduce LeximorphFactory for Manager and Provider

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

Dogu updated the task description. (Show Details)

Change #1182953 had a related patch set uploaded (by Abaris; author: Abaris):

[mediawiki/core@master] includes/libs/Leximorph/Manager: Share single Provider and logger

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

Change #1179186 merged by jenkins-bot:

[mediawiki/core@master] services: Introduce LeximorphFactory for Manager and Provider

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

@Dogu great meeting last week to learn more about this work and congratulations for the progress made so far. As part of the follow ups after this meeting, I spoke with a couple of engineers including Jdforrester-WMF to better understand this work. My understanding is this part of work is part of the long-term (2014+) work to[[ https://www.mediawiki.org/wiki/Library_infrastructure_for_MediaWiki to move tight code like this out of MediaWiki core and into libraries, ]] and this particular piece of work might have originated with a different change to provide a PHP-equivalence library for Vue code. I also understand there is a Phabricator board of these pieces of work, and this task comes under the T227447: Librarize i18n-related PHP classes in MediaWiki task, which I see is now linked as a parent task.

In particular, as a follow up, I am interested to learn more on the scope of the planned work and the anticipated impact on language onboarding which entails adding and removing languages , Plural support, Keyboard support, Fall back among other areas, just so the expectations are clear early on. is there documentation that details the scope of the planned work that can be shared and anticipated changes?

Hey @MaryMunyoki, I don't yet have a formal future plan, with several patches awaiting review and merge I paused further changes, and once they land I will draft and share the concrete next steps.

Hey @MaryMunyoki, I don't yet have a formal future plan, with several patches awaiting review and merge I paused further changes, and once they land I will draft and share the concrete next steps.

Sure, but I think we need a rough outline of the overall direction here (so we know when we're "Done", but also so other things can happen alongside). Can you put down some draft bullets of your thoughts here so we can move forward?

Change #1178920 merged by jenkins-bot:

[mediawiki/core@master] includes/libs/Leximorph/Handler/Grammar: Support override forms

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

Change #1178992 merged by jenkins-bot:

[mediawiki/core@master] includes/libs/Leximorph: Validate fallback nodes and log warnings

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

Change #1128045 abandoned by Abaris:

[mediawiki/core@master] [PoC] Librarize language-specific text transformations

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

Change #1178494 abandoned by Abaris:

[mediawiki/core@master] includes/language/Language: Use Leximorph with feature flag

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

Change #1176804 abandoned by Abaris:

[mediawiki/core@master] includes/parser/CoreParserFunctions: Use Leximorph with feature flag

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