mirror of
https://github.com/php/doc-ja.git
synced 2026-04-26 17:38:12 +02:00
4773312462
- WASM の example 修正 - number_format まわりの誤訳 - その他細かい修正全てに追随 https://github.com/php/doc-en/commits/master/reference/strings
265 lines
9.5 KiB
XML
265 lines
9.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 09324fb1df7b5b1c0a5f95e3ebbe802f59da4585 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka,mumumu -->
|
|
<refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="function.setlocale">
|
|
<refnamediv>
|
|
<refname>setlocale</refname>
|
|
<refpurpose>ロケール情報を設定する</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>string</type><type>false</type></type><methodname>setlocale</methodname>
|
|
<methodparam><type>int</type><parameter>category</parameter></methodparam>
|
|
<methodparam><type class="union"><type>string</type><type>null</type></type><parameter>locales</parameter></methodparam>
|
|
<methodparam rep="repeat"><type>string</type><parameter>rest</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>代替のシグネチャ (名前付き引数をサポートしていません):</simpara>
|
|
<methodsynopsis>
|
|
<type class="union"><type>string</type><type>false</type></type><methodname>setlocale</methodname>
|
|
<methodparam><type>int</type><parameter>category</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>locale_array</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
ロケール情報を設定します。
|
|
</para>
|
|
<warning>
|
|
<para>
|
|
ロケール情報は、スレッド毎ではなくプロセス毎に維持されます。
|
|
もし PHP を マルチスレッドサーバーAPI 上で動作させている場合、
|
|
スクリプトを実行している間にロケールの設定が突然変わるのを
|
|
経験するかも知れませんが、スクリプト自身は決して
|
|
<function>setlocale</function> 自身をコールしていません。
|
|
これは同時に同一プロセスの異なるスレッドで実行されている他のスクリプトが
|
|
<function>setlocale</function>
|
|
を使用してプロセスワイドなロケールを変更する事により発生します。
|
|
Windows では、PHP 7.0.5 以降、
|
|
ロケール情報はスレッド単位で維持されるようになっています。
|
|
</para>
|
|
</warning>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>category</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>category</parameter>は、名前付きの定数(または文字列)であり、
|
|
ロケール設定により影響を受ける関数のカテゴリを指定します。
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LC_ALL</constant> 以下のものすべて
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LC_COLLATE</constant> 文字列の比較用。<function>strcoll</function> も参照
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LC_CTYPE</constant> 文字の分類と変換。たとえば <function>ctype_alpha</function>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LC_MONETARY</constant> <function>localeconv</function> 用
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LC_NUMERIC</constant> 数字の区切り文字用(<function>localeconv</function>
|
|
も参照ください)
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LC_TIME</constant> 日時。<function>strftime</function>でフォーマットに使用
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LC_MESSAGES</constant> システムの応答用(PHP が <literal>libintl</literal>
|
|
とともにコンパイルされている場合のみ使用可能)
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>locales</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>locales</parameter>が空の文字列
|
|
<literal>""</literal> または &null; の場合、
|
|
ロケール名は上記のカテゴリと同じ名前の環境変数の値、
|
|
または環境変数 "LANG" からセットされます。
|
|
</para>
|
|
<para>
|
|
<parameter>locales</parameter> が <literal>"0"</literal> の場合、
|
|
ロケール設定は適用されず、単に現在の設定が返されます。
|
|
</para>
|
|
<para>
|
|
<parameter>locales</parameter> に追加のパラメータが続く場合、
|
|
それぞれのパラメータは成功するまで新規ロケールとしてセットされます。
|
|
これは、ロケールが異なるシステムで異なる名前を持っている、
|
|
もしくはロケールが利用できない場合のフォールバックを提供するといった場合に有用です。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>rest</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
オプションの文字列。ロケール設定が成功するまで設定を試みます。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>locale_array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
それぞれの配列の要素が、
|
|
新しいロケールとして設定が成功するまで設定を試みます。
|
|
これは、異なるシステムでロケールが違う名前として認識されたり、
|
|
ロケールが利用できない可能性がある場合にフォールバックさせる目的で使うと便利です。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
<note>
|
|
<para>
|
|
Windows では、setlocale(LC_ALL, '') を使用するとシステムの
|
|
地域と言語の設定の値を使用します (コントロールパネルで確認できます)。
|
|
</para>
|
|
</note>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
現在の新しいロケールを返します。ロケール機能が未実装、
|
|
指定されたロケールが存在しない、カテゴリ名が無効などの場合は
|
|
&false; を返します。
|
|
</para>
|
|
<para>
|
|
また、カテゴリ名が無効の場合は警告メッセージが発生します。
|
|
カテゴリやロケール名は、
|
|
<link xlink:href="&url.rfc;1766">RFC 1766</link>
|
|
や <link xlink:href="&url.iso-639;">ISO 639</link> にあります。
|
|
ロケールの命名方式は、システムによって異なります。
|
|
</para>
|
|
<note>
|
|
<para>
|
|
<function>setlocale</function> の戻り値は、
|
|
PHP が実行されているシステムに依存します。
|
|
システムの <literal>setlocale</literal> 関数が返す値を返すためです。
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>setlocale</function> の例</title>
|
|
<programlisting role="php" annotations="non-interactive">
|
|
<![CDATA[
|
|
<?php
|
|
/* ロケールをオランダ語に設定 */
|
|
setlocale(LC_ALL, 'nl_NL');
|
|
|
|
/* 出力: vrijdag 22 december 1978 */
|
|
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
|
|
|
|
/* ドイツに対して利用可能な異なるロケール名を使用する */
|
|
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
|
echo "Preferred locale for german on this system is '$loc_de'";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>setlocale</function> で現在の設定を取得する</title>
|
|
<programlisting role="php" annotations="non-interactive">
|
|
<![CDATA[
|
|
<?php
|
|
/* Retrieve current setting */
|
|
$current = setlocale(LC_ALL, null);
|
|
|
|
echo "Current locale '$current'";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Windows での <function>setlocale</function> の例</title>
|
|
<programlisting role="php" annotations="non-interactive">
|
|
<![CDATA[
|
|
<?php
|
|
/* ロケールをオランダ語に設定 */
|
|
setlocale(LC_ALL, 'nld_nld');
|
|
|
|
/* 出力: vrijdag 22 december 1978 */
|
|
echo strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));
|
|
|
|
/* ドイツに対して利用可能な異なるロケール名を使用する */
|
|
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
|
|
echo "Preferred locale for german on this system is '$loc_de'";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<tip>
|
|
<para>
|
|
Windows ユーザーは Microsoft の <acronym>MSDN</acronym> の Web サイトに
|
|
<parameter>locales</parameter>
|
|
文字列に関する有用な情報を見つけることができるでしょう。
|
|
サポートしている言語文字列は
|
|
<link xlink:href="&url.setlocale.lang.win32;">言語文字列のドキュメント</link>、
|
|
そしてサポートしている国/地域文字列は
|
|
<link xlink:href="&url.setlocale.country.win32;">国/地域文字列のドキュメント</link>
|
|
にあります。
|
|
</para>
|
|
</tip>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|