From 888db089c515270fd5cd9a9bedd217110f43bc4c Mon Sep 17 00:00:00 2001 From: elij Date: Sun, 29 May 2011 14:33:37 -0700 Subject: rename *.inc files to *.inc.php and adjust imports and references Lukas: Add note to "UPGRADING". Signed-off-by: Lukas Fleischer --- web/lib/translator.inc.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 web/lib/translator.inc.php (limited to 'web/lib/translator.inc.php') diff --git a/web/lib/translator.inc.php b/web/lib/translator.inc.php new file mode 100644 index 00000000..44c87bda --- /dev/null +++ b/web/lib/translator.inc.php @@ -0,0 +1,50 @@ +", ""); + +include_once('config.inc.php'); +include_once('gettext.php'); +include_once('streams.php'); + +global $streamer, $l10n; + +function __() { + global $LANG; + global $l10n; + + # Create the translation. + $args = func_get_args(); + + # First argument is always string to be translated + $tag = $args[0]; + + # Translate using gettext_reader initialized before. + $translated = $l10n->translate($tag); + $translated = htmlspecialchars($translated, ENT_QUOTES); + + $num_args = sizeof($args); + + # Subsequent arguments are strings to be formatted + # + # TODO: make this more robust. + # '%%' should translate to a literal '%' + + if ( $num_args > 1 ) { + for ($i = 1; $i < $num_args; $i++) { + $translated = preg_replace("/\%[sh]/", $args[$i], $translated, 1); + } + } + + return $translated; +} + -- cgit v1.2.3-24-g4f1b