Permalink
Browse files

Simplify single language version

  • Loading branch information...
1 parent 55e2b75 commit 9a4cabe89895fa2c28d66a11ca590f29ad1e8ef6 @vrana committed Jul 11, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 compile.php
View
@@ -51,14 +51,15 @@ function put_file($match) {
if (basename($match[2]) != "lang.inc.php" || !$_SESSION["lang"]) {
$tokens = token_get_all($return); // to find out the last token
return "?>\n$return" . (in_array($tokens[count($tokens) - 1][0], array(T_CLOSE_TAG, T_INLINE_HTML), true) ? "<?php" : "");
- } elseif (preg_match('~\\s*(\\$pos = .*;)~sU', $return, $match2)) {
+ } elseif (preg_match('~\\s*(\\$pos = (.+\n).+;)~sU', $return, $match2)) {
// single language lang() is used for plural
return "function get_lang() {
return '$_SESSION[lang]';
}
function lang(\$translation, \$number) {
- " . str_replace('$LANG', "'$_SESSION[lang]'", $match2[1]) . '
+ \$pos = $match2[2]\t\t: " . (preg_match("~\\\$LANG == '$_SESSION[lang]'.* \\? (.+)\n~U", $match2[1], $match3) ? $match3[1] : "1") . '
+ );
return sprintf($translation[$pos], $number);
}
';

0 comments on commit 9a4cabe

Please sign in to comment.