2 # this include file provides support for i18n
6 # use the __() function for returning translated strings of
7 # text. The string can contain escape codes %h for HTML
8 # and %s for regular text.
11 # there is a supporting script, web/utils/genpopo, that will
12 # parse the PHP files and create PHP include files that contain
13 # a mapping for each translated language. The include files
16 # $_t["en"]["My cat is large."] = "My cat is large.";
17 # $_t["es"]["My cat is large."] = "Mi gato esta grande.";
20 # print __("%s has %s apples.", array("Bill", "5"));
21 # print __("This is a %h%s%h problem!", array("<b>","major","</b>"));
23 include_once("common_po.inc");
26 function __($tag, $args=array()) {
30 # create the translation, if it doesn't exist, highlight it
32 $translated = $_t[$LANG][$tag];
34 # if it's a supported language, but there isn't a translation,
35 # alert the visitor to the missing translation.
37 $translated = "<font color=\"red\"><b>_" . $tag . "_</b></font>";
40 # replace escape substitutions
43 while (list($k, $v) = each($args)) {
44 $translated = preg_replace("/\%[sh]/", $v, $translated, 1);
50 # vim: ts=2 sw=2 noet ft=php