4

translate

translate
SYNOPSIS

translate($s, $lang)

DESCRIPTION

translate returns the translation of $s in $lang or false in case of failure.

The strings which are translated are defined in the file includes/strings.inc:

  1. includes
    1. strings.inc
  1. global $strings;
  2.  
  3. $strings = array(
  4.     array(
  5.     ),
  1.     'en' => array(
  2.         'description'           => '',
  3.         'keywords'              => 'iZend',
  1.         'donate:name'           => 'Donation to ' . $sitename,
  2.     ),
  3.     'fr' => array(

strings.inc defines the global variable $strings. $strings holds a table which associates for each language managed by the program a list of character strings and their translations. The array of strings which are not language dependent is placed at position 0.

CODE
  1. global $strings;
  2.  
  3. $strings = array();
  4.  
  5. @include 'strings.inc';

Loads the global variable $strings from the file strings.inc.

  1. function translate($s, $lang) {
  2.     global $strings;
  3.  
  4.     if ($s) {
  5.         if ($lang && array_key_exists($lang, $strings) && array_key_exists($s, $strings[$lang])) {
  6.             return $strings[$lang][$s];
  7.         }
  8.         if (array_key_exists(0, $strings) && array_key_exists($s, $strings[0])) {
  9.             return $strings[0][$s];
  10.         }
  11.     }
  12.  
  13.     return false;
  14. }
SEE ALSO

engine

Comments

To add a comment, click here.