php-doc-en/reference/i18n/functions/locale-set-default.xml
Richard Quadling ba351d4b1b Renamed files with _ to -
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@302791 c90b9560-bf6c-de11-be94-00142212c4b1
2010-08-26 08:26:00 +00:00

133 lines
2.9 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.locale-set-default" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>locale_set_default</refname>
<refpurpose>Set the default Locale</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>locale_set_default</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
</methodsynopsis>
<para>
Sets the default Locale for PHP programs. Please note that this has nothing
to do with <function>setlocale</function> nor with the system locale.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
The new Locale name. A comprehensive list of the supported locales is
available at <link xlink:href="&url.icu.locales;"/>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>locale_set_default</function> example</title>
<para>
This example demonstrates a possible usage of
<function>locale_set_default</function> to localize the
<function>sort</function> functions.
</para>
<programlisting role="php">
<![CDATA[
<?php
// the list of the strings to sort
$array = array(
'caramelo',
'cacto',
'caçada'
);
// set our locale (Portuguese, in this case)
locale_set_default('pt_PT');
// sort using the locale we previously set
sort($array, SORT_LOCALE_STRING);
print_r($array);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[0] => caçada
[1] => cacto
[2] => caramelo
)
]]>
</screen>
<para>
If we didn't use the locale, PHP would sort the string using the ASCII
characters value, thus returning (wrongly):
</para>
<screen>
<![CDATA[
Array
(
[0] => cacto
[1] => caramelo
[2] => caçada
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>locale_get_default</function></member>
</simplelist>
</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:"~/.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
-->