Liangent has uploaded a new change for review. https://gerrit.wikimedia.org/r/72053
Change subject: (bug 43547) New language variant en-x-piglatin DO NOT MERGE ...................................................................... (bug 43547) New language variant en-x-piglatin DO NOT MERGE Bug: 43547 Change-Id: I7fa2d85d6364958c5138366e8b4504a2697a8731 --- M includes/DefaultSettings.php M languages/Language.php A languages/classes/LanguageEn.php 3 files changed, 72 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/53/72053/1 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index f9d280f..5713063 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2451,7 +2451,7 @@ * $wgDisabledVariants[] = 'zh-my'; * @endcode */ -$wgDisabledVariants = array(); +$wgDisabledVariants = array( 'en-x-piglatin' ); /** * Like $wgArticlePath, but on multi-variant wikis, this provides a diff --git a/languages/Language.php b/languages/Language.php index e5cab05..b6d143e 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -409,11 +409,7 @@ * @return String Name of the language class */ public static function classFromCode( $code ) { - if ( $code == 'en' ) { - return 'Language'; - } else { - return 'Language' . str_replace( '-', '_', ucfirst( $code ) ); - } + return 'Language' . str_replace( '-', '_', ucfirst( $code ) ); } /** diff --git a/languages/classes/LanguageEn.php b/languages/classes/LanguageEn.php new file mode 100644 index 0000000..c3d13a0 --- /dev/null +++ b/languages/classes/LanguageEn.php @@ -0,0 +1,70 @@ +<?php +/** + * English specific code. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup Language + */ + +require_once __DIR__ . '/../LanguageConverter.php'; + +class EnConverter extends LanguageConverter { + + function loadDefaultTables() { + $this->mTables = array( + 'en' => new ReplacementArray(), + 'en-x-piglatin' => new ReplacementArray(), + ); + } + + /** + * It translates text into Pig Latin. + * + * @param $text string + * @param $toVariant string + * + * @throws MWException + * @return string + */ + function translate( $text, $toVariant ) { + if ( $toVariant === 'en-x-piglatin' ) { + return '!PigLatin^' . strtoupper( $text ) . '^PigLatin!'; + } else { + return $text; + } + } + +} + +/** + * English + * + * @ingroup Language + */ +class LanguageEn extends Language { + + function __construct() { + global $wgHooks; + + parent::__construct(); + + $this->mConverter = new EnConverter( $this, 'en', array( 'en', 'en-x-piglatin' ) ); + $wgHooks['PageContentSaveComplete'][] = $this->mConverter; + } + +} -- To view, visit https://gerrit.wikimedia.org/r/72053 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7fa2d85d6364958c5138366e8b4504a2697a8731 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Liangent <liang...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits