Loui Chang, and other guys: When i port a chinese version AUR, I fount this bug. That once i setting a default language to sth(eg: zh_CN) by change DEFAULT_LANG macr define in web/lib/config.inc, it won't work, and this language page(here is zh_CN) could not show its native strings.
Then i turn back to check if i got a wrong spelling. But i fount the developer have told us that options couldn't be change(in web/lib/config.inc, line 48). So I think maybe its a bug which havn't been fixed. After i check all the code about language setting, i think i got the reason. We have two problems which cause that bug. First, in .../web/lib/aur.inc, between line 296 to line 298. Even the $LANG==DEFAULT_LANG, we should include the $LANG.po file. Because once the DEFAULT_LANG isn't english, we also need translate the strings. So i just suggest add an 'else' branch after line 298 to include DEFAULT_LANG.po.such as"else{include_once(DEFAULT_LANG.".po";)}" Second, in .../web/lib/translator.inc, between line 52 to line 62. The reason is as the same as i said above. If we havn't set a $LANG var, the $LANG will be set to DEFAULT_LANG. But the DEFAULT_LANG doesn't mean english. Even the $LANG havn't been set, the $_t maybe setting (see Firest above) when include from DEFAULT_LANG.po. We should also translate them. So i think we should remove the 'else' identify. make the 'else' branch work for ever. By the way if the function "include_lang()" in .../web/lib/translator.inc, between line 32 to line 40 is an old function to make the lang func? Maybe we should remove them. PS: I prepare to make a mirror for our AUR to chinese people, how could i got the databases an files from aur.archlinux.org. OR i couldn't make a mirror for that. Your know as a chinese ,my english is very pool. If you guys don't know what i say, welcome to send me a mail. Athurg Gooth now
diff --git a/web/lib/aur.inc b/web/lib/aur.inc index f940192..821288d 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -295,6 +295,8 @@ function set_lang() { if ($LANG != DEFAULT_LANG ) { include_once("$LANG.po"); + } else { + include_once(DEFAULT_LANG.".po"); } return; diff --git a/web/lib/translator.inc b/web/lib/translator.inc index 8c90551..3c3da2a 100644 --- a/web/lib/translator.inc +++ b/web/lib/translator.inc @@ -49,18 +49,18 @@ function __() { # First argument is always string to be translated $tag = $args[0]; - if (empty($LANG) || $LANG == DEFAULT_LANG) + if (empty($LANG) || $LANG == DEFAULT_LANG){ $translated = $tag; + } + + # If there is no translation, just print the given string. + if (empty($_t[$tag])) { + $translated = $tag; + } else { - # If there is no translation, just print the given string. - if (empty($_t[$tag])) { - $translated = $tag; - } - else { - $translated = $_t[$tag]; - } + $translated = $_t[$tag]; } - + $translated = htmlspecialchars($translated, ENT_QUOTES); # This condition is to reorganise the arguments in case of