translator.inc: Remove old and deprecated code.

Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
Loui Chang 2010-01-09 00:47:39 -05:00
parent 8eab9ed462
commit 06e400a2f0

View file

@ -1,8 +1,7 @@
<?php <?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang');
# this include file provides support for i18n # This file provides support for i18n
#
# usage: # usage:
# use the __() function for returning translated strings of # use the __() function for returning translated strings of
@ -20,25 +19,12 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR
# #
# examples: # examples:
# print __("%s has %s apples.", "Bill", "5"); # print __("%s has %s apples.", "Bill", "5");
# print __("This is a %h%s%h problem!", "<b>","major","</b>"); # print __("This is a %hmajor%h problem!", "<b>", "</b>");
#
# deprecated usage:
# print __("%s has %s apples.", array("Bill", "5"));
include_once('config.inc'); include_once('config.inc');
global $_t; global $_t;
function include_lang($trans) {
global $LANG;
if ($LANG != DEFAULT_LANG) {
return include_once("$LANG/$trans");
}
else
return true;
}
function __() { function __() {
global $_t; global $_t;
global $LANG; global $LANG;
@ -63,16 +49,13 @@ function __() {
$translated = htmlspecialchars($translated, ENT_QUOTES); $translated = htmlspecialchars($translated, ENT_QUOTES);
# This condition is to reorganise the arguments in case of
# deprecated usage. __("string", array("string","string"))
if (!empty($args[1]) && is_array($args[1])) {
array_unshift($args[1], $tag);
$args = $args[1];
}
$num_args = sizeof($args); $num_args = sizeof($args);
# Subsequent arguments are strings to be formatted # Subsequent arguments are strings to be formatted
#
# TODO: make this more robust.
# '%%' should translate to a literal '%'
if ( $num_args > 1 ) { if ( $num_args > 1 ) {
for ($i = 1; $i < $num_args; $i++) { for ($i = 1; $i < $num_args; $i++) {
$translated = preg_replace("/\%[sh]/", $args[$i], $translated, 1); $translated = preg_replace("/\%[sh]/", $args[$i], $translated, 1);