mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 14:28:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@196911 c90b9560-bf6c-de11-be94-00142212c4b1
133 lines
2.8 KiB
XML
133 lines
2.8 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.1 $ -->
|
|
<refentry id="function.i18n-loc-set-default">
|
|
<refnamediv>
|
|
<refname>i18n_loc_set_default</refname>
|
|
<refpurpose>Set the default Locale</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>i18n_loc_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 <ulink url="&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>i18n_loc_set_default</function> example</title>
|
|
<para>
|
|
This example demonstrates a possible usage of
|
|
<function>i18n_loc_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)
|
|
i18n_loc_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>i18n_loc_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:"../../../../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
|
|
-->
|