2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2005-10-13 13:30:44 +00:00
|
|
|
<!-- $Revision: 1.26 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- 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>
|
2005-06-23 08:16:55 +00:00
|
|
|
<methodparam><type>int</type><parameter>category</parameter></methodparam>
|
2002-04-15 00:12:54 +00:00
|
|
|
<methodparam><type>string</type><parameter>locale</parameter></methodparam>
|
2003-02-28 23:47:31 +00:00
|
|
|
<methodparam choice="opt"><type>string</type><parameter>...</parameter></methodparam>
|
2002-09-18 07:56:17 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>string</type><methodname>setlocale</methodname>
|
2005-06-23 08:16:55 +00:00
|
|
|
<methodparam><type>int</type><parameter>category</parameter></methodparam>
|
2002-09-18 07:56:17 +00:00
|
|
|
<methodparam><type>array</type><parameter>locale</parameter></methodparam>
|
2002-04-15 00:12:54 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2004-02-18 11:17:37 +00:00
|
|
|
<parameter>category</parameter> is a named constant (or string)
|
2002-04-15 00:12:54 +00:00
|
|
|
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>
|
2002-07-27 04:07:06 +00:00
|
|
|
<simpara> LC_NUMERIC for decimal separator (See also
|
2002-04-15 00:12:54 +00:00
|
|
|
<function>localeconv</function>)
|
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
|
|
|
LC_TIME for date and time formatting with
|
|
|
|
<function>strftime</function>
|
|
|
|
</simpara>
|
|
|
|
</listitem>
|
2005-10-13 13:30:44 +00:00
|
|
|
<listitem>
|
|
|
|
<simpara>
|
|
|
|
LC_MESSAGES for system responses (available if PHP was compiled with
|
|
|
|
<literal>libintl</literal>)
|
|
|
|
</simpara>
|
|
|
|
</listitem>
|
2002-04-15 00:12:54 +00:00
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
2004-02-18 02:04:00 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
2004-02-18 11:17:37 +00:00
|
|
|
As of PHP 4.2.0, passing <parameter>category</parameter> as a string is
|
2004-02-18 02:04:00 +00:00
|
|
|
deprecated, use the above constants instead. Passing them as a string
|
|
|
|
(within quotes) will result in a warning message.
|
|
|
|
</simpara>
|
|
|
|
</note>
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
2004-09-16 14:14:17 +00:00
|
|
|
If <parameter>locale</parameter> is &null; or the empty string
|
2002-04-15 00:12:54 +00:00
|
|
|
<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>
|
2004-09-16 14:14:17 +00:00
|
|
|
If <parameter>locale</parameter> is <literal>"0"</literal>,
|
2003-07-08 19:30:01 +00:00
|
|
|
the locale setting is not affected, only the current setting is returned.
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
2002-09-18 07:56:17 +00:00
|
|
|
<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
|
2003-10-02 16:05:16 +00:00
|
|
|
new locale until success. This is useful if a locale is known under
|
2002-09-18 07:56:17 +00:00
|
|
|
different names on different systems or for providing a fallback
|
|
|
|
for a possibly not available locale.
|
|
|
|
</para>
|
2003-01-21 09:34:17 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
Passing multiple locales is not available before PHP 4.3.0
|
|
|
|
</simpara>
|
|
|
|
</note>
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
|
|
|
Setlocale returns the new current locale, or &false; if the locale
|
2003-07-08 19:30:01 +00:00
|
|
|
functionality is not implemented on your platform, the specified
|
2002-04-15 00:12:54 +00:00
|
|
|
locale does not exist or the category name is invalid.
|
2003-06-17 09:02:39 +00:00
|
|
|
An invalid category name also causes a warning message. Category/locale
|
2003-06-17 15:47:31 +00:00
|
|
|
names can be found in <ulink url="&url.rfc;1766">RFC 1766</ulink>
|
|
|
|
and <ulink url="&url.iso-639;">ISO 639</ulink>.
|
2004-09-16 14:00:03 +00:00
|
|
|
Different systems have different naming schemes for locales.
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
2003-01-21 09:34:17 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
The return value of <function>setlocale</function> depends
|
2003-01-21 09:37:36 +00:00
|
|
|
on the system that PHP is running. It returns exactly
|
|
|
|
what the system setlocale function returns.
|
2003-01-21 09:34:17 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
2005-06-03 00:46:55 +00:00
|
|
|
<warning>
|
|
|
|
<para>
|
|
|
|
The locale information is maintained per process, not per
|
|
|
|
thread. If you are running PHP on a multithreaded server
|
|
|
|
api like IIS or Apache on Windows you may experience
|
|
|
|
sudden changes of locale settings while a script is
|
2005-06-06 03:23:26 +00:00
|
|
|
running although the script itself never called <function>setlocale</function>
|
2005-06-03 00:46:55 +00:00
|
|
|
itself. This happens due to other scripts running in different
|
|
|
|
threads of the same process at the same time changing the
|
|
|
|
processwide locale using <function>setlocale</function>.
|
|
|
|
</para>
|
|
|
|
</warning>
|
2003-07-08 19:30:01 +00:00
|
|
|
<tip>
|
|
|
|
<para>
|
2003-10-02 16:05:16 +00:00
|
|
|
Windows users will find useful information about
|
2003-07-14 09:10:17 +00:00
|
|
|
<parameter>locale</parameter> strings at Microsoft's
|
|
|
|
<acronym>MSDN</acronym>website. Supported language strings can be found
|
2003-12-31 15:03:12 +00:00
|
|
|
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
|
2003-07-09 08:26:54 +00:00
|
|
|
country/region specified by <literal>ISO 3166-Alpha-3</literal>, which
|
2003-07-08 19:30:01 +00:00
|
|
|
can be found at this <ulink url="&url.iso-3166-3;">Unicode website
|
|
|
|
</ulink>.
|
|
|
|
</para>
|
|
|
|
</tip>
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>setlocale</function> Examples</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2003-01-21 09:34:17 +00:00
|
|
|
/* Set locale to Dutch */
|
2003-12-15 16:55:22 +00:00
|
|
|
setlocale(LC_ALL, 'nl_NL');
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2003-01-21 09:34:17 +00:00
|
|
|
/* Output: vrijdag 22 december 1978 */
|
2003-12-15 16:55:22 +00:00
|
|
|
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
|
2002-09-18 07:56:17 +00:00
|
|
|
|
2003-01-21 09:34:17 +00:00
|
|
|
/* try different possible locale names for german as of PHP 4.3.0 */
|
2003-12-15 16:55:22 +00:00
|
|
|
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
2003-01-21 09:34:17 +00:00
|
|
|
echo "Preferred locale for german on this system is '$loc_de'";
|
2002-04-15 00:12:54 +00:00
|
|
|
?>
|
2003-07-08 19:30:01 +00:00
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>setlocale</function> Examples for Windows</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
/* Set locale to Dutch */
|
2003-12-15 16:55:22 +00:00
|
|
|
setlocale(LC_ALL, 'nld_nld');
|
2003-07-08 19:30:01 +00:00
|
|
|
|
|
|
|
/* Output: vrijdag 22 december 1978 */
|
2003-12-15 16:55:22 +00:00
|
|
|
echo strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));
|
2003-07-08 19:30:01 +00:00
|
|
|
|
|
|
|
/* try different possible locale names for german as of PHP 4.3.0 */
|
2003-12-15 16:55:22 +00:00
|
|
|
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
|
2003-07-08 19:30:01 +00:00
|
|
|
echo "Preferred locale for german on this system is '$loc_de'";
|
|
|
|
?>
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
|
|
|
</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
|
|
|
|
-->
|