Revision split __construct method
[mediawiki.git] / languages / FakeConverter.php
blob22377c28be1b3677c051d6403d59606a37e2a2b8
1 <?php
2 /**
3 * Internationalisation code.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Language
24 /**
25 * A fake language variant converter. Languages which do not implement variant
26 * conversion, for example, English, should return a FakeConverter rather than a
27 * LanguageConverter when asked for their converter. The fake converter just
28 * returns text unchanged, i.e. it doesn't do any conversion.
30 * See https://www.mediawiki.org/wiki/Writing_systems#LanguageConverter.
32 * @ingroup Language
34 class FakeConverter {
35 /**
36 * @var Language
38 public $mLang;
40 function __construct( $langobj ) {
41 $this->mLang = $langobj;
44 function autoConvert( $text, $variant = false ) {
45 return $text;
48 function autoConvertToAllVariants( $text ) {
49 return [ $this->mLang->getCode() => $text ];
52 function convert( $t ) {
53 return $t;
56 function convertTo( $text, $variant ) {
57 return $text;
60 /**
61 * @param Title $t
62 * @return mixed
64 function convertTitle( $t ) {
65 return $t->getPrefixedText();
68 function convertNamespace( $ns ) {
69 return $this->mLang->getFormattedNsText( $ns );
72 /**
73 * @return string[]
75 function getVariants() {
76 return [ $this->mLang->getCode() ];
79 function getVariantFallbacks( $variant ) {
80 return $this->mLang->getCode();
83 function getPreferredVariant() {
84 return $this->mLang->getCode();
87 function getDefaultVariant() {
88 return $this->mLang->getCode();
91 function getURLVariant() {
92 return '';
95 function getConvRuleTitle() {
96 return false;
99 function findVariantLink( &$l, &$n, $ignoreOtherCond = false ) {
102 function getExtraHashOptions() {
103 return '';
106 function getParsedTitle() {
107 return '';
110 function markNoConversion( $text, $noParse = false ) {
111 return $text;
114 function convertCategoryKey( $key ) {
115 return $key;
118 function validateVariant( $variant = null ) {
119 return $variant === $this->mLang->getCode() ? $variant : null;
122 function translate( $text, $variant ) {
123 return $text;
126 public function updateConversionTable( Title $title ) {
130 * Used by test suites which need to reset the converter state.
132 * @private
134 private function reloadTables() {