MediaWiki  1.30.2
wfBCP47Test.php
Go to the documentation of this file.
1 <?php
17  public function testBCP47( $code, $expected ) {
18  $code = strtolower( $code );
19  $this->assertEquals( $expected, wfBCP47( $code ),
20  "Applying BCP47 standard to lower case '$code'"
21  );
22 
23  $code = strtoupper( $code );
24  $this->assertEquals( $expected, wfBCP47( $code ),
25  "Applying BCP47 standard to upper case '$code'"
26  );
27  }
28 
32  public static function provideLanguageCodes() {
33  return [
34  // Extracted from BCP 47 (list not exhaustive)
35  # 2.1.1
36  [ 'en-ca-x-ca', 'en-CA-x-ca' ],
37  [ 'sgn-be-fr', 'sgn-BE-FR' ],
38  [ 'az-latn-x-latn', 'az-Latn-x-latn' ],
39  # 2.2
40  [ 'sr-Latn-RS', 'sr-Latn-RS' ],
41  [ 'az-arab-ir', 'az-Arab-IR' ],
42 
43  # 2.2.5
44  [ 'sl-nedis', 'sl-nedis' ],
45  [ 'de-ch-1996', 'de-CH-1996' ],
46 
47  # 2.2.6
48  [
49  'en-latn-gb-boont-r-extended-sequence-x-private',
50  'en-Latn-GB-boont-r-extended-sequence-x-private'
51  ],
52 
53  // Examples from BCP 47 Appendix A
54  # Simple language subtag:
55  [ 'DE', 'de' ],
56  [ 'fR', 'fr' ],
57  [ 'ja', 'ja' ],
58 
59  # Language subtag plus script subtag:
60  [ 'zh-hans', 'zh-Hans' ],
61  [ 'sr-cyrl', 'sr-Cyrl' ],
62  [ 'sr-latn', 'sr-Latn' ],
63 
64  # Extended language subtags and their primary language subtag
65  # counterparts:
66  [ 'zh-cmn-hans-cn', 'zh-cmn-Hans-CN' ],
67  [ 'cmn-hans-cn', 'cmn-Hans-CN' ],
68  [ 'zh-yue-hk', 'zh-yue-HK' ],
69  [ 'yue-hk', 'yue-HK' ],
70 
71  # Language-Script-Region:
72  [ 'zh-hans-cn', 'zh-Hans-CN' ],
73  [ 'sr-latn-RS', 'sr-Latn-RS' ],
74 
75  # Language-Variant:
76  [ 'sl-rozaj', 'sl-rozaj' ],
77  [ 'sl-rozaj-biske', 'sl-rozaj-biske' ],
78  [ 'sl-nedis', 'sl-nedis' ],
79 
80  # Language-Region-Variant:
81  [ 'de-ch-1901', 'de-CH-1901' ],
82  [ 'sl-it-nedis', 'sl-IT-nedis' ],
83 
84  # Language-Script-Region-Variant:
85  [ 'hy-latn-it-arevela', 'hy-Latn-IT-arevela' ],
86 
87  # Language-Region:
88  [ 'de-de', 'de-DE' ],
89  [ 'en-us', 'en-US' ],
90  [ 'es-419', 'es-419' ],
91 
92  # Private use subtags:
93  [ 'de-ch-x-phonebk', 'de-CH-x-phonebk' ],
94  [ 'az-arab-x-aze-derbend', 'az-Arab-x-aze-derbend' ],
103  # Private use registry values:
104  [ 'x-whatever', 'x-whatever' ],
105  [ 'qaa-qaaa-qm-x-southern', 'qaa-Qaaa-QM-x-southern' ],
106  [ 'de-qaaa', 'de-Qaaa' ],
107  [ 'sr-latn-qm', 'sr-Latn-QM' ],
108  [ 'sr-qaaa-rs', 'sr-Qaaa-RS' ],
109 
110  # Tags that use extensions
111  [ 'en-us-u-islamcal', 'en-US-u-islamcal' ],
112  [ 'zh-cn-a-myext-x-private', 'zh-CN-a-myext-x-private' ],
113  [ 'en-a-myext-b-another', 'en-a-myext-b-another' ],
114 
115  # Invalid:
116  // de-419-DE
117  // a-DE
118  // ar-a-aaa-b-bbb-a-ccc
119  ];
120  }
121 }
wfBCP47
wfBCP47( $code)
Get the normalised IETF language tag See unit test for examples.
Definition: GlobalFunctions.php:3167
WfBCP47Test\testBCP47
testBCP47( $code, $expected)
test
Definition: wfBCP47Test.php:17
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWikiTestCase
Definition: MediaWikiTestCase.php:15
WfBCP47Test
GlobalFunctions wfBCP47.
Definition: wfBCP47Test.php:6
WfBCP47Test\provideLanguageCodes
static provideLanguageCodes()
Array format is ($code, $expected)
Definition: wfBCP47Test.php:32
$code
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition: hooks.txt:781