aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/languages/LanguageFiTest.php
Commit message (Collapse)AuthorAgeFilesLines
* language: fix mw.language.convertGrammar with word-specific casing rulesMáté Szabó2025-03-101-0/+40
Why: - mw.language.convertGrammar is responsible for implementing grammatical transformations for inflected languages, similar to its backend counterpart Language::convertGrammar. - The default implementation may be overridden by language-specific implementations loaded dynamically based on the user language. - Both the default implementation and all language-specific implementations suffer from a bug where requesting a case transformation for which word-specific casing rules are defined will return "undefined" if the case transformation was requested for a word for which no word-specific casing rule exists. - There are QUnit tests for the logic, but they only run if the user language matches the language being tested. This means they never run in CI and cannot even be run locally, since Special:JavaScriptTest has been forcing the user language to "qqx" for more than five years. What: - Place language-specific convertGrammar overrides into a new convertGrammarMapping property keyed by language code to allow loading more than one simultaneously. - Introduce and use a new 'mediawiki.language.grammar.testdata' test-only RL module that loads every language-specific convertGrammar override. - Introduce and use a new 'mediawiki.language.testdata' test-only RL module that loads language-specific rules for languages that we have QUnit tests for. Since this only covers less than two dozen languages, there'd be no value in loading this data for all 300+ languages supported by MediaWiki. - Update QUnit tests for convertGrammar to override the user language and language rules before each case. - Ensure word-specific casing rules always take precedence over language-specific convertGrammar implementations to avoid repeated boilerplate in language-specific code. - Don't attempt to use word-specific casing rules for words that do not have one. - As we're here, add matching PHPUnit tests for Language* subclasses that had preexisting QUnit tests but no PHPUnit tests. Bug: T388370 Change-Id: I3f2432f5f801c2a7e4390c2ff2038363a36e2ed9