forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'docs/view-helpers' of https://github.com/cgmartin/zf2
- Loading branch information
Showing
4 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
documentation/manual/en/module_specs/zend.i18n.view.helper.currency-format.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="zend.i18n.view.helper.currency-format"><title>CurrencyFormat Helper</title> | ||
|
||
<para> | ||
The <classname>CurrencyFormat</classname> view helper can be used to simplify rendering | ||
of localized currency values. It acts as a wrapper for the <classname>NumberFormatter</classname> | ||
class within the Internationalization extension (Intl). | ||
</para> | ||
|
||
<example xml:id="zend.i18n.view.helper.currency-format.usage"><title>Basic Usage of CurrencyFormat</title> | ||
<programlisting language="php"><![CDATA[ | ||
// Within your view | ||
echo $this->currencyFormat(1234.56, "USD", "en_US"); | ||
// This returns: '$1,234.56' | ||
]]></programlisting> | ||
|
||
<para> | ||
<methodname>currencyFormat($number, $currencyCode, $locale)</methodname> | ||
</para> | ||
|
||
<itemizedlist> | ||
<listitem> | ||
<para> | ||
<varname>$number</varname> : The numeric currency value. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para> | ||
<varname>$currencyCode</varname> : The 3-letter ISO 4217 currency code indicating the currency to use. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para> | ||
<varname>$locale</varname> : (Optional) Locale in which the number would be formatted (locale name, e.g. en_US). | ||
If unset, it will use the default locale (<classname>Locale::getDefault()</classname>) | ||
</para> | ||
</listitem> | ||
</itemizedlist> | ||
|
||
</example> | ||
|
||
<example xml:id="zend.i18n.view.helper.currency-format.setter-usage"><title>CurrencyFormat Setters</title> | ||
<para> | ||
The <varname>$currencyCode</varname> and <varname>$locale</varname> can be set prior to formatting | ||
so that they are not required each time the helper is used: | ||
</para> | ||
|
||
<programlisting language="php"><![CDATA[ | ||
// Within your view | ||
$this->plugin("currencyformat")->setCurrencyCode("USD")->setLocale("en_US"); | ||
echo $this->currencyFormat(1234.56); // "$1,234.56" | ||
echo $this->currencyFormat(5678.90); // "$5,678.90" | ||
$this->plugin("currencyformat")->setCurrencyCode("EUR"); | ||
echo $this->currencyFormat(1234.56); // "€1,234.56" | ||
echo $this->currencyFormat(5678.90); // "€5,678.90" | ||
]]></programlisting> | ||
|
||
</example> | ||
</section> |
81 changes: 81 additions & 0 deletions
81
documentation/manual/en/module_specs/zend.i18n.view.helper.number-format.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="zend.i18n.view.helper.number-format"><title>NumberFormat Helper</title> | ||
|
||
<para> | ||
The <classname>NumberFormat</classname> view helper can be used to simplify rendering | ||
of locale-specific number and percentage strings. | ||
It acts as a wrapper for the <classname>NumberFormatter</classname> | ||
class within the Internationalization extension (Intl). | ||
</para> | ||
|
||
<example xml:id="zend.i18n.view.helper.number-format.usage"><title>Basic Usage of NumberFormat</title> | ||
<programlisting language="php"><![CDATA[ | ||
// Within your view | ||
echo $this->numberFormat( | ||
1234567.891234567890000, | ||
NumberFormatter::DECIMAL, | ||
NumberFormatter::TYPE_DEFAULT, | ||
"de_DE" | ||
); | ||
// This returns: '1.234.567,891' | ||
]]></programlisting> | ||
|
||
<para> | ||
<methodname>numberFormat($number, $formatStyle, $formatType, $locale)</methodname> | ||
</para> | ||
|
||
<itemizedlist> | ||
<listitem> | ||
<para> | ||
<varname>$number</varname> : The numeric value. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para> | ||
<varname>$formatStyle</varname> : (Optional) Style of the formatting, one of the format style constants. | ||
If unset, it will use <varname>NumberFormatter::DECIMAL</varname> as the default style. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para> | ||
<varname>$formatType</varname> : (Optional) The formatting type to use. If unset, will use | ||
<varname>NumberFormatter::TYPE_DEFAULT</varname> as the default type. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para> | ||
<varname>$locale</varname> : (Optional) Locale in which the number would be formatted (locale name, e.g. en_US). | ||
If unset, it will use the default locale (<classname>Locale::getDefault()</classname>) | ||
</para> | ||
</listitem> | ||
</itemizedlist> | ||
|
||
</example> | ||
|
||
<example xml:id="zend.i18n.view.helper.number-format.setter-usage"><title>NumberFormat Setters</title> | ||
<para> | ||
The <varname>$formatStyle</varname>, <varname>$formatType</varname>, and | ||
<varname>$locale</varname> can be set prior to formatting | ||
so that they are not required each time the helper is used: | ||
</para> | ||
|
||
<programlisting language="php"><![CDATA[ | ||
// Within your view | ||
$this->plugin("numberformat") | ||
->setFormatStyle(NumberFormatter::PERCENT) | ||
->setFormatType(NumberFormatter::TYPE_DOUBLE) | ||
->setLocale("en_US"); | ||
echo $this->numberFormat(0.56); // "56%" | ||
echo $this->numberFormat(0.90); // "90%" | ||
$this->plugin("numberformat") | ||
->setLocale("de_DE"); | ||
echo $this->numberFormat(0.56); // "56 %" | ||
echo $this->numberFormat(0.90); // "90 %" | ||
]]></programlisting> | ||
|
||
</example> | ||
</section> |
28 changes: 28 additions & 0 deletions
28
documentation/manual/en/module_specs/zend.i18n.view.helpers.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<section xmlns="http://docbook.org/ns/docbook" version="5.0" | ||
xml:id="zend.view.helpers"> | ||
<title>I18n View Helpers</title> | ||
|
||
<para> | ||
In your view scripts, often it is necessary to perform certain complex functions over and | ||
over: e.g., formatting a date, formatting currency, or displaying translated content. You can | ||
use helper, or plugin, classes to perform these behaviors for you. | ||
</para> | ||
|
||
<para> | ||
See the section on <link linkend="zend.view.helpers">view helpers</link> for more information. | ||
</para> | ||
|
||
<section xml:id="zend.view.helpers.initial"> | ||
<title>Included I18n Helpers</title> | ||
|
||
<para> | ||
Zend Framework comes with an initial set of helper classes related to Internationalization. | ||
The currently shipped helpers include: | ||
</para> | ||
|
||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.view.helper.currency-format.xml"/> | ||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.view.helper.number-format.xml"/> | ||
</section> | ||
|
||
</section> |