18
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:
- includes
- strings.inc
An optional parameter allows to specify another translation table.
- global $strings;
- $strings = array(
- array(
- ),
- 'en' => array(
- 'description' => '',
- 'keywords' => 'iZend',
- 'http_bad_request:title' => 'Bad Request',
- 'http_forbidden:title' => 'Forbidden',
- 'payment_rejected:title' => 'Payment rejected',
- 'donate:name' => 'Donation to ' . $sitename,
- ),
- 'fr' => array(
- 'description' => '',
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
- global $strings;
- $strings = array();
- @include 'strings.inc';
Loads the global variable $strings
from the file strings.inc.
- function translate($s, $lang, $from=false) {
- global $strings;
- $stab=$from ? $from : $strings;
- if ($s) {
- if ($lang && array_key_exists($lang, $stab) && array_key_exists($s, $stab[$lang])) {
- return $stab[$lang][$s];
- }
- if (array_key_exists(0, $stab) && array_key_exists($s, $stab[0])) {
- return $stab[0][$s];
- }
- }
- return false;
- }
Comments