@@ -77,47 +77,42 @@ according to the `ISO 639-1 alpha-2`_ list and the `ISO 639-2 alpha-3`_ list::
77
77
// ('languageCode' => 'languageName')
78
78
// => ['ab' => 'Abkhazian', 'ace' => 'Achinese', ...]
79
79
80
- $language = Languages::getName('fr');
81
- // => 'French'
82
-
83
- You can also use the ISO 639-2 three-letter language codes instead of
84
- the ISO 639-1 two-letter codes, respectively called alpha3 and alpha2 codes::
85
-
86
- use Symfony\Component\Intl\Languages;
87
-
88
- \Locale::setDefault('en');
89
-
90
80
$languages = Languages::getAlpha3Names();
91
81
// ('languageCode' => 'languageName')
92
82
// => ['abk' => 'Abkhazian', 'ace' => 'Achinese', ...]
93
83
94
- $language = Languages::getAlpha3Name('fra ');
84
+ $language = Languages::getName('fr ');
95
85
// => 'French'
96
86
97
- .. versionadded :: 4.4
98
-
99
- The support for alpha3 codes was introduced in Symfony 4.4.
87
+ $language = Languages::getAlpha3Name('fra');
88
+ // => 'French'
100
89
101
90
All methods accept the translation locale as the last, optional parameter,
102
91
which defaults to the current default locale::
103
92
104
93
$languages = Languages::getNames('de');
105
94
// => ['ab' => 'Abchasisch', 'ace' => 'Aceh', ...]
106
95
96
+ $languages = Languages::getAlpha3Names('de');
97
+ // => ['abk' => 'Abchasisch', 'ace' => 'Aceh', ...]
98
+
107
99
$language = Languages::getName('fr', 'de');
108
100
// => 'Französisch'
109
101
102
+ $language = Languages::getAlpha3Name('fra', 'de');
103
+ // => 'Französisch'
104
+
110
105
If the given locale doesn't exist, the methods trigger a
111
106
:class: `Symfony\\ Component\\ Intl\\ Exception\\ MissingResourceException `. In addition
112
107
to catching the exception, you can also check if a given language code is valid::
113
108
114
109
$isValidLanguage = Languages::exists($languageCode);
115
110
116
- Or if you have a three-letter language code you want to check::
111
+ Or if you have a alpha3 language code you want to check::
117
112
118
113
$isValidLanguage = Languages::alpha3CodeExists($alpha3Code);
119
114
120
- You may convert codes between two-letter ISO 639-1 ( alpha2) and three-letter ISO 639-2 ( alpha3) codes::
115
+ You may convert codes between two-letter alpha2 and three-letter alpha3 codes::
121
116
122
117
$alpha3Code = Languages::getAlpha3Code($alpha2Code);
123
118
@@ -127,6 +122,10 @@ You may convert codes between two-letter ISO 639-1 (alpha2) and three-letter ISO
127
122
128
123
The ``Languages `` class was introduced in Symfony 4.3.
129
124
125
+ .. versionadded :: 4.4
126
+
127
+ The full support for alpha3 codes was introduced in Symfony 4.4.
128
+
130
129
The ``Scripts `` class provides access to the optional four-letter script code
131
130
that can follow the language code according to the `Unicode ISO 15924 Registry `_
132
131
(e.g. ``HANS `` in ``zh_HANS `` for simplified Chinese and ``HANT `` in ``zh_HANT ``
@@ -187,10 +186,6 @@ of officially recognized countries and territories::
187
186
$country = Countries::getAlpha3Name('NOR');
188
187
// => 'Norway'
189
188
190
- .. versionadded :: 4.4
191
-
192
- The support for alpha3 codes was introduced in Symfony 4.4.
193
-
194
189
All methods accept the translation locale as the last, optional parameter,
195
190
which defaults to the current default locale::
196
191
@@ -226,6 +221,10 @@ You may convert codes between two-letter alpha2 and three-letter alpha3 codes::
226
221
227
222
The ``Countries `` class was introduced in Symfony 4.3.
228
223
224
+ .. versionadded :: 4.4
225
+
226
+ The support for alpha3 codes was introduced in Symfony 4.4.
227
+
229
228
Locales
230
229
~~~~~~~
231
230
0 commit comments