phpDocumentor GalleryCore
Classes
[ class tree: GalleryCore ] [ index: GalleryCore ] [ all elements ]

Class: GalleryTranslator

Source Location: /modules/core/classes/GalleryTranslator.class

Class GalleryTranslator

Class Overview

Internationalization and Localization utilities.

Definitions: $locale - consists of ISO 3166 country codes and ISO 639 language codes i.e. en_US, en_GB, es_MX $language - the first portion of the locale $langCode - representation of the locale with the country portion removed if it is the default. (i.e. en_US => en; en_GB => en_GB) in some cases the $langCode == $locale. The exception is the handling of chinese. For political reasons there is no default country and it's always represented by the full $locale (zh_CN or zh_TW)

Located in /modules/core/classes/GalleryTranslator.class [line 51]



		
				Author(s):
		
Information Tags:
Todo:  go through and standardize the usage or remove the langCode usage and just use locale

Properties

Methods

[ Top ]
Property Summary
array   $_boundDomains   Keep track of the gettext domains we've already bound
boolean   $_isRightToLeft   Does the active language read right-to-left?
string   $_languageCode   Currently selected locale

[ Top ]
Method Summary
static boolean   canTranslate()   Can we translate?
static boolean   canTranslatePlural()   Can we make plural translations?
static array   getDefaultLanguageCode()   Get default language code for this request.
static null   getLanguageCodeFromRequest()   Examine the incoming request and try to figure out what languages the browser will accept.
static array   getLanguageData()   Return our language data.
static array   getSupportedLanguageCode()   Find a supported locale from given string.
static string   _setlocale()   Attempt to set the requested locale. Try fallbacks and character sets if needed to find a valid locale.
GalleryTranslator   GalleryTranslator()  
string   getActiveLanguageCode()   Return supported locale that was selected after initialization.
array   getLanguageAndCountryFromLanguageCode()   Determine the language and country given the language code (i.e. en, en_GB)
array   getLanguageCodeFromLocale()   Convert the locale to the language code
array['language   getSupportedLanguages()   Return the list of languages that we support.
array   init()   Initialize the translator with the specified language code hint
boolean   isRightToLeft()   Does the active language read right-to-left?
array   translateDomain()   Localize the given text.

[ Top ]
Properties
array   $_boundDomains [line 58]

Keep track of the gettext domains we've already bound

API Tags:
Access:  private


[ Top ]
boolean   $_isRightToLeft [line 72]

Does the active language read right-to-left?

API Tags:
Access:  private


[ Top ]
string   $_languageCode [line 65]

Currently selected locale

API Tags:
Access:  private


[ Top ]
Methods
static method canTranslate  [line 84]

  static boolean canTranslate( )

Can we translate?



Redefined in descendants as:

[ Top ]
static method canTranslatePlural  [line 93]

  static boolean canTranslatePlural( )

Can we make plural translations?



[ Top ]
static method getDefaultLanguageCode  [line 382]

  static array getDefaultLanguageCode( )

Get default language code for this request.


API Tags:
Return:  GalleryStatus a status code string language code


[ Top ]
static method getLanguageCodeFromRequest  [line 456]

  static null getLanguageCodeFromRequest( )

Examine the incoming request and try to figure out what languages the browser will accept.

Take the first one that we can support.


API Tags:
Return:  or a language code in the <language>_<COUNTRY> format, eg: en_US


[ Top ]
static method getLanguageData  [line 115]

  static array getLanguageData( )

Return our language data.


API Tags:
Return:  array['language code']['country code'] = array('description', 'right-to-left'?) array array('country' => 'default language code', 'country' => 'default language code', ...)

Information Tags:
Todo:  Move this information into a configuration file

Redefined in descendants as:

[ Top ]
static method getSupportedLanguageCode  [line 424]

  static array getSupportedLanguageCode( string $languageCode, [boolean $fallback = true]  )

Find a supported locale from given string.

Parameters:
string   $languageCode:  the language code hint
boolean   $fallback:  (optional) if false, return array(null,null) for no match instead of en_US

API Tags:
Return:  (string a language code in <language>_<COUNTRY> format, array data about this language code (description,right-to-left?))


[ Top ]
static method _setlocale  [line 340]

  static string _setlocale( mixed $category, string $locale  )

Attempt to set the requested locale. Try fallbacks and character sets if needed to find a valid locale.

Parameters:
mixed   $category: 
string   $locale: 

API Tags:
Return:  locale selected or boolean false if none
Access:  private


[ Top ]
Constructor GalleryTranslator  [line 75]

  GalleryTranslator GalleryTranslator( )



[ Top ]
getActiveLanguageCode  [line 410]

  string getActiveLanguageCode( )

Return supported locale that was selected after initialization.


API Tags:
Return:  locale


[ Top ]
getLanguageAndCountryFromLanguageCode  [line 604]

  array getLanguageAndCountryFromLanguageCode( string $langCode  )

Determine the language and country given the language code (i.e. en, en_GB)

Parameters:
string   $langCode:  The language code to be converted.

API Tags:
Return:  GalleryStatus a status code string language string country


[ Top ]
getLanguageCodeFromLocale  [line 582]

  array getLanguageCodeFromLocale( string $locale  )

Convert the locale to the language code

Parameters:
string   $locale:  The locale code to be converted (i.e. en_US, en_GB, etc.)

API Tags:
Return:  GalleryStatus a status code string language code (i.e. en, en_GB, etc.)


[ Top ]
getSupportedLanguages  [line 294]

  array['language getSupportedLanguages( )

Return the list of languages that we support.


API Tags:
Return:  code']['country code'] = array('description', 'right-to-left'?)
Deprecated:  Remove on next major api bump. Use GalleryCoreApi::getSupportedLanguages


[ Top ]
init  [line 306]

  array init( [string $languageCode = null], [boolean $dontUseDatabase = false]  )

Initialize the translator with the specified language code hint

Parameters:
string   $languageCode:  the language code hint (eg. 'en_US' or 'zh_CN')
boolean   $dontUseDatabase:  (optional) true if we should not use the database

API Tags:
Return:  GalleryStatus a status code string language code


[ Top ]
isRightToLeft  [line 101]

  boolean isRightToLeft( )

Does the active language read right-to-left?



[ Top ]
translateDomain  [line 494]

  array translateDomain( string $domain, mixed $data  )

Localize the given text.

Expected inputs are of the form:

Example 1: $data['text'] = 'Some %s text to localize with %d arguments' $data['arg1'] = 'fun'; $data['arg2'] = 2; or $data['args'] = array('fun', 2);

localized: 'Some fun text to localize with 5 arguments'

Example 2: $data['one'] = 'You have %d orange' $data['many'] = 'You have %d oranges' $data['count'] = $data['arg1'] = 3; (or 1)

localized: 'You have 3 oranges' (or 'You have 1 orange')

Parameters:
string   $domain:  the domain (eg. pluginType . 's_' . pluginId)
mixed   $data:  a single string, or an array of parameters

API Tags:
Return:  GalleryStatus a status code string the localized value


[ Top ]

Documentation generated on Fri, 08 Oct 2010 05:06:17 -0700 by phpDocumentor 1.3.0RC6