From 1a1a6eb36e17315f08eee0e44a83fe4bdf0887f5 Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Wed, 9 Jul 2008 14:38:08 -0400 Subject: 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 which can cause validation errors depending on where the string is placed. Signed-off-by: Loui Chang --- web/lib/translator.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'web/lib/translator.inc') diff --git a/web/lib/translator.inc b/web/lib/translator.inc index 41ece89b..f16bd11f 100644 --- a/web/lib/translator.inc +++ b/web/lib/translator.inc @@ -37,12 +37,16 @@ function __() { # First argument is always string to be translated $tag = $args[0]; - $translated = $_t[$LANG][$tag]; + if (empty($LANG) || $LANG == DEFAULT_LANG) + $translated = $tag; + else + $translated = $_t[$LANG][$tag]; + if (empty($translated)) { # if it's a supported language, but there isn't a translation, # alert the visitor to the missing translation. # - $translated = "_${tag}_"; + $translated = "_${tag}_"; } # This condition is to reorganise the arguments in case of @@ -63,4 +67,3 @@ function __() { return $translated; } -?> -- cgit v1.2.3-24-g4f1b From 2c6bae2e63c69f87599e5ef081eeba0a8d08bf00 Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Wed, 23 Jul 2008 10:36:41 -0400 Subject: Convert special chars in translations to html entities. This closes FS#10809 - bug in french translation of AUR web interface Signed-off-by: Loui Chang --- web/lib/translator.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'web/lib/translator.inc') diff --git a/web/lib/translator.inc b/web/lib/translator.inc index f16bd11f..fb9ed635 100644 --- a/web/lib/translator.inc +++ b/web/lib/translator.inc @@ -25,7 +25,6 @@ include_once("common_po.inc"); - function __() { global $_t; global $LANG; @@ -49,6 +48,8 @@ function __() { $translated = "_${tag}_"; } + $translated = htmlspecialchars($translated, ENT_QUOTES); + # This condition is to reorganise the arguments in case of # deprecated usage. __("string", array("string","string")) if (!empty($args[1]) && is_array($args[1])) { @@ -64,6 +65,7 @@ function __() { $translated = preg_replace("/\%[sh]/", $args[$i], $translated, 1); } } + return $translated; } -- cgit v1.2.3-24-g4f1b