<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.locale.functions">
    <title>Using Zend_Locale</title>

    <para>
        <classname>Zend_Locale</classname> also provides localized information about locales for
        each locale, including localized names for other locales, days of the week, month names,
        etc.
    </para>

    <sect2 id="zend.locale.copying">
        <title>Copying, Cloning, and Serializing Locale Objects</title>

        <para>
            Use <ulink url="http://php.net/language.oop5.cloning">object cloning</ulink> to
            duplicate a locale object exactly and efficiently. Most locale-aware methods also accept
            string representations of locales, such as the result of
            <command>$locale->toString()</command>.
        </para>

        <example id="zend.locale.copying.example-1">
            <title>clone</title>

            <programlisting language="php"><![CDATA[
$locale = new Zend_Locale('ar');

// Save the $locale object as a serialization
$serializedLocale = $locale->serialize();
// re-create the original object
$localeObject = unserialize($serializedLocale);

// Obtain a string identification of the locale
$stringLocale = $locale->toString();

// Make a cloned copy of the $local object
$copiedLocale = clone $locale;

print "copied: ", $copiedLocale->toString();

// PHP automatically calls toString() via __toString()
print "copied: ", $copiedLocale;
]]></programlisting>
        </example>
    </sect2>

    <sect2 id="zend.locale.equals">
        <title>Equality</title>

        <para>
            <classname>Zend_Locale</classname> also provides a convenience function to compare two
            locales. All locale-aware classes should provide a similar equality check.
        </para>

        <example id="zend.locale.equals.example-1">
            <title>Check for equal locales</title>

            <programlisting language="php"><![CDATA[
$locale = new Zend_Locale();
$mylocale = new Zend_Locale('en_US');

// Check if locales are equal
if ($locale->equals($mylocale)) {
    print "Locales are equal";
}
]]></programlisting>
        </example>
    </sect2>

    <sect2 id="zend.locale.getdefault">
        <title>Default locales</title>

        <para>
            The method <methodname>getDefault()</methodname> returns an array of relevant locales
            using information from the user's web browser (if available), information from the
            environment of the host server, and Zend Framework settings. As with the constructor
            for <classname>Zend_Locale</classname>, the first parameter selects a preference of
            which information to consider <link
                linkend="zend.locale.selection">(<constant>BROWSER</constant>,
                <constant>ENVIRONMENT</constant>, or <constant>FRAMEWORK</constant></link> first.
            The second parameter toggles between returning all matching locales or only the
            first or best match. Locale-aware components normally use only the first locale. A
            quality rating is included, when available.
        </para>

        <example id="zend.locale.getdefault.example-1">
            <title>Get default locales</title>

            <programlisting language="php"><![CDATA[
$locale = new Zend_Locale();

// Return all default locales
$found = $locale->getDefault();
print_r($found);

// Return only browser locales
$found2 = $locale->getDefault(Zend_Locale::BROWSER,TRUE);
print_r($found2);
]]></programlisting>
        </example>

        <para>
            To obtain only the default locales relevant to the <link
                linkend="zend.locale.selection"><constant>BROWSER</constant>,
                <constant>ENVIRONMENT</constant>, or <constant>FRAMEWORK</constant></link>, use
            the corresponding method:

            <itemizedlist>
                <listitem>
                    <para>
                        <methodname>getEnvironment()</methodname>
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <methodname>getBrowser()</methodname>
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <methodname>getLocale()</methodname>
                    </para>
                </listitem>
            </itemizedlist>
        </para>
    </sect2>

    <sect2 id="zend.locale.setlocale">
        <title>Set a new locale</title>

        <para>
            A new locale can be set with the function <methodname>setLocale()</methodname>. This
            function takes a locale string as parameter. If no locale is given, a locale is
            <link linkend="zend.locale.selection">automatically selected</link>.
        </para>

        <example id="zend.locale.setlocale.example-1">
            <title>setLocale</title>

            <programlisting language="php"><![CDATA[
$locale = new Zend_Locale();

// Actual locale
print $locale->toString();

// new locale
$locale->setLocale('aa_DJ');
print $locale->toString();
]]></programlisting>
        </example>
    </sect2>

    <sect2 id="zend.locale.getlocale">
        <title>Getting the language and region</title>

        <para>
            Use <methodname>getLanguage()</methodname> to obtain a string containing the two
            character language code from the string locale identifier. Use
            <methodname>getRegion()</methodname> to obtain a string containing the two character
            region code from the string locale identifier.
        </para>

        <example id="zend.locale.getlocale.example-1">
            <title>getLanguage and getRegion</title>

            <programlisting language="php"><![CDATA[
$locale = new Zend_Locale();

// if locale is 'de_AT' then 'de' will be returned as language
print $locale->getLanguage();

// if locale is 'de_AT' then 'AT' will be returned as region
print $locale->getRegion();
]]></programlisting>
        </example>
    </sect2>

    <sect2 id="zend.locale.getlocaletoterritory">
        <title>Get the locale by giving a territory</title>

        <para>
            When you only have the territory or country then it's also possible to get a locale
            from that information. You can manually search if there is a locale for this territory
            by using <methodname>getLocaleToTerritory()</methodname>. This method returns a
            locale for the given territory or <constant>NULL</constant> when there was has no locale
            been found.
        </para>

        <example id="zend.locale.getlocaletoterritory.example-1">
            <title>getLocaleToTerritory</title>

            <programlisting language="php"><![CDATA[
$locale = Zend_Locale::getLocaleToTerritory('US');
// returns 'en_US'
]]></programlisting>
        </example>

        <note>
            <title>Uppercase territories</title>

            <para>
                When you know that you are using a territory, then you should uppercase it.
                Otherwise you could get an in your eyes false locale in return when you use other
                methods. For example: When you give "om" then
                <methodname>getLocaleToTerritory()</methodname> returns you "ar_OM" as it knows that
                you mean a territory. But all other methods will return "om", as it's also a
                language.
            </para>

            <para>
                So when you know that the given string is a territory, eighter use
                <methodname>getLocaleToTerritory()</methodname> yourself before creating a locale,
                or uppercase the input.
            </para>
        </note>
    </sect2>

    <sect2 id="zend.locale.getdata">
        <title>Obtaining localized strings</title>

        <para>
            <methodname>getTranslationList()</methodname> gives you access to localized information
            of several types. These information are useful if you want to display localized data to
            a customer without the need of translating it. They are already available for your
            usage.
        </para>

        <para>
            The requested list of information is always returned as named array. If you want to give
            more than one value to a explicit type where you wish to receive values from, you have
            to give an array instead of multiple values.
        </para>

        <example id="zend.locale.getdata.example-1">
            <title>getTranslationList</title>

            <programlisting language="php"><![CDATA[
$list = Zend_Locale::getTranslationList('language', 'de_AT');

print_r ($list);
// example key -> value pairs...
// [de] -> Deutsch
// [en] -> Englisch

// use one of the returned key as value for the getTranslation() method
// of another language
print Zend_Locale::getTranslation('de', 'language', 'zh');
// returns the translation for the language 'de' in chinese
]]></programlisting>
        </example>

        <para>
            You can receive this information for all languages. But not all information is
            completely available for all languages. Some of these types are also available through
            an own function for simplicity. See this list for detailed information.
        </para>

        <table id="zend.locale.getdata.table-1">
            <title>
                Details for getTranslationList($type = null, $locale = null, $value = null)
            </title>

            <tgroup cols="2">
                <thead>
                    <row>
                        <entry>Type</entry>
                        <entry>Description</entry>
                    </row>
                </thead>

                <tbody>
                    <row>
                        <entry><emphasis>Language</emphasis></entry>

                        <entry>
                            Returns a localized list of all languages. The language part of the
                            locale is returned as key and the translation as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Script</emphasis></entry>

                        <entry>
                            Returns a localized list of all scripts. The script is returned as key
                            and the translation as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Territory</emphasis></entry>

                        <entry>
                            Returns a localized list of all territories. This contains countries,
                            continents and territories. To get only territories and continents use
                            '1' as value. To get only countries use '2' as value. The country part
                            of the locale is used as key where applicable. In the other case the
                            official <acronym>ISO</acronym> code for this territory is used. The
                            translated territory is returned as value. When you omit the value you
                            will get a list with both.
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Variant</emphasis></entry>

                        <entry>
                            Returns a localized list of known variants of scripts. The variant is
                            returned as key and the translation as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Key</emphasis></entry>

                        <entry>
                            Returns a localized list of known keys. This keys are generic values
                            used in translation. These are normally calendar, collation and
                            currency. The key is returned as array key and the translation as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Type</emphasis></entry>

                        <entry>
                            Returns a localized list of known types of keys. These are variants of
                            types of calendar representations and types of collations. When you use
                            'collation' as value you will get all types of collations returned. When
                            you use 'calendar' as value you will get all types of calendars
                            returned. When you omit the value you will get a list all both returned.
                            The type is used as key and the translation as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Layout</emphasis></entry>

                        <entry>
                            Returns a list of rules which describes how to format special text parts
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Characters</emphasis></entry>
                        <entry>Returns a list of allowed characters within this locale</entry>
                    </row>

                    <row>
                        <entry><emphasis>Delimiters</emphasis></entry>
                        <entry>Returns a list of allowed quoting characters for this locale</entry>
                    </row>

                    <row>
                        <entry><emphasis>Measurement</emphasis></entry>

                        <entry>
                            Returns a list of known measurement values. This list is depreciated
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Months</emphasis></entry>

                        <entry>
                            Returns a list of all month representations within this locale. There
                            are several different representations which are all returned as sub
                            array. If you omit the value you will get a list of all months from the
                            'gregorian' calendar returned. You can give any known calendar as value
                            to get a list of months from this calendar returned. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Month</emphasis></entry>

                        <entry>
                            Returns a localized list of all month names for this locale. If you omit
                            the value you will get the normally used gregorian full name of the
                            months where each month number is used as key and the translated month
                            is returned as value. You can get the months for different calendars and
                            formats if you give an array as value. The first array entry has to be
                            the calendar, the second the used context and the third the width to
                            return. Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Days</emphasis></entry>

                        <entry>
                            Returns a list of all day representations within this locale. There are
                            several different representations which are all returned as sub array.
                            If you omit the value you will get a list of all days from the
                            'gregorian' calendar returned. You can give any known calendar as value
                            to get a list of days from this calendar returned. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Day</emphasis></entry>

                        <entry>
                            Returns a localized list of all day names for this locale. If you omit
                            the value you will get the normally used gregorian full name of the days
                            where the english day abbreviation is used as key and the translated day
                            is returned as value. You can get the days for different calendars and
                            formats if you give an array as value. The first array entry has to be
                            the calendar, the second the used context and the third the width to
                            return. Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Week</emphasis></entry>

                        <entry>
                            Returns a list of values used for proper week calculations within a
                            locale. Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Quarters</emphasis></entry>

                        <entry>
                            Returns a list of all quarter representations within this locale. There
                            are several different representations which are all returned as sub
                            array. If you omit the value you will get a list of all quarters from
                            the 'gregorian' calendar returned. You can give any known calendar as
                            value to get a list of quarters from this calendar returned
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Quarter</emphasis></entry>

                        <entry>
                            Returns a localized list of all quarter names for this locale. If you
                            omit the value you will get the normally used gregorian full name of the
                            quarters where each quarter number is used as key and the translated
                            quarter is returned as value. You can get the quarters for different
                            calendars and formats if you give an array as value. The first array
                            entry has to be the calendar, the second the used context and the third
                            the width to return
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Eras</emphasis></entry>

                        <entry>
                            Returns a list of all era representations within this locale. If you
                            omit the value you will get a list of all eras from the 'gregorian'
                            calendar returned. You can give any known calendar as value to get a
                            list of eras from this calendar returned
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Era</emphasis></entry>

                        <entry>
                            Returns a localized list of all era names for this locale. If you omit
                            the value you will get the normally used gregorian full name of the eras
                            where each era number is used as key and the translated era is returned
                            as value. You can get the eras for different calendars and formats if
                            you give an array as value. The first array entry has to be the calendar
                            and the second the width to return
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Date</emphasis></entry>

                        <entry>
                            Returns a localized list of all date formats for this locale. The name
                            of the dateformat is used as key and the format itself as value.If you
                            omit the value you will get the date formats for the gregorian calendar
                            returned. You can get the date formats for different calendars if you
                            give the wished calendar as string. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Time</emphasis></entry>

                        <entry>
                            Returns a localized list of all time formats for this locale. The name
                            of the timeformat is used as key and the format itself as value. If you
                            omit the value you will get the time formats for the gregorian calendar
                            returned. You can get the time formats for different calendars if you
                            give the wished calendar as string. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DateTime</emphasis></entry>

                        <entry>
                            Returns a localized list of all known date-time formats for this locale.
                            The name of the date-time format is used as key and the format itself as
                            value. If you omit the value you will get the date-time formats for the
                            gregorian calendar returned. You can get the date-time formats for
                            different calendars if you give the wished calendar as string. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DateItem</emphasis></entry>

                        <entry>
                            Returns a list of default formats for given date or time items
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DateInterval</emphasis></entry>

                        <entry>
                            Returns a list of date or time formats which are used when you want to
                            display intervals. The list is a multidimentional array where the first
                            dimension is the interval format, and the second dimension is the token
                            with the greatest difference.
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Field</emphasis></entry>

                        <entry>
                            Returns a localized list of date fields which can be used to display
                            calendars or date strings like 'month' or 'year' in a wished language.
                            If you omit the value you will get this list for the gregorian calendar
                            returned. You can get the list for different calendars if you give the
                            wished calendar as string
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Relative</emphasis></entry>

                        <entry>
                            Returns a localized list of relative dates which can be used to display
                            textual relative dates like 'yesterday' or 'tomorrow' in a wished
                            language. If you omit the value you will get this list for the gregorian
                            calendar returned. You can get the list for different calendars if you
                            give the wished calendar as string
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Symbols</emphasis></entry>

                        <entry>
                            Returns a localized list of characters used for number representations
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>NameToCurrency</emphasis></entry>

                        <entry>
                            Returns a localized list of names for currencies. The currency is used
                            as key and the translated name as value. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyToName</emphasis></entry>

                        <entry>
                            Returns a list of currencies for localized names. The translated name is
                            used as key and the currency as value. Use  <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencySymbol</emphasis></entry>

                        <entry>
                            Returns a list of known localized currency symbols for currencies. The
                            currency is used as key and the symbol as value. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Question</emphasis></entry>

                        <entry>
                            Returns a list of localized strings for acceptance ('yes') and
                            negation ('no'). Use <link
                                linkend="zend.locale.getquestion">Zend_Locale's getQuestion
                                method</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyFraction</emphasis></entry>

                        <entry>
                            Returns a list of fractions for currency values. The currency is used as
                            key and the fraction as integer value. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyRounding</emphasis></entry>

                        <entry>
                            Returns a list of how to round which currency. The currency is used as
                            key and the rounding as integer value. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyToRegion</emphasis></entry>

                        <entry>
                            Returns a list of currencies which are known to be used within a region.
                            The <constant>ISO3166</constant> value ('region') is used as array key
                            and the <constant>ISO4217</constant> value ('currency') as array value.
                            Use <link linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>RegionToCurrency</emphasis></entry>

                        <entry>
                            Returns a list of regions where a currency is used . The
                            <constant>ISO4217</constant> value ('currency') is used as array key and
                            the <constant>ISO3166</constant> value ('region') as array value. When a
                            currency is used in several regions these regions are separated with a
                            whitespace. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>RegionToTerritory</emphasis></entry>

                        <entry>
                            Returns a list of territories with the countries or sub territories
                            which are included within that territory. The <acronym>ISO</acronym>
                            territory code ('territory') is used as array key and the
                            <constant>ISO3166</constant> value ('region') as array value. When a
                            territory contains several regions these regions are separated with a
                            whitespace
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToRegion</emphasis></entry>

                        <entry>
                            Returns a list of regions and the territories where these regions are
                            located. The <constant>ISO3166</constant> code ('region') is used as
                            array key and the <acronym>ISO</acronym> territory code ('territory') as
                            array value. When a region is located in several territories these
                            territories are separated with a whitespace
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>ScriptToLanguage</emphasis></entry>

                        <entry>
                            Returns a list of scripts which are used within a language. The language
                            code is used as array key and the script code as array value. When a
                            language contains several scripts these scripts are separated with a
                            whitespace
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>LanguageToScript</emphasis></entry>

                        <entry>
                            Returns a list of languages which are using a script. The script code
                            is used as array key and the language code as array value. When a script
                            is used in several languages these languages are separated with a
                            whitespace
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToLanguage</emphasis></entry>

                        <entry>
                            Returns a list of languages and the countries where they are spoken. The
                            language is used as array key and the country code as array value. When
                            a language is used in several countries these countries are separated
                            with a whitespace
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>LanguageToTerritory</emphasis></entry>

                        <entry>
                            Returns a list of countries and the languages which are spoken within
                            them. The country code is used as array key and the language code
                            as array value. When several languages are spoken within a territory
                            then these languages are separated with a whitespace
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TimezoneToWindows</emphasis></entry>

                        <entry>
                            Returns a list of windows timezones and the related
                            <acronym>ISO</acronym> timezone. The windows timezone is used as array
                            key and the <acronym>ISO</acronym> timezone as array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>WindowsToTimezone</emphasis></entry>

                        <entry>
                            Returns a list of <acronym>ISO</acronym> timezones and the related
                            windows timezone. The <acronym>ISO</acronym> timezone is used as array
                            key and the windows timezone as array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToTimezone</emphasis></entry>

                        <entry>
                            Returns a list of regions or territories and the related
                            <acronym>ISO</acronym> timezone. The <acronym>ISO</acronym> timezone is
                            used as array key and the territory code as array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TimezoneToTerritory</emphasis></entry>

                        <entry>
                            Returns a list of timezones and the related region or territory code.
                            The region or territory code is used as array key and the
                            <acronym>ISO</acronym> timezone as array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CityToTimezone</emphasis></entry>

                        <entry>
                            Returns a localized list of cities which can be used as translation for
                            a related timezone. Not for all timezones is a translation available,
                            but for a user is the real city written in his languages more accurate
                            than the <acronym>ISO</acronym> name of this timezone. The
                            <acronym>ISO</acronym> timezone is used as array key and the translated
                            city as array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TimezoneToCity</emphasis></entry>

                        <entry>
                            Returns a list of timezones for localized city names. The localized city
                            is used as array key and the <acronym>ISO</acronym> timezone name as
                            array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>PhoneToTerritory</emphasis></entry>

                        <entry>
                            Returns a list of phone codes which are known to be used within a
                            territory. The territory (region) is used as array key and the telephone
                            code as array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToPhone</emphasis></entry>

                        <entry>
                            Returns a list of territories where a phone is used . The phone code
                            is used as array key and the territory (region) as array value. When a
                            phone code is used in several territories these territories are
                            separated with a whitespace
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>NumericToTerritory</emphasis></entry>

                        <entry>
                            Returns a list of 3 digit number codes for territories.
                            The territory (region) is used as array key and the 3 digit number code
                            as array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToNumeric</emphasis></entry>

                        <entry>
                            Returns a list of territories with their 3 digit number code. The 3
                            digit number code is used as array key and the territory (region) as
                            array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Alpha3ToTerritory</emphasis></entry>

                        <entry>
                            Returns a list of 3 sign character codes for territories.
                            The territory (region) is used as array key and the 3 sign character
                            code as array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToAlpha3</emphasis></entry>

                        <entry>
                            Returns a list of territories with their 3 sign character code. The 3
                            sign character code is used as array key and the territory (region) as
                            array value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>PostalToTerritory</emphasis></entry>

                        <entry>
                            Returns a list of territories with a regex for postal codes which are
                            included within that territory. The <acronym>ISO</acronym> territory
                            code ('territory') is used as array key and the regex as array value.
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>NumberingSystem</emphasis></entry>

                        <entry>
                            Returns a list of scripts with the notation for digits used within the
                            script
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>FallbackToChar</emphasis></entry>

                        <entry>
                            Returns a list of replacement characters for often used unicode
                            characters. This can be used to replace "©" with "(C)" for example
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CharToFallback</emphasis></entry>

                        <entry>
                            Returns a list of unicode characters for often used replacement
                            characters. This can be used to replace "(C)" with "©" for example
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>LocaleUpgrade</emphasis></entry>

                        <entry>
                            Returns a list of locale dependencies which can be used to upgrade a
                            language to a full qualified locale
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Unit</emphasis></entry>

                        <entry>
                            Returns a list of localized calendar units. This can be used to
                            translate the strings "day", "month" and so on automatically
                        </entry>
                    </row>
                </tbody>
            </tgroup>
        </table>

        <para>
            If you are in need of a single translated value, you can use the
            <methodname>getTranslation()</methodname> method. It always returns a string but it
            accepts some different types than the <methodname>getTranslationList()</methodname>
            method. Also value is the same as before with one difference. You have to give the
            detail you want to get returned as additional value.
        </para>

        <note>
            <para>
                Because you have almost always give a value as detail this parameter has to be given
                as first parameter. This differs from the
                <methodname>getTranslationList()</methodname> method.
            </para>
        </note>

        <para>
            See the following table for detailed information:
        </para>

        <table id="zend.locale.getdata.table-2">
            <title>Details for getTranslation($value = null, $type = null, $locale = null)</title>

            <tgroup cols="2">
                <thead>
                    <row>
                        <entry>Type</entry>
                        <entry>Description</entry>
                    </row>
                </thead>

                <tbody>
                    <row>
                        <entry><emphasis>Language</emphasis></entry>

                        <entry>
                            Returns a translation for a language. To select the wished translation
                            you must give the language code as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Script</emphasis></entry>

                        <entry>
                            Returns a translation for a script. To select the wished translation you
                            must give the script code as value
                        </entry>
                    </row>

                    <row>
                        <entry>
                            <emphasis>Territory</emphasis> or <emphasis>Country</emphasis>
                        </entry>

                        <entry>
                            Returns a translation for a territory. This can be countries, continents
                            and territories. To select the wished variant you must give the
                            territory code as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Variant</emphasis></entry>

                        <entry>
                            Returns a translation for a script variant. To select the wished variant
                            you must give the variant code as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Key</emphasis></entry>

                        <entry>
                            Returns translation for a known keys. This keys are generic values used
                            in translation. These are normally calendar, collation and currency. To
                            select the wished key you must give the key code as value
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DefaultCalendar</emphasis></entry>

                        <entry>
                            Returns the default calendar for the given locale. For most locales this
                            will be 'gregorian'. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>MonthContext</emphasis></entry>

                        <entry>
                            Returns the default context for months which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used.
                            Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DefaultMonth</emphasis></entry>

                        <entry>
                            Returns the default format for months which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used.
                            Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Month</emphasis></entry>

                        <entry>
                            Returns a translation for a month. You have to give the number of the
                            month as integer value. It has to be between 1 and 12. If you want to
                            receive data for other calendars, contexts or formats, then you must
                            give an array instead of an integer with the expected values. The array
                            has to look like this: <command>array( 'calendar', 'context', 'format',
                                'month number')</command>. If you give only an integer then the
                            default values are the 'gregorian' calendar, the context 'format' and
                            the format 'wide'. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DayContext</emphasis></entry>

                        <entry>
                            Returns the default context for ´days which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used.
                            Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DefaultDay</emphasis></entry>

                        <entry>
                            Returns the default format for days which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used.
                            Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Day</emphasis></entry>

                        <entry>
                            Returns a translation for a day. You have to give the english
                            abbreviation of the day as string value ('sun', 'mon', etc.). If you
                            want to receive data for other calendars, contexts or format, then you
                            must give an array instead of an integer with the expected values. The
                            array has to look like this: <methodname>array('calendar', 'context',
                                'format', 'day abbreviation')</methodname>. If you give only an
                            string then the default values are the 'gregorian' calendar, the context
                            'format' and the format 'wide'. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Quarter</emphasis></entry>

                        <entry>
                            Returns a translation for a quarter. You have to give the number of the
                            quarter as integer and it has to be between 1 and 4. If you want to
                            receive data for other calendars, contexts or formats, then you must
                            give an array instead of an integer with the expected values. The array
                            has to look like this: <methodname>array('calendar', 'context',
                                'format', 'quarter number')</methodname>. If you give only an
                            string then the default values are the 'gregorian' calendar,
                            the context 'format' and the format 'wide'
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Am</emphasis></entry>

                        <entry>
                            Returns translation for 'AM' in the expected locale. If you want to
                            receive data for other calendars provide a string with the expected
                            calendar. If you omit the value then the 'gregorian' calendar will be
                            used. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Pm</emphasis></entry>

                        <entry>
                            Returns translation for 'PM' in the expected locale. If you want to
                            receive data for other calendars provide a string with the expected
                            calendar. If you omit the value then the 'gregorian' calendar will be
                            used. Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Era</emphasis></entry>

                        <entry>
                            Returns a translation for an era within a locale. You have to give the
                            era number as string or integer. If you want to receive data for other
                            calendars or formats, then you must give an array instead of the era
                            number with the expected values. The array has to look like this:
                            <methodname>array('calendar', 'format', 'era number')</methodname>. If
                            you give only a string then the default values are the 'gregorian'
                            calendar and the 'abbr' format
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DefaultDate</emphasis></entry>

                        <entry>
                            Returns the default date format which is used within the given
                            calendar. If you omit the value the 'gregorian' calendar will be used.
                            Use <link linkend="zend.date.introduction">Zend_Date</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Date</emphasis></entry>

                        <entry>
                            Returns the date format for a given calendar or format within a locale.
                            If you omit the value then the 'gregorian' calendar will be used with
                            the 'medium' format. If you give a string then the 'gregorian' calendar
                            will be used with the given format. Or you can also give an array which
                            will have to look like this: <methodname>array('calendar',
                                'format')</methodname>. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DefaultTime</emphasis></entry>

                        <entry>
                            Returns the default time format which is used within the given calendar.
                            If you omit the value the 'gregorian' calendar will be used. Use
                            <link linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Time</emphasis></entry>

                        <entry>
                            Returns the time format for a given calendar or format within a locale.
                            If you omit the value then the 'gregorian' calendar will be used with
                            the 'medium' format. If you give a string then the 'gregorian' calendar
                            will be used with the given format. Or you can also give an array which
                            will have to look like this:
                            <methodname>array('calendar', 'format')</methodname>. Use <link
                                linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DateTime</emphasis></entry>

                        <entry>
                            Returns the datetime format for the given locale which indicates how to
                            display date with times in the same string within the given calendar. If
                            you omit the value the 'gregorian' calendar will be used. Use
                            <link linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DateItem</emphasis></entry>
                        <entry>Returns the default format for a given date or time item</entry>
                    </row>

                    <row>
                        <entry><emphasis>DateInterval</emphasis></entry>

                        <entry>
                            Returns the interval format for a given date or time format. The first
                            value is the calendar format, normally 'gregorian'. The second value is
                            the interval format and the third value the token with the greatest
                            difference. For example: array('gregorian', 'yMMMM', 'y') returns the
                            interval format for the date format 'yMMMM' where 'y' has the greatest
                            difference.
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Field</emphasis></entry>

                        <entry>
                            Returns a translated date field which can be used to display calendars
                            or date strings like 'month' or 'year' in a wished language. You must
                            give the field which has to be returned as string. In this case the
                            'gregorian' calendar will be used. You can get the field for other
                            calendar formats if you give an array which has to look like this:
                            <methodname>array('calendar', 'date field')</methodname>
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Relative</emphasis></entry>

                        <entry>
                            Returns a translated date which is relative to today which can include
                            date strings like 'yesterday' or 'tomorrow' in a wished language. You
                            have to give the number of days relative to tomorrow to receive the
                            expected string. Yesterday would be '-1', tomorrow '1' and so on. This
                            will use the 'gregorian' calendar. if you want to get relative dates for
                            other calendars you will have to give an array which has to look like
                            this: <methodname>array('calendar', 'relative days')</methodname>. Use
                            <link linkend="zend.date.introduction">Zend_Date</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>DecimalNumber</emphasis></entry>

                        <entry>
                            Returns the format for decimal numbers within a given locale. Use <link
                                linkend="zend.locale.parsing">Zend_Locale_Format</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>ScientificNumber</emphasis></entry>

                        <entry>
                            Returns the format for scientific numbers within a given locale
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>PercentNumber</emphasis></entry>

                        <entry>
                            Returns the format for percentage numbers within a given locale
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyNumber</emphasis></entry>

                        <entry>
                            Returns the format for displaying currency numbers within a given
                            locale. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>NameToCurrency</emphasis></entry>

                        <entry>
                            Returns the translated name for a given currency. The currency has to be
                            given in <acronym>ISO</acronym> format which is for example 'EUR' for
                            the currency 'euro'. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyToName</emphasis></entry>

                        <entry>
                            Returns a currency for a given localized name. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencySymbol</emphasis></entry>

                        <entry>
                            Returns the used symbol for a currency within a given locale. Not for
                            all currencies exists a symbol. Use
                            <link linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Question</emphasis></entry>

                        <entry>
                            Returns a localized string for acceptance ('yes') and negation ('no').
                            You have to give either 'yes' or 'no' as value to receive the expected
                            string. Use <link linkend="zend.locale.getquestion">Zend_Locale's
                                getQuestion method</link> for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyFraction</emphasis></entry>

                        <entry>
                            Returns the fraction to use for a given currency. You must give the
                            currency as <acronym>ISO</acronym> value. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link>
                            for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyRounding</emphasis></entry>

                        <entry>
                            Returns how to round a given currency. You must give the currency as
                            <acronym>ISO</acronym> value. If you omit the currency then the
                            'DEFAULT' rounding will be returned. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link>
                            for simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CurrencyToRegion</emphasis></entry>

                        <entry>
                            Returns the currency for a given region. The region code has to be given
                            as <constant>ISO3166</constant> string for example 'AT' for austria. Use
                            <link linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>RegionToCurrency</emphasis></entry>

                        <entry>
                            Returns the regions where a currency is used. The currency has to be
                            given as <constant>ISO4217</constant> code for example 'EUR' for euro.
                            When a currency is used in multiple regions, these regions are separated
                            with a whitespace character. Use <link
                                linkend="zend.currency.introduction">Zend_Currency</link> for
                            simplicity
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>RegionToTerritory</emphasis></entry>

                        <entry>
                            Returns the regions for a given territory. The territory has to be given
                            as <constant>ISO4217</constant> string for example '001' for world. The
                            regions within this territory are separated with a whitespace character
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToRegion</emphasis></entry>

                        <entry>
                            Returns the territories where a given region is located. The region has
                            to be given in <constant>ISO3166</constant> string for example 'AT' for
                            austria. When a region is located in multiple territories then these
                            territories are separated with a whitespace character
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>ScriptToLanguage</emphasis></entry>

                        <entry>
                            Returns the scripts which are used within a given language. The language
                            has to be given as <acronym>ISO</acronym> language code for example 'en'
                            for english. When multiple scripts are used within a language then these
                            scripts are separated with a whitespace character
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>LanguageToScript</emphasis></entry>

                        <entry>
                            Returns the languages which are used within a given script. The script
                            has to be given as <acronym>ISO</acronym> script code for example 'Latn'
                            for latin. When a script is used in multiple languages then these
                            languages are separated with a whitespace character
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToLanguage</emphasis></entry>

                        <entry>
                            Returns the territory where a given language is used. The language has
                            to be given as <acronym>ISO</acronym> language code for example 'en' for
                            english. When the given language is spoken within multiple territories
                            then these territories are separated with a whitespace character
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>LanguageToTerritory</emphasis></entry>

                        <entry>
                            Returns the language which is spoken within a given territory. The
                            territory has to be given as <constant>ISO3166</constant> code for
                            example 'IT' for italia. When multiple languages are spoken within the
                            given territory then these languages are separated with a whitespace
                            character
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TimezoneToWindows</emphasis></entry>

                        <entry>
                            Returns a <acronym>ISO</acronym> timezone for a given windows timezone
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>WindowsToTimezone</emphasis></entry>

                        <entry>
                            Returns a windows timezone for a given <acronym>ISO</acronym> timezone
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToTimezone</emphasis></entry>

                        <entry>
                            Returns the territory for a given <acronym>ISO</acronym> timezone
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TimezoneToTerritory</emphasis></entry>

                        <entry>
                            Returns the <acronym>ISO</acronym> timezone for a given territory
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CityToTimezone</emphasis></entry>

                        <entry>
                            Returns the localized city for a given <acronym>ISO</acronym> timezone.
                            Not for all timezones does a city translation exist
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TimezoneToCity</emphasis></entry>

                        <entry>
                            Returns the <acronym>ISO</acronym> timezone for a given localized city
                            name. Not for all cities does a timezone exist
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>PhoneToTerritory</emphasis></entry>

                        <entry>
                            Returns the telephone code for a given territory (region). The territory
                            code has to be given as <constant>ISO3166</constant> string for example
                            'AT' for austria
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToPhone</emphasis></entry>

                        <entry>
                            Returns the territory (region) where a telephone code is used. The
                            telephone code has to be given as plain integer code for example '43'
                            for +43. When a telephone code is used in multiple territories
                            (regions), these territories are separated with a whitespace character
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>NumericToTerritory</emphasis></entry>

                        <entry>
                            Returns the 3 digit number code for a given territory (region). The
                            territory code has to be given as <constant>ISO3166</constant> string
                            for example 'AT' for austria
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToNumeric</emphasis></entry>

                        <entry>
                            Returns the territory (region) for a 3 digit number code. The 3 digit
                            number code has to be given as plain integer code for example '43'
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Alpha3ToTerritory</emphasis></entry>

                        <entry>
                            Returns the 3 sign character code for a given territory (region). The
                            territory code has to be given as <constant>ISO3166</constant> string
                            for example 'AT' for austria
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>TerritoryToAlpha3</emphasis></entry>
                        <entry>Returns the territory (region) for a 3 sign character code</entry>
                    </row>

                    <row>
                        <entry><emphasis>PostalToTerritory</emphasis></entry>

                        <entry>
                            Returns the a regex for postal codes for a given territory. The
                            territory has to be given as <constant>ISO4217</constant> string for
                            example '001' for world
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>NumberingSystem</emphasis></entry>

                        <entry>
                            Returns a scripts with the notation for digits used within this script
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>FallbackToChar</emphasis></entry>

                        <entry>
                            Returns a replacement character for a often used unicode character.
                            This can be used to replace "©" with "(C)" for example
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>CharToFallback</emphasis></entry>

                        <entry>
                            Returns a unicode character for a often used replacement character.
                            This can be used to replace "(C)" with "©" for example
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>LocaleUpgrade</emphasis></entry>

                        <entry>
                            Returns a locale dependencies for a given language which can be used to
                            upgrade this language to a full qualified locale
                        </entry>
                    </row>

                    <row>
                        <entry><emphasis>Unit</emphasis></entry>

                        <entry>
                            Returns a localized calendar unit. This can be used to translate
                            the strings "day", "month" and so on automatically. The first parameter
                            has to be the type, and the second parameter has to be the count
                        </entry>
                    </row>
                </tbody>
            </tgroup>
        </table>

        <note>
            <para>
                With Zend Framework 1.5 several old types have been renamed. This has to be done
                because of several new types, some misspelling and to increase the usability. See
                this table for a list of old to new types:
            </para>
        </note>

        <table id="zend.locale.getdata.table-3">
            <title>Differences between Zend Framework 1.0 and 1.5</title>

            <tgroup cols="2">
                <thead>
                    <row>
                        <entry>Old type</entry>
                        <entry>New type</entry>
                    </row>
                </thead>

                <tbody>
                    <row>
                        <entry>Country</entry>
                        <entry>Territory (with value '2')</entry>
                    </row>

                    <row>
                        <entry>Calendar</entry>
                        <entry>Type (with value 'calendar')</entry>
                    </row>

                    <row>
                        <entry>Month_Short</entry>
                        <entry>Month (with array('gregorian', 'format', 'abbreviated')</entry>
                    </row>

                    <row>
                        <entry>Month_Narrow</entry>
                        <entry>Month (with array('gregorian', 'stand-alone', 'narrow')</entry>
                    </row>

                    <row>
                        <entry>Month_Complete</entry>
                        <entry>Months</entry>
                    </row>

                    <row>
                        <entry>Day_Short</entry>
                        <entry>Day (with array('gregorian', 'format', 'abbreviated')</entry>
                    </row>

                    <row>
                        <entry>Day_Narrow</entry>
                        <entry>Day (with array('gregorian', 'stand-alone', 'narrow')</entry>
                    </row>

                    <row>
                        <entry>DateFormat</entry>
                        <entry>Date</entry>
                    </row>

                    <row>
                        <entry>TimeFormat</entry>
                        <entry>Time</entry>
                    </row>

                    <row>
                        <entry>Timezones</entry>
                        <entry>CityToTimezone</entry>
                    </row>

                    <row>
                        <entry>Currency</entry>
                        <entry>NameToCurrency</entry>
                    </row>

                    <row>
                        <entry>Currency_Sign</entry>
                        <entry>CurrencySymbol</entry>
                    </row>

                    <row>
                        <entry>Currency_Detail</entry>
                        <entry>CurrencyToRegion</entry>
                    </row>

                    <row>
                        <entry>Territory_Detail</entry>
                        <entry>TerritoryToRegion</entry>
                    </row>

                    <row>
                        <entry>Language_Detail</entry>
                        <entry>LanguageToTerritory</entry>
                    </row>
                </tbody>
            </tgroup>
        </table>

        <para>
            The example below demonstrates how to obtain the names of things in different languages.
        </para>

        <example id="zend.locale.getdata.example-3">
            <title>getTranslationList</title>

            <programlisting language="php"><![CDATA[
// prints the names of all countries in German language
print_r(Zend_Locale::getTranslationList('country', 'de'));
]]></programlisting>
        </example>

        <para>
            The next example shows how to find the name of a language in another language, when the
            two letter iso country code is not known.
        </para>

        <example id="zend.locale.getdata.example-4">
            <title>Converting country name in one language to another</title>

            <programlisting language="php"><![CDATA[
$code2name = Zend_Locale::getLanguageTranslationList('en_US');
$name2code = array_flip($code2name);
$frenchCode = $name2code['French'];
echo Zend_Locale::getLanguageTranslation($frenchCode, 'de_AT');
// output is the German name of the French language
]]></programlisting>
        </example>

        <para>
            To generate a list of all languages known by <classname>Zend_Locale</classname>, with
            each language name shown in its own language, try the example below in a web page.
            Similarly, <methodname>getCountryTranslationList()</methodname> and
            <methodname>getCountryTranslation()</methodname> could be used to create a table mapping
            your native language names for regions to the names of the regions shown in another
            language. Use a <command>try .. catch</command> block to handle exceptions that occur
            when using a locale that does not exist. Not all languages are also locales. In the
            example, below exceptions are ignored to prevent early termination.
        </para>

        <example id="zend.locale.getdata.example-6">
            <title>All Languages written in their native language</title>

            <programlisting language="php"><![CDATA[
$list = Zend_Locale::getLanguageTranslationList('auto');

foreach($list as $language => $content) {
    try {
        $output = Zend_Locale::getLanguageTranslation($language, $language);
        if (is_string($output)) {
            print "\n<br>[".$language."] ".$output;
        }
    } catch (Exception $e) {
        continue;
    }
}
]]></programlisting>
        </example>
    </sect2>

    <sect2 id="zend.locale.getquestion">
        <title>Obtaining translations for "yes" and "no"</title>

        <para>
            Frequently, programs need to solicit a "yes" or "no" response from the user. Use
            <methodname>getQuestion()</methodname> to obtain an array containing the correct word(s)
            or regex strings to use for prompting the user in a particular $locale (defaults to the
            current object's locale). The returned array will contain the following information :
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <emphasis>yes and no</emphasis>: A generic string representation for yes and no
                    responses. This will contain the first and most generic response from yesarray
                    and noarray.
                </para>

                <para>
                    <emphasis>yesarray and noarray</emphasis>: An array with all known yes and
                    no responses. Several languages have more than just two responses. In general
                    this is the full string and its abbreviation.
                </para>

                <para>
                    <emphasis>yesexpr and noexpr</emphasis>: A generated regex which allows you
                    to handle user response, and search for yes or no.
                </para>
            </listitem>
        </itemizedlist>

        <para>
            All of this information are of course localized and depend on the set locale. See the
            following example for the information you can receive:
        </para>

        <example id="zend.locale.getquestion.example-1">
            <title>getQuestion()</title>

            <programlisting language="php"><![CDATA[
$locale = new Zend_Locale();
// Question strings
print_r($locale->getQuestion('de'));

- - - Output - - -

Array
(
    [yes] => ja
    [no] => nein
    [yesarray] => Array
        (
            [0] => ja
            [1] => j
        )

    [noarray] => Array
        (
            [0] => nein
            [1] => n
        )

    [yesexpr] => ^([jJ][aA]?)|([jJ]?)
    [noexpr] => ^([nN]([eE][iI][nN])?)|([nN]?)
)
]]></programlisting>
        </example>

        <note>
            <para>
                Until 1.0.3 <emphasis>yesabbr</emphasis> from the underlaying locale data was also
                available. Since 1.5 this information is no longer standalone available, but you
                will find the information from it within <emphasis>yesarray</emphasis>.
            </para>
        </note>
    </sect2>

    <sect2 id="zend.locale.getlocalelist">
        <title>Get a list of all known locales</title>

        <para>
            Sometimes you will want to get a list of all known locales. This can be used for several
            tasks like the creation of a selectbox. For this purpose you can use the static
            <methodname>getLocaleList()</methodname> method which will return a list of all known
            locales.
        </para>

        <example id="zend.locale.getlocalelist.example-1">
            <title>getLocaleList()</title>

            <programlisting language="php"><![CDATA[
$localelist = Zend_Locale::getLocaleList();
]]></programlisting>
        </example>

        <note>
            <para>
                Note that the locales are returned as key of the array you will receive. The value
                is always a boolean <constant>TRUE</constant>.
            </para>
        </note>
    </sect2>

    <sect2 id="zend.locale.detection">
        <title>Detecting locales</title>

        <para>
            When you want to detect if a given input, regardless of its source, is a locale you
            should use the static <methodname>isLocale()</methodname> method. The first parameter of
            this method is the string which you want to check.
        </para>

        <example id="zend.locale.detection.example-1">
            <title>Simple locale detection</title>

            <programlisting language="php"><![CDATA[
$input = 'to_RU';
if (Zend_Locale::isLocale($input)) {
    print "'{$input}' is a locale";
} else {
    print "Sorry... the given input is no locale";
}
]]></programlisting>
        </example>

        <para>
            As you can see, the output of this method is always a boolean. There is only one reason
            you could get an exception when calling this method. When your system does not provide
            any locale and Zend Framework is not able to detect it automatically. Normally this
            shows that there is a problem with your OS in combination with <acronym>PHP</acronym>'s
            <methodname>setlocale()</methodname>.
        </para>

        <para>
            You should also note that any given locale string will automatically be degraded if the
            region part does not exist for this locale. In our previous example the language
            '<property>to</property>' does not exist in the region '<property>RU</property>', but
            you will still get <constant>TRUE</constant> returned as
            <classname>Zend_Locale</classname> can work with the given input.
        </para>

        <para>
            Still it's sometimes useful to prevent this automatic degrading, and this is where the
            second parameter of <methodname>isLocale()</methodname> comes in place. The
            <property>strict</property> parameter defaults to <constant>FALSE</constant> and can be
            used to prevent degrading when set to <constant>TRUE</constant>.
        </para>

        <example id="zend.locale.detection.example-2">
            <title>Strict locale detection</title>

            <programlisting language="php"><![CDATA[
$input = 'to_RU';
if (Zend_Locale::isLocale($input, true)) {
    print "'{$input}' is a locale";
} else {
    print "Sorry... the given input is no locale";
}
]]></programlisting>
        </example>

        <para>
            Now that you are able to detect if a given string is a locale you could add locale aware
            behaviour to your own classes. But you will soon detect that this always leads to
            the same 15 lines of code. Something like the following example:
        </para>

        <example id="zend.locale.detection.example-3">
            <title>Implement locale aware behaviour</title>

            <programlisting language="php"><![CDATA[
if ($locale === null) {
    $locale = new Zend_Locale();
}

if (!Zend_Locale::isLocale($locale, true, false)) {
    if (!Zend_Locale::isLocale($locale, false, false)) {
        throw new Zend_Locale_Exception(
            "The locale '$locale' is no known locale");
    }

    $locale = new Zend_Locale($locale);
}

if ($locale instanceof Zend_Locale) {
    $locale = $locale->toString();
}
]]></programlisting>
        </example>

        <para>
            With Zend Framework 1.8 we added a static <methodname>findLocale()</methodname> method
            which returns a locale string which you can work with. It processes the following
            tasks:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    Detects if a given string is a locale
                </para>
            </listitem>

            <listitem>
                <para>
                    Degrades the locale if it does not exist in the given region
                </para>
            </listitem>

            <listitem>
                <para>
                    Upgrades the locale when it is detected as region without language
                </para>
            </listitem>

            <listitem>
                <para>
                    Returns a previous set application wide locale if no input is given
                </para>
            </listitem>

            <listitem>
                <para>
                    Detects the locale from browser when the previous detections failed
                </para>
            </listitem>

            <listitem>
                <para>
                    Detects the locale from environment when the previous detections failed
                </para>
            </listitem>

            <listitem>
                <para>
                    Detects the locale from framework when the previous detections failed
                </para>
            </listitem>

            <listitem>
                <para>
                    Returns always a string which represents the found locale.
                </para>
            </listitem>
        </itemizedlist>

        <para>
            The following example shows how these checks and the above code can be simplified with
            one single call:
        </para>

        <example id="zend.locale.detection.example-4">
            <title>Locale aware behaviour as with Zend Framework 1.8</title>

            <programlisting language="php"><![CDATA[
$locale = Zend_Locale::findLocale($inputstring);
]]></programlisting>
        </example>
    </sect2>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->
