Class NLS

Description

The NLS:: class provides Native Language Support. This includes common methods for handling language detection and selection, timezones, and hostname->country lookups.

Copyright 1999-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /NLS/NLS.php (line 28)


	
			
Method Summary
 boolean checkCharset (string $charset)
 string generateFlagImageByHost (string $host)
 string getCharset ([boolean $original = false])
 mixed getCountryByHost (string $host)
 mixed getCountryISO ([string $code = ''])
 string getEmailCharset ()
 string getExternalCharset ()
 array getLangInfo (const $item)
 array getLocaleInfo ()
 boolean isValid (string $language)
 string numberFormat ($number $number, [$decimals $decimals = 0])
 string select ()
 void setCharset (string $charset, [integer $index = 0])
 void setCharsetEnvironment (string $charset)
 void setLang ([string $lang = null])
 void setLanguageEnvironment ([string $language = null], [string $app = null])
 void setTextdomain (string $app, string $directory, string $charset)
 void setTimeZone ()
Methods
checkCharset (line 355)

Check to see if character set is valid for htmlspecialchars() calls.

  • return: Is charset valid for the current system?
boolean checkCharset (string $charset)
  • string $charset: The character set to check.
generateFlagImageByHost (line 569)

Returns a Horde image link to the country flag.

  • return: The image URL, or the empty string on error.
string generateFlagImageByHost (string $host)
  • string $host: The hostname or IP address.
getCharset (line 246)

Returns the charset for the current language.

  • return: The character set that should be used with the current locale settings.
string getCharset ([boolean $original = false])
  • boolean $original: If true returns the original charset of the translation, the actually used one otherwise.
getCountryByHost (line 513)

Get country information from a hostname or IP address.

  • return: On success, return an array with the following entries: 'code' => Country Code 'name' => Country Name On failure, return false.
mixed getCountryByHost (string $host)
  • string $host: The hostname or IP address.
getCountryISO (line 595)

Returns either a specific or all ISO-3166 country names.

  • return: If a country code has been requested will return the corresponding country name. If empty will return an array of all the country codes and their names.
mixed getCountryISO ([string $code = ''])
  • string $code: The ISO 3166 country code.
getEmailCharset (line 336)

Returns the charset to use for outgoing emails.

  • return: The preferred charset for outgoing mails based on the user's preferences and the current language.
string getEmailCharset ()
getExternalCharset (line 284)

Returns the current charset of the environment

  • return: The character set that should be used with the current locale settings.
string getExternalCharset ()
getLangInfo (line 488)

Get the language info returned by nl_langinfo(), but cache it, to avoid repeated calls.

  • return: The results of nl_langinfo().
  • since: Horde 3.1
array getLangInfo (const $item)
  • const $item: The langinfo item to return.
getLocaleInfo (line 447)

Get the locale info returned by localeconv(), but cache it, to avoid repeated calls.

  • return: The results of localeconv().
array getLocaleInfo ()
isValid (line 198)

Determines whether the supplied language is valid.

  • return: True if the language is valid, false if it's not valid or unknown.
boolean isValid (string $language)
  • string $language: The abbreviated name of the language.
numberFormat (line 468)

Replacement for number_format() which doesn't work with multibyte separators.

  • return: The number formatted for the current locale.
  • since: Horde 3.3.7
string numberFormat ($number $number, [$decimals $decimals = 0])
  • $number $number: The number to format.
  • $decimals $decimals: The number of decimals.
select (line 35)

Selects the most preferred language for the current client session.

  • return: The selected language abbreviation.
string select ()
setCharset (line 399)

Sets the charset.

In general, the applied charset is automatically determined by browser language and browser capabilities and there's no need to manually call setCharset. However for headless (RPC) operations the charset may be set manually to ensure correct character conversion in the backend.

void setCharset (string $charset, [integer $index = 0])
  • string $charset: If specified, this charset will be stored in the given cache slot.
  • integer $index: The ID of a cache slot. 0 for the UI charset, 1 for the translation charset and 2 for the external charset. Defaults to 0: this is the charset returned by getCharset and used for conversion.
setCharsetEnvironment (line 415)

Sets the charset and reloads the whole NLS environment.

When setting the charset, the gettext catalogs have to be reloaded too, to match the new charset, among other things. This method takes care of all this.

  • since: Horde 3.2
void setCharsetEnvironment (string $charset)
  • string $charset: The new charset.
setLang (line 102)

Sets the language.

void setLang ([string $lang = null])
  • string $lang: The language abbreviation.
setLanguageEnvironment (line 177)

Sets the language and reloads the whole NLS environment.

When setting the language, the gettext catalogs have to be reloaded too, charsets have to be updated etc. This method takes care of all this.

  • since: Horde 3.2
void setLanguageEnvironment ([string $language = null], [string $app = null])
  • string $language: The new language.
  • string $app: The application for reloading the gettext catalog. The current application if empty.
setTextdomain (line 149)

Sets the gettext domain.

void setTextdomain (string $app, string $directory, string $charset)
  • string $app: The application name.
  • string $directory: The directory where the application's LC_MESSAGES directory resides.
  • string $charset: The charset.
setTimeZone (line 431)

Sets the current timezone, if available.

void setTimeZone ()

Documentation generated on Sun, 30 Jan 2011 05:19:57 +0000 by phpDocumentor 1.4.3