diff --git a/includes/LanguageData.php b/includes/LanguageData.php index 8a7354b15..60c9b1280 100644 --- a/includes/LanguageData.php +++ b/includes/LanguageData.php @@ -71,10 +71,12 @@ class LanguageData { // ApiQuerySiteinfo $data['localTimezone'] = $config->get( 'Localtimezone' ); - $data['specialContributionsName'] = $this->specialPageFactory - ->getLocalNameFor( 'Contributions' ); - $data['specialNewSectionName'] = $this->specialPageFactory - ->getLocalNameFor( 'NewSection' ); + // special page names compared against Title::getText, which contains space + // But aliases are stored with underscores (db key) in the alias files + $data['specialContributionsName'] = str_replace( '_', ' ', $this->specialPageFactory + ->getLocalNameFor( 'Contributions' ) ); + $data['specialNewSectionName'] = str_replace( '_', ' ', $this->specialPageFactory + ->getLocalNameFor( 'NewSection' ) ); $localTimezone = $config->get( 'Localtimezone' ); // Return all timezone abbreviations for the local timezone (there will often be two, for diff --git a/tests/cases/comments.json b/tests/cases/comments.json index cd4dc5265..98424a6ff 100644 --- a/tests/cases/comments.json +++ b/tests/cases/comments.json @@ -230,5 +230,13 @@ "expected": "../cases/timestamp-format-switch/timestamp-format-switch.json", "config": "../data/enwiki-config.json", "data": "../data/enwiki-data.json" + }, + { + "name": "Signatures with Special:Contributions (alias with underscored)", + "title": "Talk:Signatures Alias", + "dom": "cases/signatures-comments/signatures-contribs-alias-underscore.html", + "expected": "../cases/signatures-comments/signatures-contribs-alias-underscore.json", + "config": "../data/huwiki-config.json", + "data": "../data/huwiki-data.json" } ] diff --git a/tests/cases/datatest-ckb.json b/tests/cases/datatest-ckb.json index 753344a92..1b9332e94 100644 --- a/tests/cases/datatest-ckb.json +++ b/tests/cases/datatest-ckb.json @@ -17,7 +17,7 @@ ] }, "localTimezone": "UTC", - "specialContributionsName": "Contributions", + "specialContributionsName": "بەشدارییەکان", "specialNewSectionName": "NewSection", "timezones": { "ckb": { diff --git a/tests/cases/datatest-hu.json b/tests/cases/datatest-hu.json new file mode 100644 index 000000000..fd56b68c6 --- /dev/null +++ b/tests/cases/datatest-hu.json @@ -0,0 +1,81 @@ +{ + "dateFormat": { + "hu": "Y. F j., H:i" + }, + "digits": { + "hu": [ + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9" + ] + }, + "localTimezone": "UTC", + "specialContributionsName": "Szerkesztő közreműködései", + "specialNewSectionName": "NewSection", + "timezones": { + "hu": { + "UTC": "UTC" + } + }, + "contLangMessages": { + "hu": { + "sunday": "vasárnap", + "monday": "hétfő", + "tuesday": "kedd", + "wednesday": "szerda", + "thursday": "csütörtök", + "friday": "péntek", + "saturday": "szombat", + "sun": "vas", + "mon": "hét", + "tue": "kedd", + "wed": "sze", + "thu": "csü", + "fri": "pén", + "sat": "szo", + "january": "január", + "february": "február", + "march": "március", + "april": "április", + "may_long": "május", + "june": "június", + "july": "július", + "august": "augusztus", + "september": "szeptember", + "october": "október", + "november": "november", + "december": "december", + "january-gen": "január", + "february-gen": "február", + "march-gen": "március", + "april-gen": "április", + "may-gen": "május", + "june-gen": "június", + "july-gen": "július", + "august-gen": "augusztus", + "september-gen": "szeptember", + "october-gen": "október", + "november-gen": "november", + "december-gen": "december", + "jan": "jan", + "feb": "febr", + "mar": "márc", + "apr": "ápr", + "may": "máj", + "jun": "jún", + "jul": "júl", + "aug": "aug", + "sep": "szept", + "oct": "okt", + "nov": "nov", + "dec": "dec" + } + } +} diff --git a/tests/cases/datatest-sr.json b/tests/cases/datatest-sr.json index db993c5cc..fc89efd31 100644 --- a/tests/cases/datatest-sr.json +++ b/tests/cases/datatest-sr.json @@ -43,8 +43,8 @@ ] }, "localTimezone": "UTC", - "specialContributionsName": "Contributions", - "specialNewSectionName": "NewSection", + "specialContributionsName": "Доприноси", + "specialNewSectionName": "Нови одељак", "timezones": { "sr": { "UTC": "UTC" diff --git a/tests/cases/datatest-th.json b/tests/cases/datatest-th.json index 0612f691a..89f7e869e 100644 --- a/tests/cases/datatest-th.json +++ b/tests/cases/datatest-th.json @@ -17,7 +17,7 @@ ] }, "localTimezone": "Asia/Bangkok", - "specialContributionsName": "Contributions", + "specialContributionsName": "เรื่องที่เขียน", "specialNewSectionName": "NewSection", "timezones": { "th": { diff --git a/tests/cases/signatures-comments/signatures-contribs-alias-underscore.html b/tests/cases/signatures-comments/signatures-contribs-alias-underscore.html new file mode 100644 index 000000000..f981be40e --- /dev/null +++ b/tests/cases/signatures-comments/signatures-contribs-alias-underscore.html @@ -0,0 +1,4 @@ +

test

+

Hello 127.0.0.1 2023. január 13., 10:25 (CET) +

+
Answer Lower cased 2023. január 13., 12:25 (CET)
diff --git a/tests/cases/signatures-comments/signatures-contribs-alias-underscore.json b/tests/cases/signatures-comments/signatures-contribs-alias-underscore.json new file mode 100644 index 000000000..31a65659a --- /dev/null +++ b/tests/cases/signatures-comments/signatures-contribs-alias-underscore.json @@ -0,0 +1,58 @@ +[ + { + "placeholderHeading": false, + "type": "heading", + "range": [ + "0/0/0", + "0/0/1" + ], + "headingLevel": 2, + "level": 0, + "name": "h-127.0.0.1-20230113092500", + "id": "h-test-20230113092500", + "warnings": [], + "replies": [ + { + "type": "comment", + "timestamp": "20230113092500", + "author": "127.0.0.1", + "range": [ + "2/0", + "2/2/30" + ], + "signatureRanges": [ + [ + "2/1", + "2/2/30" + ] + ], + "level": 1, + "name": "c-127.0.0.1-20230113092500", + "id": "c-127.0.0.1-20230113092500-test", + "warnings": [], + "replies": [ + { + "type": "comment", + "timestamp": "20230113112500", + "author": "Lower cased", + "range": [ + "4/0/0", + "4/0/2/30" + ], + "signatureRanges": [ + [ + "4/0/1", + "4/0/2/30" + ] + ], + "level": 2, + "name": "c-Lower_cased-20230113112500", + "id": "c-Lower_cased-20230113112500-127.0.0.1-20230113092500", + "warnings": [], + "replies": [] + } + ] + } + ] + } +] diff --git a/tests/data/huwiki-data.json b/tests/data/huwiki-data.json index ec6ca04bb..3862c05a7 100644 --- a/tests/data/huwiki-data.json +++ b/tests/data/huwiki-data.json @@ -17,7 +17,7 @@ ] }, "localTimezone": "Europe/Berlin", - "specialContributionsName": "Szerkesztő_közreműködései", + "specialContributionsName": "Szerkesztő közreműködései", "timezones": { "hu": { "CEMT": "CEMT", diff --git a/tests/phpunit/LanguageDataTest.php b/tests/phpunit/LanguageDataTest.php index e08bba6d1..801951756 100644 --- a/tests/phpunit/LanguageDataTest.php +++ b/tests/phpunit/LanguageDataTest.php @@ -3,6 +3,7 @@ namespace MediaWiki\Extension\DiscussionTools\Tests; use MediaWiki\Extension\DiscussionTools\LanguageData; +use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; /** @@ -15,10 +16,10 @@ class LanguageDataTest extends IntegrationTestCase { */ public function testGetLocalData( string $langCode, array $config, string $expectedPath ): void { $config += [ - 'ContentLanguage' => $langCode, - 'UsePigLatinVariant' => false, - 'TranslateNumerals' => true, - 'Localtimezone' => 'UTC', + MainConfigNames::LanguageCode => $langCode, + MainConfigNames::UsePigLatinVariant => false, + MainConfigNames::TranslateNumerals => true, + MainConfigNames::Localtimezone => 'UTC', ]; $this->overrideConfigValues( $config ); @@ -27,7 +28,7 @@ class LanguageDataTest extends IntegrationTestCase { $services = MediaWikiServices::getInstance(); $languageData = new LanguageData( $services->getMainConfig(), - $services->getLanguageFactory()->getLanguage( $langCode ), + $services->getContentLanguage(), $services->getLanguageConverterFactory(), $services->getSpecialPageFactory() ); @@ -51,7 +52,9 @@ class LanguageDataTest extends IntegrationTestCase { // Has localised digits (T261706) [ 'ckb', [], '../cases/datatest-ckb.json' ], // Has unusual timezone abbreviation (T265500) - [ 'th', [ 'Localtimezone' => 'Asia/Bangkok' ], '../cases/datatest-th.json' ], + [ 'th', [ MainConfigNames::Localtimezone => 'Asia/Bangkok' ], '../cases/datatest-th.json' ], + // Special page alias with underscores (T327021) + [ 'hu', [], '../cases/datatest-hu.json' ], ]; }