<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.currency.number">
    <title>How does the currency look like?</title>

    <para>
        How the value of a currency will be rendered depends mainly on the used locale. There
        are several informations which are set by the locale. Each of them can manually be
        overridden by using the proper option.
    </para>

    <para>
        For example, most locales are using the Latin script for rendering numbers. But there
        are languages like "Arabic" which are using other digits. And when you have an Arabic
        website you may also want to render other currencies by using the Arabic script. See
        the following example:
    </para>

    <example id="zend.currency.number.example-1">
        <title>Using a custom script</title>

        <para>
            Let's expect that we are again using our "Dollar" currency. But now we want to
            render our currency by using the Arabic script.
        </para>

        <programlisting language="php"><![CDATA[
$currency = new Zend_Currency(
    array(
        'value'  => 1000,
        'script' => 'Arab',
    )
);

print $currency; // Could return '$ ١٬٠٠٠٫٠٠'
]]></programlisting>
    </example>

    <para>
        For more informations about available scripts look into
        <classname>Zend_Locale</classname>'s <link linkend="zend.locale.numbersystems">chapter
            about numbering systems</link>.
    </para>

    <para>
        But also the formatting of a currency number (money value) can be changed. Per default
        it depends on the used locale. It includes the separator which will be used between
        thousands, which sign will be used as decimal point, and also the used precision.
    </para>

    <programlisting language="php"><![CDATA[
$currency = new Zend_Currency(
    array(
        'value'    => 1000,
        'currency' => 'USD'
        'format'   => 'de',
    )
);

print $currency; // Could return '$ 1.000'
]]></programlisting>

    <para>
        There are two ways to define the format which will be used. You can either give a
        locale or define a format manually.
    </para>

    <para>
        When you are using a locale for defining the format all is done automatically. The
        locale 'de', for example, defines '.' as separator for thousands and ',' as decimal
        point. Within English this is reversed.
    </para>

    <programlisting language="php"><![CDATA[
$currency_1 = new Zend_Currency(
    array(
        'value'    => 1000,
        'currency' => 'USD'
        'format'   => 'de',
    )
);

$currency_2 = new Zend_Currency(
    array(
        'value'    => 1000,
        'currency' => 'USD'
        'format'   => 'en',
    )
);

print $currency_1; // Could return '$ 1.000'
print $currency_2; // Could return '$ 1,000'
]]></programlisting>

    <para>
        When you define it manually then you must conform the format as described in
        <link linkend="zend.locale.number.localize.table-1">this chapter about
            localizing</link>. See the following:
    </para>

    <programlisting language="php"><![CDATA[
$currency = new Zend_Currency(
    array(
        'value'    => 1000,
        'currency' => 'USD'
        'format'   => '#0',
    )
);

print $currency; // Could return '$ 1000'
]]></programlisting>

    <para>
        In the above snippet we deleted the separator and also the precision.
    </para>
</sect1>
