File/nasmail/functions/i18n.php

Description

Internationalization functions

This file contains variuos functions that are needed to do internationalization of NaSMail.

Internally the output character set is used. Other characters are encoded using Unicode entities according to HTML 4.0.

  • version: $Id: i18n.php 1402 2008-06-05 06:16:23Z tokul $
  • copyright: (c) 1999-2006 The SquirrelMail Project Team
  • copyright: (c) 2006-2007 The NaSMail Project
  • license: GNU Public License
Includes
 include_once (SM_PATH.'functions/gettext.php') (line 1211)
 include_once (SM_PATH.'class/l10n.class.php') (line 1206)
 include_once (SM_PATH.'functions/ngettext.php') (line 1207)
 include_once (SM_PATH.'functions/global.php') (line 24)

Everything uses global.php...

 include_once (SM_PATH.'locale/'.$lang_dir.'/setup.php') (line 1177)

Automatic translation loading from setup.php files.

setup.php file can contain $languages array entries.

Functions
charset_convert (line 202)

Combined decoding and encoding functions

If conversion is done to charset different that utf-8, unsupported symbols will be replaced with question marks.

  • return: converted string
string charset_convert (string $in_charset, string $string, string $out_charset, [boolean $htmlencode = true])
  • string $in_charset: initial charset
  • string $string: string that has to be converted
  • string $out_charset: final charset
  • boolean $htmlencode: keep htmlspecialchars encoding
charset_decode (line 128)

Converts string from given charset to charset, that can be displayed by user translation.

Function by default returns html encoded strings, if translation uses different encoding. If Japanese translation is used - function returns string converted to euc-jp If $charset is not supported - function returns unconverted string.

sanitizing of html tags is also done by this function.

  • return: decoded string
string charset_decode (string $charset, string $string, [boolean $force_decode = false], [boolean $save_html = false])
  • string $charset
  • string $string: Text to be decoded
  • boolean $force_decode: converts string to html without $charset!='utf-8' check.
  • boolean $save_html: disables htmlspecialchars() in order to preserve html formating. Use with care.
charset_encode (line 160)

Converts html string to given charset

void charset_encode (string $string, string $charset, [boolean $htmlencode = true], string 3)
  • string $string
  • string $charset
  • boolean $htmlencode: keep htmlspecialchars encoding
  • string 3
fixcharset (line 217)

Makes charset name suitable for decoding cycles

Functions removes minus and characters that might be used in paths from charset name in order to be able to use it in function names and include calls.

  • return: Adjusted name of charset
string fixcharset (string $charset)
  • string $charset: Name of charset
nsm_bindtextdomain (line 80)

Gettext bindtextdomain wrapper.

Wrapper solves differences between php versions in order to provide ngettext support and fix gettext codeset conversion issues. Function sets codeset to utf-8, if bind_textdomain_codeset() function is available.

  • return: path to translation directory
string nsm_bindtextdomain (string $domain, string $dir)
  • string $domain: gettext domain name
  • string $dir: directory that contains all translations
nsm_i18n_charset_alias (line 519)

Locates charset alias used by NaSMail

In 1.5 function was extended to recognize ISO646 aliases supported by extra decoding library 1.3.

  • return: charset name used in NaSMail
string nsm_i18n_charset_alias (string $charset)
  • string $charset
nsm_i18n_convert_entities (line 241)

Converts html character entities to numeric entities

NasMail encoding functions work only with numeric entities. This function fixes issues with decoding functions that might convert some symbols to character entities. Issue is specific to PHP recode extension decoding. Function is used internally in charset_convert() function.

  • return: string with character entities converted to decimals.
string nsm_i18n_convert_entities (string $str)
  • string $str: string that might contain html character entities
nsm_i18n_language_name (line 876)

Converts language code to translated language name Not all iso 639 codes are supported. Function could also be used to translate English language name to user's language.

  • return: translated language name
string nsm_i18n_language_name (string $lang_code)
  • string $lang_code
nsm_textdomain (line 106)

Gettext textdomain wrapper.

Makes sure that gettext_domain global is modified.

  • return: gettext domain name
string nsm_textdomain ( $domain, string $name)
  • string $name: gettext domain name
  • $domain
nsm_tgettext (line 1288)

Lookup a message in the current or selected domain (tagged form)

Function allows to separate strings that have dual meaning in English. When string is translated with nsm_t* functions, these functions strip all text before first tag.

For example: "Search" can be noun or verb in US English. Other languages might use different translations for nouns and verbs.

  • return: Translated string
  • since: 1.6
string nsm_tgettext (string $msgid, [string $tag = ':'], [ $domain = ''])
  • string $msgid: translatable string
  • string $tag: Gettext domain
  • $domain
nsm_tngettext (line 1311)

Plural form of nsm_tgettext

  • return: Translated string
  • since: 1.6
string nsm_tngettext (string $msgid1, string $msgid2, int $count, [string $tag = ':'], [ $domain = ''])
  • string $msgid1: First form of translatable string
  • string $msgid2: Second form of translatable string
  • int $count: Count. Unsigned integer
  • string $tag: Gettext domain
  • $domain
set_up_language (line 1020)
void set_up_language ( $sm_language, [ $do_search = false], [ $default = false])
  • $sm_language
  • $do_search
  • $default
sq_setlocale (line 39)

php setlocale function wrapper

From php 4.3.0 it is possible to use arrays in order to set locale. php gettext extension works only when locale is set. This wrapper function allows to use more than one locale name.

string sq_setlocale (int $category, mixed $locale)
  • int $category: locale category name. Use php named constants (LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME)
  • mixed $locale: option contains array with possible locales or string with one locale

Documentation generated on Sun, 22 Nov 2009 17:36:38 +0200 by phpDocumentor 1.4.3