Skip to content

Commit

Permalink
Merge branch 'docs/view-helpers' of https://github.com/cgmartin/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jul 11, 2012
2 parents 27e334f + 733be69 commit f6b4d59
Show file tree
Hide file tree
Showing 6 changed files with 281 additions and 19 deletions.
6 changes: 6 additions & 0 deletions documentation/manual/en/manual.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,12 @@
</xi:fallback>
</xi:include>

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module_specs/zend.i18n.filters.xml" parse="xml">
<xi:fallback>
<xi:include href="../en/module_specs/zend.i18n.filters.xml" parse="xml"/>
</xi:fallback>
</xi:include>

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="module_specs/zend.i18n.view.helpers.xml" parse="xml">
<xi:fallback>
<xi:include href="../en/module_specs/zend.i18n.view.helpers.xml" parse="xml"/>
Expand Down
81 changes: 81 additions & 0 deletions documentation/manual/en/module_specs/zend.i18n.filter.alnum.xml
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.filter.alnum">
<title>Alnum Filter</title>

<para>
The <classname>Alnum</classname> filter can be used to return
only alphabetic characters and digits in the
unicode "letter" and "number" categories, respectively.
All other characters are supressed.
</para>

<example xml:id="zend.i18n.filter.alnum.options">
<title>Supported options for Alnum Filter</title>

<para>
The following options are supported for <classname>Alnum</classname>:
</para>

<para>
<methodname>Alnum([ boolean $allowWhiteSpace [, string $locale ]])</methodname>
</para>

<itemizedlist>
<listitem>
<para>
<varname>$allowWhiteSpace</varname> : If set to true then
whitespace characters are allowed. Otherwise they are
suppressed. Default is "false" (whitespace is not allowed).
</para>
<para>
Methods for getting/setting the allowWhiteSpace option
are also available:
<methodname>getAllowWhiteSpace()</methodname> and
<methodname>setAllowWhiteSpace()</methodname>
</para>
</listitem>
<listitem>
<para>
<varname>$locale</varname> : The locale string used in
identifying the characters to filter
(locale name, e.g. en_US). If unset, it will use the
default locale
(<classname>Locale::getDefault()</classname>).
</para>
<para>
Methods for getting/setting the locale are also available:
<methodname>getLocale()</methodname> and
<methodname>setLocale()</methodname>
</para>
</listitem>
</itemizedlist>
</example>

<example xml:id="zend.i18n.filter.alnum.usage">
<title>Alnum Filter Usage</title>

<programlisting language="php"><![CDATA[
// Default settings, deny whitespace
$filter = \Zend\I18n\Filter\Alnum();
echo $filter->filter("This is (my) content: 123");
// Returns "Thisismycontent123"
// First param in constructor is $allowWhiteSpace
$filter = \Zend\I18n\Filter\Alnum(true);
echo $filter->filter("This is (my) content: 123");
// Returns "This is my content 123"
]]></programlisting>

<note>
<para>
Note: <classname>Alnum</classname> works on almost all
languages, except: Chinese, Japanese and Korean.
Within these languages the english alphabet is used
instead of the characters from these languages.
The language itself is detected using the
<classname>Locale</classname>.
</para>
</note>
</example>

</section>
81 changes: 81 additions & 0 deletions documentation/manual/en/module_specs/zend.i18n.filter.alpha.xml
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.filter.alpha">
<title>Alpha Filter</title>

<para>
The <classname>Alpha</classname> filter can be used to return
only alphabetic characters in the unicode "letter" category.
All other characters are supressed.
</para>

<example xml:id="zend.i18n.filter.alpha.options">
<title>Supported options for Alpha Filter</title>

<para>
The following options are supported for <classname>Alpha</classname>:
</para>

<para>
<methodname>Alpha([ boolean $allowWhiteSpace [, string $locale ]])</methodname>
</para>

<itemizedlist>
<listitem>
<para>
<varname>$allowWhiteSpace</varname> : If set to true then
whitespace characters are allowed. Otherwise they are
suppressed. Default is "false" (whitespace is not allowed).
</para>
<para>
Methods for getting/setting the allowWhiteSpace option
are also available:
<methodname>getAllowWhiteSpace()</methodname> and
<methodname>setAllowWhiteSpace()</methodname>
</para>
</listitem>
<listitem>
<para>
<varname>$locale</varname> : The locale string used in
identifying the characters to filter
(locale name, e.g. en_US). If unset, it will use the
default locale
(<classname>Locale::getDefault()</classname>).
</para>
<para>
Methods for getting/setting the locale are also available:
<methodname>getLocale()</methodname> and
<methodname>setLocale()</methodname>
</para>
</listitem>
</itemizedlist>
</example>

<example xml:id="zend.i18n.filter.alpha.usage">
<title>Alpha Filter Usage</title>

<programlisting language="php"><![CDATA[
// Default settings, deny whitespace
$filter = \Zend\I18n\Filter\Alpha();
echo $filter->filter("This is (my) content: 123");
// Returns "Thisismycontent"
// Allow whitespace
$filter = \Zend\I18n\Filter\Alpha(true);
echo $filter->filter("This is (my) content: 123");
// Returns "This is my content "
]]></programlisting>

<note>
<para>
Note: <classname>Alpha</classname> works on almost all
languages, except: Chinese, Japanese and Korean.
Within these languages the english alphabet is used
instead of the characters from these languages.
The language itself is detected using the
<classname>Locale</classname>.
</para>

</note>
</example>

</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="zend.i18n.filter.number-format">
<title>NumberFormat Filter</title>

<para>
The <classname>NumberFormat</classname> filter can be used to return
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.filter.number-format.options">
<title>Supported options for NumberFormat Filter</title>

<para>
The following options are supported for <classname>NumberFormat</classname>:
</para>

<para>
<methodname>NumberFormat([ string $locale [, int $style [, int $type ]]])</methodname>
</para>

<itemizedlist>
<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>

<para>
Methods for getting/setting the locale are also available:
<methodname>getLocale()</methodname> and
<methodname>setLocale()</methodname>
</para>
</listitem>
<listitem>
<para>
<varname>$style</varname> : (Optional) Style of the formatting, one of the
<link xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="http://us.php.net/manual/en/class.numberformatter.php#intl.numberformatter-constants.unumberformatstyle"
>format style constants</link>.
If unset, it will use <varname>NumberFormatter::DEFAULT_STYLE</varname> as the default style.
</para>
<para>
Methods for getting/setting the format style are also available:
<methodname>getStyle()</methodname> and
<methodname>setStyle()</methodname>
</para>
</listitem>
<listitem>
<para>
<varname>$type</varname> : (Optional) The
<link xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="http://us.php.net/manual/en/class.numberformatter.php#intl.numberformatter-constants.types"
>formatting type</link> to use.
If unset, it will use <varname>NumberFormatter::TYPE_DOUBLE</varname> as the default type.
</para>
<para>
Methods for getting/setting the format type are also available:
<methodname>getType()</methodname> and
<methodname>setType()</methodname>
</para>
</listitem>

</itemizedlist>
</example>

<example xml:id="zend.i18n.filter.number-format.usage">
<title>NumberFormat Filter Usage</title>

<programlisting language="php"><![CDATA[
$filter = \Zend\I18n\Filter\NumberFormat("de_DE");
echo $filter->filter(1234567.8912346);
// Returns "1.234.567,891"
$filter = \Zend\I18n\Filter\NumberFormat("en_US", NumberFormatter::PERCENT);
echo $filter->filter(0.80);
// Returns "80%"
$filter = \Zend\I18n\Filter\NumberFormat("fr_FR", NumberFormatter::SCIENTIFIC);
echo $filter->filter(0.00123456789);
// Returns "1,23456789E-3"
]]></programlisting>
</example>

</section>
13 changes: 13 additions & 0 deletions documentation/manual/en/module_specs/zend.i18n.filters.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0"
xml:id="zend.i18n.filters">
<title>I18n Filters</title>

<para>
Zend Framework comes with a set of filters related to Internationalization.
</para>

<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.filter.alnum.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.filter.alpha.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.filter.number-format.xml"/>
</section>
33 changes: 14 additions & 19 deletions documentation/manual/en/module_specs/zend.i18n.view.helpers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,24 @@
xml:id="zend.i18n.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.i18n.view.helpers.initial">
<title>Included I18n Helpers</title>
<section xml:id="zend.i18n.view.helpers.intro">
<title>Introduction</title>

<para>
Zend Framework comes with an initial set of helper classes related to Internationalization.
The currently shipped helpers include:
Zend Framework comes with an initial set of helper classes related to Internationalization:
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>

<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.date-format.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.view.helper.number-format.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.view.helper.translate.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.view.helper.translate-plural.xml"/>
<para>
See the section on <link linkend="zend.view.helpers">view helpers</link> for more information.
</para>
</section>

<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.date-format.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.view.helper.number-format.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.view.helper.translate.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zend.i18n.view.helper.translate-plural.xml"/>

</section>

0 comments on commit f6b4d59

Please sign in to comment.