symfony API

sfI18N Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.2 API OpenSearch

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.

sfI18N wraps the core i18n classes for a symfony context.

Method Summary

  • createMessageSource($dir = null)
    Returns a new message source.
  • getConfiguration()
    Returns the configuration instance.
  • string getCountry($iso, $culture = null)
    Gets a country name.
  • string getCulture()
    Gets the current culture for i18n format objects.
  • array getDateForCulture($date, $culture = null)
    Returns the day, month and year from a date formatted with a given culture.
  • getMessageFormat()
    Gets the message format.
  • getMessageSource()
    Gets the message source.
  • string getNativeName($culture)
    Gets a native culture name.
  • array getOptions()
    Returns the initialization options
  • array getTimeForCulture($time, $culture)
    Returns the hour, minute from a date formatted with a given culture.
  • integer getTimestampForCulture($dateTime, $culture = null)
    Returns a timestamp from a date with time formatted with a given culture.
  • initialize($configuration, $cache = null, $options = array())
    Initializes this class.
  • Boolean isMessageSourceFileBased($source)
    Returns true if messages are stored in a file.
  • listenToChangeActionEvent($event)
    Listens to the controller.change_action event.
  • listenToChangeCultureEvent($event)
    Listens to the user.change_culture event.
  • setCulture($culture)
    Sets the current culture for i18n format objects.
  • setMessageSource($dirs, $culture = null)
    Sets the message source.
  • string __($string, $args = array(), $catalogue = 'messages')
    Gets the translation for the given string
  • __construct($configuration, $cache = null, $options = array())
    Class constructor.

Method Details

  • createMessageSource ($dir = null) Browse code

    $dir An array of i18n directories to create a XLIFF or gettext message source, null otherwise

    Returns a new message source.

    returns A sfMessageSource object

  • getConfiguration () Browse code

    Returns the configuration instance.

    returns An sfApplicationConfiguration instance

  • (string) getCountry ($iso, $culture = null) Browse code

    $iso The ISO code
    $culture The culture for the translation

    Gets a country name.

    returns The country name

  • (string) getCulture () Browse code

    Gets the current culture for i18n format objects.

    returns The culture

  • (array) getDateForCulture ($date, $culture = null) Browse code

    $date The formatted date as string
    $culture The culture

    Returns the day, month and year from a date formatted with a given culture.

    returns An array with the day, month and year

  • getMessageFormat () Browse code

    Gets the message format.

    returns A sfMessageFormat object

  • getMessageSource () Browse code

    Gets the message source.

    returns A sfMessageSource object

  • (string) getNativeName ($culture) Browse code

    $culture The culture

    Gets a native culture name.

    returns The culture name

  • (array) getOptions () Browse code

    Returns the initialization options

    returns The options used to initialize sfI18n

  • (array) getTimeForCulture ($time, $culture) Browse code

    $time The formatted date as string
    $culture The culture

    Returns the hour, minute from a date formatted with a given culture.

    returns An array with the hour and minute

  • (integer) getTimestampForCulture ($dateTime, $culture = null) Browse code

    $dateTime The formatted date with time as string
    $culture The culture

    Returns a timestamp from a date with time formatted with a given culture.

    returns The timestamp

  • initialize ($configuration, $cache = null, $options = array()) Browse code

    $configuration A sfApplicationConfiguration instance
    $cache A sfCache instance
    $options An array of options

    Initializes this class.


    Available options:

    * culture: The culture
    * source: The i18n source (XLIFF by default)
    * debug: Whether to enable debug or not (false by default)
    * database: The database name (default by default)
    * untranslated_prefix: The prefix to use when a message is not translated
    * untranslated_suffix: The suffix to use when a message is not translated

  • (Boolean) isMessageSourceFileBased ($source) Browse code

    $source The source name

    Returns true if messages are stored in a file.

    returns true if messages are stored in a file, false otherwise

  • listenToChangeActionEvent ($event) Browse code

    $event An sfEvent instance

    Listens to the controller.change_action event.

  • listenToChangeCultureEvent ($event) Browse code

    $event An sfEvent instance

    Listens to the user.change_culture event.

  • setCulture ($culture) Browse code

    $culture The culture

    Sets the current culture for i18n format objects.

  • setMessageSource ($dirs, $culture = null) Browse code

    $dirs An array of i18n directories if message source is a sfMessageSource_File subclass, null otherwise
    $culture The culture

    Sets the message source.

  • (string) __ ($string, $args = array(), $catalogue = 'messages') Browse code

    $string The string to translate
    $args An array of arguments for the translation
    $catalogue The catalogue name

    Gets the translation for the given string

    returns The translated string

  • __construct ($configuration, $cache = null, $options = array()) Browse code

    $configuration
    $cache
    $options

    Class constructor.