Add a new DEFAULT_LANG constant.

DEFAULT_LANG will essentially be used to specify what language
strings are initially written in.

This will eliminate the need for English translation arrays in
AUR and make adding or changing the English strings a lot easier.

DEFAULT_LANG may be required for strings to display properly.

Also change the output when a translation isn't found.
Eliminate the <b> which can cause validation errors depending
on where the string is placed.

Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
Loui Chang 2008-07-09 14:38:08 -04:00
parent 1deb924674
commit 1a1a6eb36e
3 changed files with 17 additions and 11 deletions

View file

@ -311,12 +311,11 @@ function set_lang() {
$LANG = $row[0]; $LANG = $row[0];
} }
$update_cookie = 1; $update_cookie = 1;
} else {
$LANG = "en";
} }
# Set $LANG to default if nothing is valid.
if (!array_key_exists($LANG, $SUPPORTED_LANGS)) { if (!array_key_exists($LANG, $SUPPORTED_LANGS)) {
$LANG = "en"; # default to English $LANG = DEFAULT_LANG;
} }
if ($update_cookie) { if ($update_cookie) {
@ -410,4 +409,3 @@ function uid_from_username($username="")
return $row[0]; return $row[0];
} }
?>

View file

@ -16,9 +16,12 @@ define( "USERNAME_MAX_LEN", 16 );
define( "PASSWD_MIN_LEN", 4 ); define( "PASSWD_MIN_LEN", 4 );
define( "PASSWD_MAX_LEN", 128 ); define( "PASSWD_MAX_LEN", 128 );
$LOGIN_TIMEOUT = 7200; # number of idle seconds before timeout # Language that messages are initially written in.
# This should never change.
define("DEFAULT_LANG", "en");
$SUPPORTED_LANGS = array( # what languages we have translations for # Languages we have translations for
$SUPPORTED_LANGS = array(
"en" => "English", "en" => "English",
"pl" => "Polski", "pl" => "Polski",
"it" => "Italiano", "it" => "Italiano",
@ -30,4 +33,6 @@ $SUPPORTED_LANGS = array( # what languages we have translations for
"fr" => "Français" "fr" => "Français"
); );
?> # Idle seconds before timeout
$LOGIN_TIMEOUT = 7200;

View file

@ -37,12 +37,16 @@ function __() {
# First argument is always string to be translated # First argument is always string to be translated
$tag = $args[0]; $tag = $args[0];
if (empty($LANG) || $LANG == DEFAULT_LANG)
$translated = $tag;
else
$translated = $_t[$LANG][$tag]; $translated = $_t[$LANG][$tag];
if (empty($translated)) { if (empty($translated)) {
# if it's a supported language, but there isn't a translation, # if it's a supported language, but there isn't a translation,
# alert the visitor to the missing translation. # alert the visitor to the missing translation.
# #
$translated = "<b style=\"color: red\">_${tag}_</b>"; $translated = "_${tag}_";
} }
# This condition is to reorganise the arguments in case of # This condition is to reorganise the arguments in case of
@ -63,4 +67,3 @@ function __() {
return $translated; return $translated;
} }
?>