Warning, /sdk/pology/www/base/i18n.inc is written in an unsupported language. File is not indexed.

0001 <?php
0002 
0003 $fallback_lang = "en_US";
0004 
0005 function _subs_args ($text, $args)
0006 {
0007     if ($args) {
0008         array_unshift($args, $text);
0009         return call_user_func_array("sprintf", $args);
0010     } else {
0011         return $text;
0012     }
0013     // NOTE: Text is not pulled through sprintf in case of zero arguments,
0014     // for the following reason. If the original text did not contain
0015     // any formatting directives, its message in the PO file will not be given
0016     // the php-format flag; if the translator then uses % in translation,
0017     // and the text is pulled through sprintf, kaboom.
0018 }
0019 
0020 // Dummy translation calls, for the moment.
0021 
0022 // varargs: msgid, ...
0023 function vt_ ()
0024 {
0025     $args = func_get_args();
0026     $msgid = array_shift($args);
0027     $msgstr = $msgid; // dummy
0028     return _subs_args($msgstr, $args);
0029 }
0030 
0031 // varargs: msgctxt, msgid, ...
0032 function vpt_ ()
0033 {
0034     $args = func_get_args();
0035     $msgctxt = array_shift($args);
0036     $msgid = array_shift($args);
0037     $msgstr = $msgid; // dummy
0038     return _subs_args($msgstr, $args);
0039 }
0040 
0041 // varargs: msgid, msgid_plural, n, ...
0042 function vnt_ ()
0043 {
0044     $args = func_get_args();
0045     $msgid = array_shift($args);
0046     $msgid_plural = array_shift($args);
0047     $n = array_shift($args);
0048     $msgstr = $n == 1 ? $msgid : $msgid_plural; // dummy
0049     return _subs_args($msgstr, $args);
0050 }
0051 
0052 // varargs: msgctxt, msgid, msgid_plural, n, ...
0053 function vpnt_ ()
0054 {
0055     $args = func_get_args();
0056     $msgctxt = array_shift($args);
0057     $msgid = array_shift($args);
0058     $msgid_plural = array_shift($args);
0059     $n = array_shift($args);
0060     $msgstr = $n == 1 ? $msgid : $msgid_plural; // dummy
0061     return _subs_args($msgstr, $args);
0062 }
0063 
0064 // varargs: msgid, ...
0065 function t_ ()
0066 {
0067     echo call_user_func_array("vt_", func_get_args()) . "\n";
0068 }
0069 
0070 // varargs: msgctxt, msgid, ...
0071 function pt_ ()
0072 {
0073     echo call_user_func_array("vpt_", func_get_args()) . "\n";
0074 }
0075 
0076 // varargs: msgid, msgid_plural, n, ...
0077 function nt_ ()
0078 {
0079     echo call_user_func_array("vnt_", func_get_args()) . "\n";
0080 }
0081 
0082 // varargs: msgctxt, msgid, msgid_plural, n, ...
0083 function pnt_ ()
0084 {
0085     echo call_user_func_array("vpnt_", func_get_args()) . "\n";
0086 }
0087 
0088 // Return path for given language if it exists,
0089 // otherwise return path for fallback language.
0090 // $pathbase should contain one %s printf-directive,
0091 // which is replaced by the language code to construct the final path.
0092 function path_for_lang ($pathbase, $lang)
0093 {
0094     $path = sprintf($pathbase, $lang);
0095     if (!file_exists($path)) {
0096         global $fallback_lang;
0097         $path = sprintf($pathbase, $fallback_lang);
0098     }
0099     return $path;
0100 }
0101 
0102 // Some global translation pieces.
0103 $listsep = vpt_("separator when listing items in text", ", ");
0104 
0105 ?>