MediaWiki  1.23.13
wfBCP47Test.php
Go to the documentation of this file.
1 <?php
16  public function testBCP47( $code, $expected ) {
17  $code = strtolower( $code );
18  $this->assertEquals( $expected, wfBCP47( $code ),
19  "Applying BCP47 standard to lower case '$code'"
20  );
21 
22  $code = strtoupper( $code );
23  $this->assertEquals( $expected, wfBCP47( $code ),
24  "Applying BCP47 standard to upper case '$code'"
25  );
26  }
27 
31  public static function provideLanguageCodes() {
32  return array(
33  // Extracted from BCP47 (list not exhaustive)
34  # 2.1.1
35  array( 'en-ca-x-ca', 'en-CA-x-ca' ),
36  array( 'sgn-be-fr', 'sgn-BE-FR' ),
37  array( 'az-latn-x-latn', 'az-Latn-x-latn' ),
38  # 2.2
39  array( 'sr-Latn-RS', 'sr-Latn-RS' ),
40  array( 'az-arab-ir', 'az-Arab-IR' ),
41 
42  # 2.2.5
43  array( 'sl-nedis', 'sl-nedis' ),
44  array( 'de-ch-1996', 'de-CH-1996' ),
45 
46  # 2.2.6
47  array(
48  'en-latn-gb-boont-r-extended-sequence-x-private',
49  'en-Latn-GB-boont-r-extended-sequence-x-private'
50  ),
51 
52  // Examples from BCP47 Appendix A
53  # Simple language subtag:
54  array( 'DE', 'de' ),
55  array( 'fR', 'fr' ),
56  array( 'ja', 'ja' ),
57 
58  # Language subtag plus script subtag:
59  array( 'zh-hans', 'zh-Hans' ),
60  array( 'sr-cyrl', 'sr-Cyrl' ),
61  array( 'sr-latn', 'sr-Latn' ),
62 
63  # Extended language subtags and their primary language subtag
64  # counterparts:
65  array( 'zh-cmn-hans-cn', 'zh-cmn-Hans-CN' ),
66  array( 'cmn-hans-cn', 'cmn-Hans-CN' ),
67  array( 'zh-yue-hk', 'zh-yue-HK' ),
68  array( 'yue-hk', 'yue-HK' ),
69 
70  # Language-Script-Region:
71  array( 'zh-hans-cn', 'zh-Hans-CN' ),
72  array( 'sr-latn-RS', 'sr-Latn-RS' ),
73 
74  # Language-Variant:
75  array( 'sl-rozaj', 'sl-rozaj' ),
76  array( 'sl-rozaj-biske', 'sl-rozaj-biske' ),
77  array( 'sl-nedis', 'sl-nedis' ),
78 
79  # Language-Region-Variant:
80  array( 'de-ch-1901', 'de-CH-1901' ),
81  array( 'sl-it-nedis', 'sl-IT-nedis' ),
82 
83  # Language-Script-Region-Variant:
84  array( 'hy-latn-it-arevela', 'hy-Latn-IT-arevela' ),
85 
86  # Language-Region:
87  array( 'de-de', 'de-DE' ),
88  array( 'en-us', 'en-US' ),
89  array( 'es-419', 'es-419' ),
90 
91  # Private use subtags:
92  array( 'de-ch-x-phonebk', 'de-CH-x-phonebk' ),
93  array( 'az-arab-x-aze-derbend', 'az-Arab-x-aze-derbend' ),
102  # Private use registry values:
103  array( 'x-whatever', 'x-whatever' ),
104  array( 'qaa-qaaa-qm-x-southern', 'qaa-Qaaa-QM-x-southern' ),
105  array( 'de-qaaa', 'de-Qaaa' ),
106  array( 'sr-latn-qm', 'sr-Latn-QM' ),
107  array( 'sr-qaaa-rs', 'sr-Qaaa-RS' ),
108 
109  # Tags that use extensions
110  array( 'en-us-u-islamcal', 'en-US-u-islamcal' ),
111  array( 'zh-cn-a-myext-x-private', 'zh-CN-a-myext-x-private' ),
112  array( 'en-a-myext-b-another', 'en-a-myext-b-another' ),
113 
114  # Invalid:
115  // de-419-DE
116  // a-DE
117  // ar-a-aaa-b-bbb-a-ccc
118  );
119  }
120 }
wfBCP47
wfBCP47( $code)
Get the normalised IETF language tag See unit test for examples.
Definition: GlobalFunctions.php:3977
WfBCP47Test\testBCP47
testBCP47( $code, $expected)
test
Definition: wfBCP47Test.php:16
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
WfBCP47Test
@covers wfBCP47
Definition: wfBCP47Test.php:5
WfBCP47Test\provideLanguageCodes
static provideLanguageCodes()
Array format is ($code, $expected)
Definition: wfBCP47Test.php:31
values
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
Definition: hooks.txt:177
that
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if that
Definition: deferred.txt:11
Language
Internationalisation code.
Definition: Language.php:74