From 5268aa5802366910b7900e83c9de7ffff2ff96d6 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 14 Jun 2004 18:31:31 +0000 Subject: Started adding i18n support --- web/lib/translator.inc | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 web/lib/translator.inc (limited to 'web/lib') diff --git a/web/lib/translator.inc b/web/lib/translator.inc new file mode 100644 index 00000000..2d45f2ab --- /dev/null +++ b/web/lib/translator.inc @@ -0,0 +1,55 @@ +","major","")); + +include_once("common_po.inc"); + +function _($tag, $args=array()) { + global $_t; + global $LANG; + + # default to English if the lang hasn't been provided + # + if (!$LANG) { + $lang = "en"; + } else { + $lang = $LANG; + } + + # create the translation, if it doesn't exist, highlight it + # + $translated = $_t[$lang][$tag]; + if (!$translated) { + $translated = "_" . $tag . "_"; + } + + # replace escape substitutions + # + if (!empty($args)) { + while (list($k, $v) = each($args)) { + $translated = preg_replace("/\%[sh]/", $v, $translated, 1); + } + } + return $translated; +} + +# vim: ts=2 sw=2 noet ft=php +?> -- cgit v1.2.3-24-g4f1b