Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/250398
Change subject: Introduce constant for canonical English in TimeParserFactory ...................................................................... Introduce constant for canonical English in TimeParserFactory This is split from I124b4ae. Change-Id: I4ac7190ef2de8232752773e4b0523e6d2e79cda1 --- M repo/includes/Parsers/MediaWikiMonthNameProvider.php M repo/includes/Parsers/MonthNameProvider.php M repo/includes/Parsers/TimeParserFactory.php 3 files changed, 18 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/98/250398/1 diff --git a/repo/includes/Parsers/MediaWikiMonthNameProvider.php b/repo/includes/Parsers/MediaWikiMonthNameProvider.php index a0fdd48..5ff6ce1 100644 --- a/repo/includes/Parsers/MediaWikiMonthNameProvider.php +++ b/repo/includes/Parsers/MediaWikiMonthNameProvider.php @@ -40,14 +40,14 @@ * @see MonthNameProvider::getMonthNameReplacements * * @param string $languageCode - * @param string $baseLanguageCode + * @param string $canonicalLanguageCode * * @return string[] Array mapping localized month names (including full month names, genitive - * names and abbreviations) to the same month names in canonical English. + * names and abbreviations) to the same month names in a canonical language (usually English). */ - public function getMonthNameReplacements( $languageCode, $baseLanguageCode = 'en' ) { + public function getMonthNameReplacements( $languageCode, $canonicalLanguageCode = 'en' ) { $language = Language::factory( $languageCode ); - $baseLanguage = Language::factory( $baseLanguageCode ); + $baseLanguage = Language::factory( $canonicalLanguageCode ); $replacements = array(); diff --git a/repo/includes/Parsers/MonthNameProvider.php b/repo/includes/Parsers/MonthNameProvider.php index eee6456..e4a3786 100644 --- a/repo/includes/Parsers/MonthNameProvider.php +++ b/repo/includes/Parsers/MonthNameProvider.php @@ -19,12 +19,12 @@ /** * @param string $languageCode - * @param string $baseLanguageCode + * @param string $canonicalLanguageCode * * @return string[] Array mapping localized month names (possibly including full month names, - * genitive names and abbreviations) to the same month names in a base language (usually - * canonical English). + * genitive names and abbreviations) to the same month names in a canonical language (usually + * English). */ - public function getMonthNameReplacements( $languageCode, $baseLanguageCode = 'en' ); + public function getMonthNameReplacements( $languageCode, $canonicalLanguageCode = 'en' ); } diff --git a/repo/includes/Parsers/TimeParserFactory.php b/repo/includes/Parsers/TimeParserFactory.php index dd4abe6..88e2219 100644 --- a/repo/includes/Parsers/TimeParserFactory.php +++ b/repo/includes/Parsers/TimeParserFactory.php @@ -23,6 +23,8 @@ */ class TimeParserFactory { + const CANONICAL_LANGUAGE_CODE = 'en'; + /** * @var ParserOptions */ @@ -44,7 +46,7 @@ $this->options = $options ?: new ParserOptions(); $this->monthNameProvider = $monthNameProvider ?: new MediaWikiMonthNameProvider(); - $this->options->defaultOption( ValueParser::OPT_LANG, 'en' ); + $this->options->defaultOption( ValueParser::OPT_LANG, self::CANONICAL_LANGUAGE_CODE ); } @@ -88,12 +90,14 @@ */ public function getMonthNameUnlocalizer() { $languageCode = $this->options->getOption( ValueParser::OPT_LANG ); - $baseLanguageCode = 'en'; - $replacements = array(); - - if ( $languageCode !== $baseLanguageCode ) { - $replacements = $this->monthNameProvider->getMonthNameReplacements( $languageCode, $baseLanguageCode ); + if ( $languageCode === self::CANONICAL_LANGUAGE_CODE ) { + $replacements = array(); + } else { + $replacements = $this->monthNameProvider->getMonthNameReplacements( + $languageCode, + self::CANONICAL_LANGUAGE_CODE + ); } return new MonthNameUnlocalizer( $replacements ); -- To view, visit https://gerrit.wikimedia.org/r/250398 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4ac7190ef2de8232752773e4b0523e6d2e79cda1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits