/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright ©2006 by sTEFANs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This file provides functions to translate several string or URLs.
* The translations themself could be in according files to ease
* the access and provide a well done structure.
* @copyright Copyright ©2006 by sTEFANs
* @license http://opensource.org/licenses/lgpl-license.php GNU General Public License
* Formats a given timestamp into a localized format.
* @param boolean $short Whether or not (default) the timestamp
* should be returned in short or long format.
* @return string Formatted timestamp string.
* Translates the given ID to the language
* set in the browser or to english as default language.<br><br>
* <b>Parameters</b>:This function needs the ID for the
* string to translate as first argument. Any
* further arguments are passed to <i>sprintf</i>
* to format the string with values.<br>
* If no parameter is applied, an error text
* (not translated) is returned.
* Determines the languages accepted by the browser.
* @return array Array of languages accepted by the browser
* order by relevance or an empty array if the browser
* does not determine accepted languages.
if (isset
($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
$lang_str =
$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$langs =
explode(',', $lang_str);
foreach($langs as $key =>
$lang){
// Remove double countries
foreach($countries as $key =>
$country){
* Loads the best fitting translation table resource.
* The best fitting translation table is the table that
* 1. meets the country and language code exactly
* 2. meets the country code only
* 3. is the default language
* Translation tables are looked up in folder
* <b>STD_RESOURCE_PATH</b> defined in
* <b>inc/var.inc.php</b>. The name of the file
* should be in format <b>country-language.php</b>
* or <b>country</b>, both in ISO 2 letter code
* as used by browsers.<br>
* US English for instance is coded <b>en-us</b>,
* default English is coded <b>en</b>.
* Translation tables for a language without
* a country code should be provided.<br>
* The filename is case insensitive.
* The file name of the default translation
* table is defined in <b>inc/var.inc.php</b>
* by <b>STD_TRANSLATION_TABLE</b>.
* @return string Code of the loaded language
static $language_code =
NULL;
if ($language_code ==
NULL){
$browser_langs =
GetBrowserLanguages();
if ($browser_langs !=
NULL){
while($idx <
count($browser_langs) &&
$language_code ==
NULL){
$path =
STD_RESOURCE_PATH.
$browser_langs[$idx].
'.php';
$language_code =
$browser_langs[$idx];
if ($language_code ==
NULL){
include_once(STD_RESOURCE_PATH.
STD_TRANSLATION_TABLE);