(root)/i18n-functions.php - Rev 446
Rev 438 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of Travelsized CMS
* A content management system with modules, based on wiki syntax
*
* Author: Dan Jensen <admin@leinir.dk>
* Copyright 2003/2004
*
* 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.
*
* The GNU General Public License is available at: http://www.gnu.org/copyleft/
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* i18n() - Internationalization function
*
* @param string thestring The string that is to be translated. Must be in British English
* @param array needles An array containing needles to be inserted at ##key## points throughout the string
*
* @return string The translated string or, if there is no translation available, the untranslated string
*/
function i18n
($thestring, $needles = "")
{
global $i18nstrings;
if (array_key_exists( $thestring, $i18nstrings ) && $i18nstrings[$thestring] != "")
$result = $i18nstrings[$thestring];
else
$result = $thestring;
if( is_array( $needles ) )
foreach($needles as $key => $value)
$result = str_replace("##$key##", $value, $result);
return $result;
}
function generate_pagehelp
() {
global $page_help;
$thetexts = array("txt1", "txt2", "txt3", "txt4", "txt5", "txt6", "txt7", "txt8");
$thecolours = array("blue", "red", "green", "maroon", "purple", "fuchsia", "navy", "teal");
$temp_content = "
<table>";
foreach($page_help as $key => $value) {
foreach($thetexts as $key2 => $value2) {
$key = str_replace($value2, "<span style=\"color: " . $thecolours[$key2] . ";\">$value2</span>", $key);
$value = str_replace($value2, "<span style=\"color: " . $thecolours[$key2] . ";\">$value2</span>", $value);
}
$temp_content .= "
<tr>
<td class=\"page_help_term\"><div>$key</div></td>
<td class=\"page_help_description\"><div>$value</div></td>
</tr>";
}
$temp_content .= "
</table>";
return $temp_content;
}
function generate_pagehelplink
() {
return "
<script language=\"JavaScript\">
<!--
function showhide(id) {
obj = document.getElementsByTagName(\"div\");
if (obj[id].style.display == 'block'){
obj[id].style.display = 'none';
}
else {
obj[id].style.display = 'block';
}
}
document.write('<a class=\\\"command\\\" name=\\\"page_help\\\" href=\\\"javascript://\\\" onClick=\\\"showhide(\'page_help\')\\\">[" . i18n
("Show layout help") . "]</a>')
document.write('<div id=\"page_help\" style=\"display: none;\">" . str_replace("'", "\'", str_replace("\n", "", str_replace("\"", "\\\"", generate_pagehelp
()))) . "</div>')
// --></script>
<noscript><a class=\"command\" href=\"" . globalIDtoURL
( "help" ) . "\" target=\"_blank\">[" . i18n
("Show layout help") . "]</a></noscript>";
}
?>