symfony API

sfCultureInfo Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

Packages

You are currently browsing the symfony API for the 1.2 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

sfCultureInfo class.

Method Summary

  • string dataDir()
    Gets the default directory for the ICU data.
  • string fileExt()
    Gets the filename extension for ICU data. Default is ".dat".
  • mixed findInfo($path = '/', $merge = false)
    Finds the specific ICU data information from the data.
  • string getCalendar()
    Gets the default calendar used by the culture, e.g. "gregorian".
  • array getCountries($countries = null)
    Gets a list of countries in the language of the localized version.
  • string getCountry($code)
    Get the country name in the current culture for the given code.
  • array getCultures($type = sfCultureInfo::ALL)
    Gets the list of supported cultures filtered by the specified culture type. This is an EXPENSIVE function, it needs to traverse a list of ICU files in the data directory.
  • array getCurrencies($currencies = null, (Boolean) $full = false)
    Gets a list of currencies in the language of the localized version.
  • string getCurrency($code)
    Get the currency name in the current culture for the given code.
  • array& getData($filename)
    Gets the data by unserializing the ICU data from disk.
  • getDateTimeFormat()
    Gets the sfDateTimeFormatInfo that defines the culturally appropriate format of displaying dates and times.
  • array getEnglishName()
    Gets the culture name in English.
  • getInstance($culture = 'en')
    Gets the sfCultureInfo that for this culture string.
  • getInvariantCulture()
    Gets the sfCultureInfo that is culture-independent (invariant).
  • boolean getIsNeutralCulture()
    Gets a value indicating whether the current sfCultureInfo represents a neutral culture. Returns true if the culture only contains two characters.
  • string getLanguage($code)
    Get the language name in the current culture for the given code.
  • array getLanguages($languages = null)
    Gets a list of languages in the language of the localized version.
  • string getName()
    Gets the culture name in the format "<languagecode2>_(country/regioncode2)".
  • array getNativeName()
    Gets the culture name in the language that the culture is set to display. Returns 'Country' is omitted if the culture is neutral.
  • getNumberFormat()
    Gets the sfNumberFormatInfo that defines the culturally appropriate format of displaying numbers, currency, and percentage.
  • getParent()
    Gets the sfCultureInfo that represents the parent culture of the current sfCultureInfo
  • array getScripts()
    Gets a list of scripts in the language of the localized version.
  • array getTimeZones()
    Gets a list of timezones in the language of the localized version.
  • loadCultureData($culture)
    Loads the ICU culture data for the specific culture identifier.
  • mixed searchArray($info, $path = '/')
    Searches the array for a specific value using a path separated using slash "/" separated path. e.g to find $info&[apos;hello']&[apos;world'], the path "hello/world" will return the corresponding value.
  • setCulture($culture)
    Sets the culture for the current instance. The culture indentifier must be of the form "<language>_(country/region)".
  • setDateTimeFormat((sfDateTimeFormatInfo) $dateTimeFormat)
    Sets the date time format information.
  • setNumberFormat((sfNumberFormatInfo) $numberFormat)
    Sets the number format information.
  • array simplify($array)
    Simplifies a single element array into its own value.
  • boolean validCulture($culture)
    Determines if a given culture is valid. Simply checks that the culture data exists.
  • return constructor __construct($culture = 'en')
    Initializes a new instance of the sfCultureInfo class based on the culture specified by name. E.g. The culture indentifier must be of the form "<language>_(country/region/variant)".
  • mixed __get($name)
    Allows functions that begins with 'set' to be called directly as an attribute/property to retrieve the value.
  • __set($name, $value)
    Allows functions that begins with 'set' to be called directly as an attribute/property to set the value.
  • string __toString()
    Displays the culture name.

Method Details

  • (string) dataDir ()

    Gets the default directory for the ICU data.


    The default is the "data" directory for this class.

    returns directory containing the ICU data.

  • (string) fileExt ()

    Gets the filename extension for ICU data. Default is ".dat".

    returns filename extension for ICU data.

  • (mixed) findInfo ($path = '/', $merge = false)

    $path the data you want to find.
    $merge merge the data from its parents.

    Finds the specific ICU data information from the data.


    The path to the specific ICU data is separated with a slash "/". E.g. To find the default calendar used by the culture, the path "calendar/default" will return the corresponding default calendar. Use merge=true to return the ICU including the parent culture. E.g. The currency data for a variant, say "en_AU" contains one entry, the currency for AUD, the other currency data are stored in the "en" data file. Thus to retrieve all the data regarding currency for "en_AU", you need to use findInfo("Currencies,true);.

    returns the specific ICU data.

  • (string) getCalendar ()

    Gets the default calendar used by the culture, e.g. "gregorian".

    returns the default calendar.

  • (array) getCountries ($countries = null)

    $countries An array of countries used to restrict the returned array (null by default, which means all countries)

    Gets a list of countries in the language of the localized version.

    returns a list of localized country names.

  • (string) getCountry ($code)

    $code A valid country code

    Get the country name in the current culture for the given code.

    returns The country name in the current culture

  • (array) getCultures ($type = sfCultureInfo::ALL)

    $type culture type, sfCultureInfo::ALL, sfCultureInfo::NEUTRAL or sfCultureInfo::SPECIFIC.

    Gets the list of supported cultures filtered by the specified culture type. This is an EXPENSIVE function, it needs to traverse a list of ICU files in the data directory.


    This function can be called statically.

    returns list of culture information available.

  • (array) getCurrencies ($currencies = null, (Boolean) $full = false)

    $currencies An array of currencies used to restrict the returned array (null by default, which means all currencies)
    $full Whether to return the symbol and the name or not (false by default)

    Gets a list of currencies in the language of the localized version.

    returns a list of localized currencies.

  • (string) getCurrency ($code)

    $code A valid currency code

    Get the currency name in the current culture for the given code.

    returns The currency name in the current culture

  • (array&) getData ($filename)

    $filename the ICU data filename

    Gets the data by unserializing the ICU data from disk.


    The data files are cached in a static variable inside this function.

    returns ICU data

  • getDateTimeFormat ()

    Gets the sfDateTimeFormatInfo that defines the culturally appropriate format of displaying dates and times.

    returns date time format information for the culture.

  • (array) getEnglishName ()

    Gets the culture name in English.


    Returns

    array('Language','Country');
    'Country' is omitted if the culture is neutral.

    returns array with language and country as elements.

  • getInstance ($culture = 'en')

    $culture The culture for this instance

    Gets the sfCultureInfo that for this culture string.

    returns Invariant culture info is "en"

  • getInvariantCulture ()

    Gets the sfCultureInfo that is culture-independent (invariant).


    Any changes to the invariant culture affects all other instances of the invariant culture. The invariant culture is assumed to be "en";

    returns invariant culture info is "en".

  • (boolean) getIsNeutralCulture ()

    Gets a value indicating whether the current sfCultureInfo represents a neutral culture. Returns true if the culture only contains two characters.

    returns true if culture is neutral, false otherwise.

  • (string) getLanguage ($code)

    $code A valid language code

    Get the language name in the current culture for the given code.

    returns The language name in the current culture

  • (array) getLanguages ($languages = null)

    $languages An array of languages used to restrict the returned array (null by default, which means all languages)

    Gets a list of languages in the language of the localized version.

    returns list of localized language names.

  • (string) getName ()

    Gets the culture name in the format "<languagecode2>_(country/regioncode2)".

    returns culture name.

  • (array) getNativeName ()

    Gets the culture name in the language that the culture is set to display. Returns 'Country' is omitted if the culture is neutral.

    returns array with language and country as elements, localized.

  • getNumberFormat ()

    Gets the sfNumberFormatInfo that defines the culturally appropriate format of displaying numbers, currency, and percentage.

    returns the number format info for current culture.

  • getParent ()

    Gets the sfCultureInfo that represents the parent culture of the current sfCultureInfo

    returns parent culture information.

  • (array) getScripts ()

    Gets a list of scripts in the language of the localized version.

    returns list of localized script names.

  • (array) getTimeZones ()

    Gets a list of timezones in the language of the localized version.

    returns list of localized timezones.

  • loadCultureData ($culture)

    $culture the culture identifier.

    Loads the ICU culture data for the specific culture identifier.

  • (mixed) searchArray ($info, $path = '/')

    $info the array for search
    $path slash "/" separated array path.

    Searches the array for a specific value using a path separated using slash "/" separated path. e.g to find $info&[apos;hello']&[apos;world'], the path "hello/world" will return the corresponding value.

    returns the value array using the path

  • setCulture ($culture)

    $culture culture identifier, e.g. "fr_FR_EURO".

    Sets the culture for the current instance. The culture indentifier must be of the form "<language>_(country/region)".

  • setDateTimeFormat ((sfDateTimeFormatInfo) $dateTimeFormat)

    $dateTimeFormat the new date time format info.

    Sets the date time format information.

  • setNumberFormat ((sfNumberFormatInfo) $numberFormat)

    $numberFormat the new number format info.

    Sets the number format information.

  • (array) simplify ($array)

    $array with single elements arrays

    Simplifies a single element array into its own value.


    E.g.

    array(0 => array('hello'), 1 => 'world');
    becomes
    array(0 => 'hello', 1 => 'world');

    returns simplified array.

  • (boolean) validCulture ($culture)

    $culture a culture

    Determines if a given culture is valid. Simply checks that the culture data exists.

    returns true if valid, false otherwise.

  • (return constructor) __construct ($culture = 'en')

    $culture a culture name, e.g. "en_AU".

    Initializes a new instance of the sfCultureInfo class based on the culture specified by name. E.g. The culture indentifier must be of the form "<language>_(country/region/variant)".

    returns new sfCultureInfo.

  • (mixed) __get ($name)

    $name The property to get

    Allows functions that begins with 'set' to be called directly as an attribute/property to retrieve the value.

  • __set ($name, $value)

    $name The property to set
    $value The property value

    Allows functions that begins with 'set' to be called directly as an attribute/property to set the value.

  • (string) __toString ()

    Displays the culture name.

    returns the culture name.