forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZend_Currency-Number.xml
115 lines (94 loc) · 3.46 KB
/
Zend_Currency-Number.xml
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
<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="zend.currency.number"><info><title>How does the currency look like?</title></info>
<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 xml:id="zend.currency.number.example-1"><info><title>Using a custom script</title></info>
<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>
</section>