]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - languages/FakeConverter.php
MediaWiki 1.30.2 renames
[autoinstalls/mediawiki.git] / languages / FakeConverter.php
1 <?php
2 /**
3  * Internationalisation code.
4  *
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.
9  *
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.
14  *
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
19  *
20  * @file
21  * @ingroup Language
22  */
23
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.
29  *
30  * See https://www.mediawiki.org/wiki/Writing_systems#LanguageConverter.
31  *
32  * @ingroup Language
33  */
34 class FakeConverter {
35         /**
36          * @var Language
37          */
38         public $mLang;
39
40         function __construct( $langobj ) {
41                 $this->mLang = $langobj;
42         }
43
44         function autoConvert( $text, $variant = false ) {
45                 return $text;
46         }
47
48         function autoConvertToAllVariants( $text ) {
49                 return [ $this->mLang->getCode() => $text ];
50         }
51
52         function convert( $t ) {
53                 return $t;
54         }
55
56         function convertTo( $text, $variant ) {
57                 return $text;
58         }
59
60         /**
61          * @param Title $t
62          * @return mixed
63          */
64         function convertTitle( $t ) {
65                 return $t->getPrefixedText();
66         }
67
68         function convertNamespace( $ns ) {
69                 return $this->mLang->getFormattedNsText( $ns );
70         }
71
72         /**
73          * @return string[]
74          */
75         function getVariants() {
76                 return [ $this->mLang->getCode() ];
77         }
78
79         function getVariantFallbacks( $variant ) {
80                 return $this->mLang->getCode();
81         }
82
83         function getPreferredVariant() {
84                 return $this->mLang->getCode();
85         }
86
87         function getDefaultVariant() {
88                 return $this->mLang->getCode();
89         }
90
91         function getURLVariant() {
92                 return '';
93         }
94
95         function getConvRuleTitle() {
96                 return false;
97         }
98
99         function findVariantLink( &$l, &$n, $ignoreOtherCond = false ) {
100         }
101
102         function getExtraHashOptions() {
103                 return '';
104         }
105
106         function getParsedTitle() {
107                 return '';
108         }
109
110         function markNoConversion( $text, $noParse = false ) {
111                 return $text;
112         }
113
114         function convertCategoryKey( $key ) {
115                 return $key;
116         }
117
118         function validateVariant( $variant = null ) {
119                 return $variant === $this->mLang->getCode() ? $variant : null;
120         }
121
122         function translate( $text, $variant ) {
123                 return $text;
124         }
125
126         public function updateConversionTable( Title $title ) {
127         }
128
129         /**
130          * Used by test suites which need to reset the converter state.
131          *
132          * @private
133          */
134         private function reloadTables() {
135         }
136 }