reference/intl/locale/compose-locale.xml
1976eae0d815797af97a1e16c5cd90ffc2868395
...
...
@@ -12,19 +12,15 @@
12
12
<para>
13
13
&style.oop;
14
14
</para>
15
-
<methodsynopsis>
16
-
<modifier>public</modifier>
17
-
<modifier>static</modifier>
18
-
<type>string</type>
19
-
<methodname>Locale::composeLocale</methodname>
15
+
<methodsynopsis role="Locale">
16
+
<modifier>public</modifier> <modifier>static</modifier> <type class="union"><type>string</type><type>false</type></type><methodname>Locale::composeLocale</methodname>
20
17
<methodparam><type>array</type><parameter>subtags</parameter></methodparam>
21
18
</methodsynopsis>
22
19
<para>
23
20
&style.procedural;
24
21
</para>
25
22
<methodsynopsis>
26
-
<type>string</type>
27
-
<methodname>locale_compose</methodname>
23
+
<type class="union"><type>string</type><type>false</type></type><methodname>locale_compose</methodname>
28
24
<methodparam><type>array</type><parameter>subtags</parameter></methodparam>
29
25
</methodsynopsis>
30
26
<para>
...
...
@@ -42,22 +38,22 @@
42
38
<term><parameter>subtags</parameter></term>
43
39
<listitem>
44
40
<para>
45
-
an array containing a list of key-value pairs, where the keys identify
41
+
An &array; containing a list of key-value pairs, where the keys identify
46
42
the particular locale ID subtags, and the values are the associated
47
43
subtag values.
48
44
<note>
49
45
<para>
50
-
The 'variant' and 'private' subtags can take maximum 15 values
51
-
whereas 'extlang' can take maximum 3 values.e.g. Variants are allowed
46
+
The <literal>'variant'</literal> and <literal>'private'</literal> subtags can take maximum 15 values
47
+
whereas <literal>'extlang'</literal> can take maximum 3 values. For instance, variants are allowed
52
48
with the suffix ranging from 0-14. Hence the keys for the input array
53
-
can be variant0, variant1, ...,variant14. In the returned locale id,
54
-
the subtag is ordered by suffix resulting in variant0 followed by
55
-
variant1 followed by variant2 and so on.
49
+
can be <literal>variant0</literal>, <literal>variant1</literal>, …,<literal>variant14</literal>. In the returned locale id,
50
+
the subtag is ordered by suffix resulting in <literal>variant0</literal> followed by
51
+
<literal>variant1</literal> followed by <literal>variant2</literal> and so on.
56
52
</para>
57
53
<para>
58
-
The 'variant', 'private' and 'extlang' multiple values can be specified both
59
-
as array under specific key (e.g. 'variant') and as multiple numbered keys
60
-
(e.g. 'variant0', 'variant1', etc.).
54
+
Alternatively, the <literal>'variant'</literal>, <literal>'private'</literal> and <literal>'extlang'</literal> values can be specified
55
+
as array under specific key (e.g. <literal>'variant'</literal>).
56
+
In this case no limits on the number of recognized subtags apply.
61
57
</para>
62
58
</note>
63
59
</para>
...
...
@@ -71,7 +67,7 @@
71
67
<refsect1 role="returnvalues">
72
68
&reftitle.returnvalues;
73
69
<para>
74
-
The corresponding locale identifier.
70
+
The corresponding locale identifier, or &false; when <parameter>subtags</parameter> is empty.
75
71
</para>
76
72
</refsect1>
77
73

...
...
@@ -83,15 +79,15 @@
83
79
<![CDATA[
84
80
<?php
85
81
$arr = array(
86
-
'language'=>'en' ,
87
-
'script' =>'Hans' ,
82
+
'language'=>'en',
83
+
'script' =>'Hans',
88
84
'region' =>'CN',
89
-
'variant2'=>'rozaj' ,
90
-
'variant1'=>'nedis' ,
91
-
'private1'=>'prv1' ,
92
-
'private2'=>'prv2'
85
+
'variant2'=>'rozaj',
86
+
'variant1'=>'nedis',
87
+
'private1'=>'prv1',
88
+
'private2'=>'prv2',
93
89
);
94
-
echo locale_compose( $arr );
90
+
echo locale_compose($arr);
95
91
?>
96
92
]]>
97
93
</programlisting>
...
...
@@ -103,14 +99,14 @@ echo locale_compose( $arr );
103
99
<?php
104
100
$arr = array(
105
101
'language'=>'en' ,
106
-
'script' =>'Hans' ,
102
+
'script' =>'Hans',
107
103
'region' =>'CN',
108
-
'variant2'=>'rozaj' ,
109
-
'variant1'=>'nedis' ,
110
-
'private1'=>'prv1' ,
111
-
'private2'=>'prv2'
104
+
'variant2'=>'rozaj',
105
+
'variant1'=>'nedis',
106
+
'private1'=>'prv1',
107
+
'private2'=>'prv2',
112
108
);
113
-
echo Locale::composeLocale( $arr );
109
+
echo Locale::composeLocale($arr);
114
110
?>
115
111
]]>
116
112
</programlisting>
...
...
@@ -121,6 +117,47 @@ echo Locale::composeLocale( $arr );
121
117
Locale: en_Hans_CN_nedis_rozaj_x_prv1_prv2
122
118
]]>
123
119
</screen>
120
+

121
+
<example xml:id="locale.composelocale.example.limits">
122
+
<title>Subtag limits</title>
123
+
<para>
124
+
If <parameter>subtags</parameter> are given as separate keys with numeric suffix,
125
+
unsupported keys are silently ignored (in this case <literal>'extlang3'</literal>),
126
+
and ordered in the result by numeric suffix.
127
+
There are no limits, if subtags are given as &array;; the order is as given.
128
+
</para>
129
+
<programlisting role="php">
130
+
<![CDATA[
131
+
<?php
132
+
$arr = array(
133
+
'language' => 'en',
134
+
'script' => 'Hans',
135
+
'region' => 'CN',
136
+
'extlang3' => 'd',
137
+
'extlang2' => 'c',
138
+
'extlang1' => 'b',
139
+
'extlang0' => 'a',
140
+
);
141
+
echo locale_compose($arr), PHP_EOL;
142
+

143
+
$arr = array(
144
+
'language' => 'en',
145
+
'script' => 'Hans',
146
+
'region' => 'CN',
147
+
'extlang' => ['a', 'b', 'c', 'd'],
148
+
);
149
+
echo locale_compose($arr), PHP_EOL;
150
+
?>
151
+
]]>
152
+
</programlisting>
153
+
</example>
154
+
&example.outputs;
155
+
<screen>
156
+
<![CDATA[
157
+
en_a_b_c_Hans_CN
158
+
en_a_b_c_d_Hans_CN
159
+
]]>
160
+
</screen>
124
161
</refsect1>
125
162

126
163
<refsect1 role="seealso">
...
...
@@ -132,7 +169,6 @@ Locale: en_Hans_CN_nedis_rozaj_x_prv1_prv2
132
169
</para>
133
170
</refsect1>
134
171
</refentry>
135
-

136
172
<!-- Keep this comment at the end of the file
137
173
Local variables:
138
174
mode: sgml
139
175