[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/locale/ -> locale.class.php (sommaire)

\defgroup Locale The Locale module is used for localization purposes. Its main class is the Locale class that is capable of loading very simple php files containing a big array of string identifiers and their translations. The main method of the class is the Locale::tr() that given a string identifier, will return the translated version.

Poids: 825 lignes (28 kb)
Inclus ou requis:0 fois
Référencé: 2 fois
Nécessite: 0 fichiers

Définit 1 class

Locale:: (26 méthodes):
  Locale()
  _loadLocaleFile()
  _loadLocaleInfo()
  getCharset()
  getDirection()
  getDescription()
  getLocaleFolder()
  setLocale()
  getStrings()
  tr()
  i18n()
  pr()
  getLocaleCode()
  getLanguageId()
  getCountryId()
  firstDayOfWeek()
  getMonthNames()
  getDayNames()
  getDayNamesShort()
  _getOrdinal()
  getDateOrdinal()
  getDayOrdinal()
  formatDate()
  formatDateGMT()
  formatDateAsRFC822()
  mergeLocale()


Classe: Locale  - X-Ref

\ingroup Locale

Class used to localize messages and things such as dates and numbers.

To use this class, we will have to provide a file containing an array
of the form:

<pre>
$messages["identifier"] = "Translated text"
</pre>

The file will be loaded when creating this object and must be called following
the same scheme: locale_lang_COUNTRY (see constructor on locales namig schemes)

When we want to translate a string, we will have to use its identifier, that will
be looked up in the array containing all the messages. If there is a message for that
identifier, it will be returned or a empty string otherwise.

This class is extensively used throughout the templates to localize texts, dates
and numbers, being the formatDate function one of the most importants of this class.

<b>IMPORTANT:</b> For performance reasons, it is recommended to use the Locales::getLocale
method instead of creating new Locale objects every time we need one. The getLocale methods
offers caching capabilities so that the file with the messages will not need to be fetched
every time from disk.
Locale( $code )   X-Ref
Constructor.

param: $code Code follows the Java naming scheme: language_COUNTRY, so

_loadLocaleFile()   X-Ref


_loadLocaleInfo()   X-Ref


getCharset()   X-Ref
Returns the character encoding method used by the current locale file. It has to be a valid
character encoding, since it will be used in the header of the html file to tell the browser
which is the most suitable encoding that should be used.

return: A valid character encoding method.

getDirection()   X-Ref
returns the direction in which this language is written.
Possible values are, as with the html standard, "rtl" or "ltr"


getDescription()   X-Ref
Returns an optional locale description string that can be included in the
locale file with the other texts.

return: A string describing the locale file.

getLocaleFolder()   X-Ref


setLocale( $code )   X-Ref
Changes the locale to something else than what we chose in the first place when
creating the object.

param: code follows the same format as in the constructor.

getStrings()   X-Ref
returns all the strings

return: An array containing all the strings that this locale supports

tr( $id )   X-Ref
Translates a string

param: id Identifier of the message we would like to translate

i18n( $id )   X-Ref
Alias for getString


pr( $id, $arg1 = null, $arg2 = null, $arg3 = null )   X-Ref
calls printf on the translated string.

Crappy Crappy! Since it only accepts three arguments... ;) Well, if we
ever need more than three, I'll change it!

getLocaleCode()   X-Ref
Returns the complete code

return: The Locale code

getLanguageId()   X-Ref
Returns the two-character language code

return: The two-character language code

getCountryId()   X-Ref
Returns the two-character country code

return: The two-character country code.

firstDayOfWeek()   X-Ref
Returns the first day of the week, which also depends on the country

return: Returns 0 for Sunday, 1 for Monday and so on...

getMonthNames()   X-Ref
Returns all the months of the year

return: Returns an array containing the names of the months, where the

getDayNames()   X-Ref
Returns the days of the week

return: Returns the names of the days of the week, where the first one is

getDayNamesShort()   X-Ref
Returns the shorter version of the days of the week

return: Returns an array with the days of the week abbreviated, where the first

_getOrdinal( $num )   X-Ref
Pas de description

getDateOrdinal( $date )   X-Ref
Returns the day in an ordinal format, i.e. 1st, 2nd, 3rd, etc (in English)

return: A string with the ordinal representation of the day.

getDayOrdinal( $t )   X-Ref
Pas de description

formatDate( $timeStamp, $format = null, $blog = null )   X-Ref
Formats the date of a Timestamp object according to the given format:

(compatible with PHP):<ul>
<li>%a abbreviated weekday</li>
<li>%A    complete weekday</li>
<li>%b    abbreviated month</li>
<li>%B    long month</li>
<li>%d    day of the month, 2 digits with leading zero</li>
<li>%j   day of the month, numeric (without leading zero)</li>
<li>%H    hours, in 24-h format</li>
<li>%I    hours, in 12-h format (without leading zero)</li>
<li>%p   returns 'am' or 'pm'</li>
<li>%P   returns 'AM' or 'PM'</li>
<li>%M    minutes</li>
<li>%m    month number, from 00 to 12</li>
<li>%S    seconds</li>
<li>%y    2-digit year representation</li>
<li>%Y    4-digit year representation</li>
<li>%O   Difference to Greenwich time (GMT) in hours</li>
<li>%%    the '%' character
</ul>
(these have been added by myself and are therefore incompatible with php)<ul>
<li>%T    "_day_ of _month_", where the day is in ordinal form and 'month' is the name of the month</li>
<li>%D    cardinal representation of the day</li>
</ul>

formatDateGMT( $timeStamp, $format = null, $blog = null )   X-Ref
Formats the date of a Timestamp object according to the given format:
This function assumes that the timestamp is local and it converts it
to GMT before formatting.

(compatible with PHP):<ul>
<li>%a abbreviated weekday</li>
<li>%A    complete weekday</li>
<li>%b    abbreviated month</li>
<li>%B    long month</li>
<li>%d    day of the month, 2 digits with leading zero</li>
<li>%j   day of the month, numeric (without leading zero)</li>
<li>%H    hours, in 24-h format</li>
<li>%I    hours, in 12-h format (without leading zero)</li>
<li>%p   returns 'am' or 'pm'</li>
<li>%P   returns 'AM' or 'PM'</li>
<li>%M    minutes</li>
<li>%m    month number, from 00 to 12</li>
<li>%S    seconds</li>
<li>%y    2-digit year representation</li>
<li>%Y    4-digit year representation</li>
<li>%O   Difference to Greenwich time (GMT) in hours (Will always be +0000)</li>
<li>%%    the '%' character
</ul>
(these have been added by myself and are therefore incompatible with php)<ul>
<li>%T    "_day_ of _month_", where the day is in ordinal form and 'month' is the name of the month</li>
<li>%D    cardinal representation of the day</li>
</ul>

formatDateAsRFC822( $timestamp, $blog = null )   X-Ref
Formats a date as an RFC 822 date timestamp.


mergeLocale( $locale )   X-Ref
merges two locales




Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics