File: setlocale.xml

package info (click to toggle)
phpdoc 20050512-1
  • links: PTS
  • area: non-free
  • in suites: sarge
  • size: 36,592 kB
  • ctags: 1,501
  • sloc: xml: 376,768; php: 6,708; cpp: 500; makefile: 293; perl: 161; sh: 151; awk: 28
file content (182 lines) | stat: -rw-r--r-- 6,229 bytes parent folder | download
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.22 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
  <refentry id="function.setlocale">
   <refnamediv>
    <refname>setlocale</refname>
    <refpurpose>Set locale information</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>setlocale</methodname>
      <methodparam><type>mixed</type><parameter>category</parameter></methodparam>
      <methodparam><type>string</type><parameter>locale</parameter></methodparam>
      <methodparam choice="opt"><type>string</type><parameter>...</parameter></methodparam>
     </methodsynopsis>
     <methodsynopsis>
      <type>string</type><methodname>setlocale</methodname>
      <methodparam><type>mixed</type><parameter>category</parameter></methodparam>
      <methodparam><type>array</type><parameter>locale</parameter></methodparam>
     </methodsynopsis>
    <para>
     <parameter>category</parameter> is a named constant (or string)
     specifying the category of the functions affected by the locale
     setting:
     <itemizedlist>
      <listitem>
       <simpara>
        LC_ALL for all of the below
       </simpara>
      </listitem>
      <listitem>
       <simpara>
        LC_COLLATE for string comparison, see
        <function>strcoll</function>
       </simpara>
      </listitem>
      <listitem>
       <simpara>
        LC_CTYPE for character classification and conversion, for
        example <function>strtoupper</function>
       </simpara>
      </listitem>
      <listitem>
       <simpara>
        LC_MONETARY for <function>localeconv</function>
       </simpara>
      </listitem>
      <listitem>
       <simpara> LC_NUMERIC for decimal separator (See also
       <function>localeconv</function>)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
        LC_TIME for date and time formatting with
        <function>strftime</function>
       </simpara>
      </listitem>
     </itemizedlist>
    </para>
    <note>
     <simpara>
      As of PHP 4.2.0, passing <parameter>category</parameter> as a string is
      deprecated, use the above constants instead.  Passing them as a string
      (within quotes) will result in a warning message.
     </simpara>
    </note>
    <para>
     If <parameter>locale</parameter> is &null; or the empty string
     <literal>""</literal>, the locale names will be set from the
     values of environment variables with the same names as the above
     categories, or from "LANG".
    </para>
    <para>
     If <parameter>locale</parameter> is <literal>"0"</literal>,
     the locale setting is not affected, only the current setting is returned.
    </para>
    <para>
     If <parameter>locale</parameter> is an array or followed by additional
     parameters then each array element or parameter is tried to be set as
     new locale until success. This is useful if a locale is known under
     different names on different systems or for providing a fallback 
     for a possibly not available locale.
    </para>
    <note>
     <simpara>
      Passing multiple locales is not available before PHP 4.3.0
     </simpara>
    </note>
    <para>
     Setlocale returns the new current locale, or &false; if the locale
     functionality is not implemented on your platform, the specified
     locale does not exist or the category name is invalid.
     An invalid category name also causes a warning message. Category/locale
     names can be found in <ulink url="&url.rfc;1766">RFC 1766</ulink>
     and <ulink url="&url.iso-639;">ISO 639</ulink>.
     Different systems have different naming schemes for locales.
    </para>
    <note>
     <para>
      The return value of <function>setlocale</function> depends
      on the system that PHP is running.  It returns exactly
      what the system setlocale function returns.
     </para>
    </note>
    <tip>
     <para>
      Windows users will find useful information about
      <parameter>locale</parameter> strings at Microsoft's
      <acronym>MSDN</acronym>website. Supported language strings can be found
      at <ulink url="&url.setlocale.lang.win32;">&url.setlocale.lang.win32;</ulink> and supported
      country/region strings at <ulink url="&url.setlocale.country.win32;">
      &url.setlocale.country.win32;</ulink>. Windows systems support the three letter codes for
      country/region specified by <literal>ISO 3166-Alpha-3</literal>, which
      can be found at this <ulink url="&url.iso-3166-3;">Unicode website
      </ulink>. 
     </para>
    </tip>
    <para>
     <example>
      <title><function>setlocale</function> Examples</title>
      <programlisting role="php">
<![CDATA[
<?php
/* Set locale to Dutch */
setlocale(LC_ALL, 'nl_NL');

/* Output: vrijdag 22 december 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* try different possible locale names for german as of PHP 4.3.0 */
$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> Examples for Windows</title>
      <programlisting role="php">
<![CDATA[
<?php
/* Set locale to Dutch */
setlocale(LC_ALL, 'nld_nld');

/* Output: vrijdag 22 december 1978 */
echo strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* try different possible locale names for german as of PHP 4.3.0 */
$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>
  </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:"../../../../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
-->