If `$locale` is invalid, the return value is actually the value of `$locale`, not `NULL` or `FALSE` as you might expect.
(If `$in_locale` is invalid, but `$locale` is valid, the return value is the language name in the default locale.)
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
Locale::getDisplayLanguage -- locale_get_display_language — 入力ロケールの言語の表示名を、適切に地域化して返す
オブジェクト指向型
$locale
, string $in_locale
= ?): string手続き型
$locale
, string $in_locale
= ?): string
入力ロケールの言語の表示名を、適切に地域化して返します。
null
の場合はデフォルトのロケールを使用します。
locale
表示言語を返したいロケール。
in_locale
オプションのフォーマットロケール。 言語名の表示に使用します。
$locale に対応する言語の表示名を、 $in_locale にあわせた形式で返します。
例1 locale_get_display_language() の例
<?php
echo locale_get_display_language('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo locale_get_display_language('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo locale_get_display_language('sl-Latn-IT-nedis', 'de');
?>
例2 オブジェクト指向の例
<?php
echo Locale::getDisplayLanguage('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo Locale::getDisplayLanguage('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo Locale::getDisplayLanguage('sl-Latn-IT-nedis', 'de');
?>
上の例の出力は以下となります。
Slovenian; slov\xc3\xa8ne; Slowenisch
If `$locale` is invalid, the return value is actually the value of `$locale`, not `NULL` or `FALSE` as you might expect.
(If `$in_locale` is invalid, but `$locale` is valid, the return value is the language name in the default locale.)
To display special characters correctly in a web browser, it's a good idea to decode the result data with utf8_decode:
<?php
echo utf8_decode(Locale::getDisplayLanguage('sl-Latn-IT-nedis', 'fr'));
echo utf8_decode(Locale::getDisplayLanguage('sl-Latn-IT-nedis', 'pt-BR'));
?>