-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathsetlocale.xml
249 lines (239 loc) · 9.1 KB
/
setlocale.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 54ff7bf8e0f8fa90988cccf6b583517366605f6d 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>string</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>
の場合、ロケール名は上記のカテゴリと同じ名前の環境変数の値、
または環境変数 "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">
<![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>Windows での <function>setlocale</function> の例</title>
<programlisting role="php">
<![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
-->