[aur-dev] [PATCH] Some translation files clean up. New __() behaviour.
From 74fe2004840382a5c8d3558f0e19580722f7bcc1 Mon Sep 17 00:00:00 2001 From: Loui Chang <louipc.ist@gmail.com> Date: Thu, 21 Feb 2008 16:56:13 -0500 Subject: [PATCH] Some translation files clean up. New __() behaviour. No more need to pass an array to __() for string substitutions. ex. __("I have %s apples and %s oranges", 5, 6) translation_tool seems broken. I shall investigate Signed-off-by: Loui Chang <louipc.ist@gmail.com> --- web/html/index.php | 6 +++--- web/html/packages.php | 2 +- web/html/testpo.php | 6 +++--- web/lang/en/acctfuncs_po.inc | 11 ++++++++++- web/lang/en/common_po.inc | 8 +++++++- web/lang/en/hacker_po.inc | 2 +- web/lang/en/index_po.inc | 5 ++--- web/lang/en/pkgfuncs_po.inc | 29 +++++++++++++++++------------ web/lang/en/search_po.inc | 1 + web/lang/en/submit_po.inc | 4 +--- web/lang/en/template_po.inc | 2 +- web/lang/en/test_po.inc | 2 +- web/lang/it/acctfuncs_po.inc | 10 ++++------ web/lang/it/aur_po.inc | 3 ++- web/lib/acctfuncs.inc | 13 +++++++------ web/lib/pkgfuncs.inc | 2 +- web/lib/translator.inc | 24 ++++++++++++++++-------- web/utils/translation_tool | 9 ++++----- 18 files changed, 82 insertions(+), 57 deletions(-) diff --git a/web/html/index.php b/web/html/index.php index 895fc8a..2112731 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -18,8 +18,8 @@ echo "<table border='0' cellpadding='0' cellspacing='3' width='90%'>\n"; # MAIN: Top echo "<tr>\n"; print "<td class='boxSoft' valign='top' colspan='2'>"; -print "<p>".__("Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information.", array('<a href="http://wiki.archlinux.org/index.php/AUR_User_Guidelines">', '</a>', '<a href="http://wiki.archlinux.org/index.php/AUR_Trusted_User_Guidelines">', '</a>'))."<br>"; -print __("Contributed PKGBUILDs <b>must</b> conform to the %hArch Packaging Standards%h otherwise they will be deleted!", array('<a href="http://wiki.archlinux.org/index.php/Arch_Packaging_Standards">', '</a>'))."</p>"; +print "<p>".__("Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information.", '<a href="http://wiki.archlinux.org/index.php/AUR_User_Guidelines">', '</a>', '<a href="http://wiki.archlinux.org/index.php/AUR_Trusted_User_Guidelines">', '</a>')."<br>"; +print __("Contributed PKGBUILDs <b>must</b> conform to the %hArch Packaging Standards%h otherwise they will be deleted!", '<a href="http://wiki.archlinux.org/index.php/Arch_Packaging_Standards">', '</a>')."</p>"; print "<p>".__("Remember to vote for your favourite packages!")."<br>"; print __("The most popular packages will be provided as binary packages in [community].")."</p>"; print "</td>"; @@ -157,7 +157,7 @@ if (!empty($user)) { # Number of outdated packages print "<tr>"; print "<td class='boxSoft'>"; - print "<span class='f4'>".__("Out-of-date")."</span>"; + print "<span class='f4'>".__("Out of Date")."</span>"; print "</td>"; print "<td class='boxSoft'><span class='f4'>$flagged_outdated</span></td>"; print "</tr>"; diff --git a/web/html/packages.php b/web/html/packages.php index 053756f..8322d13 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -91,7 +91,7 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . ". You may view your package at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=" . $row['ID']; $body = wordwrap($body, 70); $headers = "To: ".$row['Email']."\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; - @mail(' ', "AUR Out-of-date Notification for ".$row['Name'], $body, $headers); + @mail(' ', "AUR Out of date Notification for ".$row['Name'], $body, $headers); } } diff --git a/web/html/testpo.php b/web/html/testpo.php index 75da92a..1104e56 100644 --- a/web/html/testpo.php +++ b/web/html/testpo.php @@ -26,14 +26,14 @@ print "<html><body bgcolor='white'>\n"; print "<p>\n"; print __("Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h.", - array("<a href='".$_SERVER['PHP_SELF']."?LANG=en'>","English","</a>", + "<a href='".$_SERVER['PHP_SELF']."?LANG=en'>","English","</a>", "<a href='".$_SERVER['PHP_SELF']."?LANG=es'>","Español","</a>", "<a href='".$_SERVER['PHP_SELF']."?LANG=de'>","Deutsch","</a>", - "<a href='".$_SERVER['PHP_SELF']."?LANG=fr'>","Français","</a>")); + "<a href='".$_SERVER['PHP_SELF']."?LANG=fr'>","Français","</a>"); print "</p>\n"; print "<p>\n"; -print __("My current language tag is: '%s'.", array($LANG)); +print __("My current language tag is: '%s'.", $LANG); print "</p>\n"; print "<ul>\n"; diff --git a/web/lang/en/acctfuncs_po.inc b/web/lang/en/acctfuncs_po.inc index c19bfdb..321c303 100644 --- a/web/lang/en/acctfuncs_po.inc +++ b/web/lang/en/acctfuncs_po.inc @@ -89,5 +89,14 @@ $_t["en"]["Developer"] = "Developer"; $_t["en"]["View this user's packages"] = "View this user's packages"; -?> +$_t["en"]["It must be between %s and %s characters long"] = "It must be between %s and %s characters long"; + +$_t["en"]["Your password must be at least %s characters."] = "Your password must be at least %s characters"; + +$_t["en"]["Can contain only one period, underscore or hyphen."] = "Can contain only one period, underscore or hyphen."; +$_t["en"]["Start and end with a letter or number"] = "Start and end with a letter or number"; + +$_t["en"]["The username is invalid."] = "The username is invalid."; + +?> diff --git a/web/lang/en/common_po.inc b/web/lang/en/common_po.inc index 0d04caa..b647a9c 100644 --- a/web/lang/en/common_po.inc +++ b/web/lang/en/common_po.inc @@ -33,4 +33,10 @@ $_t["en"]["Create"] = "Create"; $_t["en"]["More"] = "More"; -?> \ No newline at end of file +$_t["en"]["Home"] = "Home"; +$_t["en"]["Accounts"] = "Accounts"; +$_t["en"]["Packages"] = "Packages"; +$_t["en"]["My Packages"] = "My Packages"; + + +?> diff --git a/web/lang/en/hacker_po.inc b/web/lang/en/hacker_po.inc index a400a28..49764e1 100644 --- a/web/lang/en/hacker_po.inc +++ b/web/lang/en/hacker_po.inc @@ -15,4 +15,4 @@ $_t["en"]["Your session id is invalid."] = "Your session id is invalid."; $_t["en"]["If this problem persists, please contact the site administrator."] = "If this problem persists, please contact the site administrator."; -?> \ No newline at end of file +?> diff --git a/web/lang/en/index_po.inc b/web/lang/en/index_po.inc index bdeb87f..f9d5073 100644 --- a/web/lang/en/index_po.inc +++ b/web/lang/en/index_po.inc @@ -89,10 +89,9 @@ $_t["en"]["The most popular packages will be provided as binary packages in [com $_t["en"]["Packages added or updated in the past 7 days"] = "Packages added or updated in the past 7 days"; -$_t["en"]["Out-of-date"] = "Out-of-date"; - $_t["en"]["DISCLAIMER"] = "DISCLAIMER: Unsupported PKGBUILDs are user produced content, by downloading them you agree to do so at your own risk."; -$_t["en"]["Login failure: Bad user or pass."] = "Login failure: Bad user or pass."; +$_t["en"]["Out of Date"] = "Out of Date"; ?> + diff --git a/web/lang/en/pkgfuncs_po.inc b/web/lang/en/pkgfuncs_po.inc index 3e7d318..2395367 100644 --- a/web/lang/en/pkgfuncs_po.inc +++ b/web/lang/en/pkgfuncs_po.inc @@ -23,7 +23,7 @@ $_t["en"]["Delete comment"] = "Delete comment"; $_t["en"]["Go"] = "Go"; -$_t["en"]["Unflag Out-of-date"] = "Unflag Out-of-date"; +$_t["en"]["Unflag Out-of-date"] = "Unflag Out of Date"; $_t["en"]["Go back to %hpackage details view%h."] = "Go back to %hpackage details view%h."; @@ -31,8 +31,6 @@ $_t["en"]["Error retrieving package details."] = "Error retrieving package detai $_t["en"]["Description"] = "Description"; -$_t["en"]["My Packages"] = "My Pkgs"; - $_t["en"]["Keywords"] = "Keywords"; $_t["en"]["Dependencies"] = "Dependencies"; @@ -121,15 +119,6 @@ $_t["en"]["The above files have been verified (by %s) and are safe to use."] = " $_t["en"]["Be careful! The above files may contain malicious code that can damage your system."] = "Be careful! The above files may contain malicious code that can damage your system."; -$_t["en"]["Flag Safe"] = "Flag Safe"; - -$_t["en"]["Flag Package Safe To Use"] = "Flag Package Safe To Use"; - -$_t["en"]["Unflag Safe"] = "Unflag Safe"; - -$_t["en"]["Unflag Package Safe To Use"] = "Unflag Package Safe To Use"; - -$_t["en"]["Safe"] = "Safe"; $_t["en"]["Age"] = "Age"; @@ -161,4 +150,20 @@ $_t["en"]["Toggle Notify"] = "Toggle Notify"; $_t["en"]["Showing results %s - %s of %s"] = "Showing results %s - %s of %s"; +$_t["en"]["Leave the password fields blank to keep your same password."] = ""; + +$_t["en"]["You must log in to view user information."] = "You must log in to view user information."; + +$_t["en"]["Could not retrieve information for the specified user."] = ""; + +$_t["en"]["Use this form to search existing accounts."] = ""; + +$_t["en"]["Use this form to create an account."] = ""; + +$_t["en"]["Use this form to update your account."] = ""; + +$_t["en"]["You are not allowed to access this area."] = ""; + +$_t["en"]["You do not have permission to edit this account."] = ""; + ?> diff --git a/web/lang/en/search_po.inc b/web/lang/en/search_po.inc index 6c73a1a..0c6e467 100644 --- a/web/lang/en/search_po.inc +++ b/web/lang/en/search_po.inc @@ -75,4 +75,5 @@ $_t["en"]["The selected packages have been unflagged safe."] = "The selected pac $_t["en"]["Couldn't unflag package safe."] = "Couldn't unflag package safe."; + ?> diff --git a/web/lang/en/submit_po.inc b/web/lang/en/submit_po.inc index 9f21b72..ee3695d 100644 --- a/web/lang/en/submit_po.inc +++ b/web/lang/en/submit_po.inc @@ -95,6 +95,4 @@ $_t["en"]["Missing arch variable in PKGBUILD."] = "Missing arch variable in PKGB $_t["en"]["Missing license variable in PKGBUILD."] = "Missing license variable in PKGBUILD."; - - -?> \ No newline at end of file +?> diff --git a/web/lang/en/template_po.inc b/web/lang/en/template_po.inc index db437be..af83375 100644 --- a/web/lang/en/template_po.inc +++ b/web/lang/en/template_po.inc @@ -13,4 +13,4 @@ global $_t; $_t["en"]["Hi, this is worth reading!"] = "Hi, this is worth reading!"; -?> \ No newline at end of file +?> diff --git a/web/lang/en/test_po.inc b/web/lang/en/test_po.inc index 28c0e10..be6fff2 100644 --- a/web/lang/en/test_po.inc +++ b/web/lang/en/test_po.inc @@ -19,4 +19,4 @@ $_t["en"]["Hello, again!"] = "Hello, again!"; $_t["en"]["My current language tag is: '%s'."] = "My current language tag is: '%s'."; -?> \ No newline at end of file +?> diff --git a/web/lang/it/acctfuncs_po.inc b/web/lang/it/acctfuncs_po.inc index ebada42..d4ab768 100644 --- a/web/lang/it/acctfuncs_po.inc +++ b/web/lang/it/acctfuncs_po.inc @@ -83,14 +83,12 @@ $_t["it"]["Developer"] = "Sviluppatore"; $_t["it"]["View this user's packages"] = "Visualizza i pacchetti di quest'utente"; -$_t["it"]["start and end with a letter or number"] = "inizia e finisce con una lettera o un numero"; +$_t["it"]["Start and end with a letter or number"] = "Inizia e finisce con una lettera o un numero"; -$_t["it"]["Your password must be at least "] = "La password deve essere di almeno "; +$_t["it"]["Your password must be at least %s characters."] = "La password deve essere di almeno %s."; $_t["it"]["The username is invalid."] = "Il nome utente non è valido."; -$_t["it"]["It must be "] = "Deve essere "; +$_t["it"]["Can contain only one period, underscore or hyphen."] = "Può contenere solo un punto, un trattino basso o un trattino."; -$_t["it"]["can contain only one period, underscore or hyphen."] = "può contenere solo un punto, un trattino basso o un trattino."; - -?> \ No newline at end of file +?> diff --git a/web/lang/it/aur_po.inc b/web/lang/it/aur_po.inc index ac24bb9..87c6e09 100644 --- a/web/lang/it/aur_po.inc +++ b/web/lang/it/aur_po.inc @@ -39,4 +39,5 @@ $_t["it"]["Login failure: Bad user or pass."] = "Autenticazione fallita: nome ut $_t["it"]["Trusted User"] = "Trusted User"; -?> \ No newline at end of file +?> + diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc index 5775101..4951b8c 100644 --- a/web/lib/acctfuncs.inc +++ b/web/lib/acctfuncs.inc @@ -201,18 +201,19 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="", if (!$error && !valid_username($U) && !user_is_privileged($editor_user)) $error = __("The username is invalid.") . "<ul>\n" - ."<li>" . __("It must be " . USERNAME_MIN_LEN . "-" . USERNAME_MAX_LEN - . " characters long") . "</li>" - . "<li>" . __("start and end with a letter or number") . "</li>" - . "<li>" . __("can contain only one period, underscore or hyphen.") + ."<li>" . __("It must be between %s and %s characters long", + USERNAME_MIN_LEN, USERNAME_MAX_LEN ) + . "</li>" + . "<li>" . __("Start and end with a letter or number") . "</li>" + . "<li>" . __("Can contain only one period, underscore or hyphen.") . "</li>\n</ul>"; if (!$error && $P && $C && ($P != $C)) { $error = __("Password fields do not match."); } if (!$error && $P != '' && !good_passwd($P)) - $error = __("Your password must be at least " . PASSWD_MIN_LEN - . " characters."); + $error = + __("Your password must be at least %s characters.",PASSWD_MIN_LEN); if (!$error && !valid_email($E)) { $error = __("The email address is invalid."); diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index c559750..98fb700 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -1089,7 +1089,7 @@ function pkg_search_page($SID="") { # print number of results # ok this styling sucks print "<tr><td align='center' colspan='0'><span class='f4'><span class='blue'>"; - print __("Showing results %s - %s of %s", array($first, $last, $allresults)); + print __("Showing results %s - %s of %s", $first, $last, $allresults); print "</span></span></td></tr>"; # first print the legend diff --git a/web/lib/translator.inc b/web/lib/translator.inc index bfae276..25f6b13 100644 --- a/web/lib/translator.inc +++ b/web/lib/translator.inc @@ -17,31 +17,39 @@ # $_t["es"]["My cat is large."] = "Mi gato esta grande."; # # examples: -# print __("%s has %s apples.", array("Bill", "5")); -# print __("This is a %h%s%h problem!", array("<b>","major","</b>")); +# print __("%s has %s apples.", "Bill", "5"); +# print __("This is a %h%s%h problem!", "<b>","major","</b>"); include_once("common_po.inc"); -function __($tag, $args=array()) { +function __() { global $_t; global $LANG; # create the translation, if it doesn't exist, highlight it # + $args = func_get_args(); + + # First argument is always string to be translated + $tag = $args[0]; + $translated = $_t[$LANG][$tag]; - if (!$translated) { + if (empty($translated)) { # if it's a supported language, but there isn't a translation, # alert the visitor to the missing translation. # - $translated = "<font color=\"red\"><b>_" . $tag . "_</b></font>"; + $translated = "<b style=\"color: red\">_${tag}_</b>"; } # replace escape substitutions # - if (!empty($args)) { - while (list($k, $v) = each($args)) { - $translated = preg_replace("/\%[sh]/", $v, $translated, 1); + $num_args = func_num_args(); + + # Subsequent arguments are strings to be formatted + if ( $num_args > 1 ) { + for ($i = 1; $i < $num_args; $i++) { + $translated = preg_replace("/\%[sh]/", $args[$i], $translated, 1); } } return $translated; diff --git a/web/utils/translation_tool b/web/utils/translation_tool index ae9ae1d..df32508 100755 --- a/web/utils/translation_tool +++ b/web/utils/translation_tool @@ -182,8 +182,7 @@ if force: f.write("\n") trans = raw_input(term+" = ") f.write('$_t["%s"]["%s"] = "%s";\n' % (trans_abbrv, term, trans)) - f.write("\n"); - f.write("?>"); + f.write("\n?>\n"); f.close() else: # need to leave existing file intact, and only append on terms that are new @@ -216,13 +215,13 @@ else: f = open(po,'w') f.write("".join(contents)) f.write('\ninclude_once(\"%s/%s\");\n' % (trans_abbrv, po)) - f.write("\n?>"); + f.write("\n?>\n"); f.close() else: f = open(po,'w') f.write(INC_HEADER) f.write('\ninclude_once(\"%s/%s\");\n' % (trans_abbrv, po)) - f.write('\n?>') + f.write("\n?>\n") f.close() # first read in file contents so we can hash what already exists # @@ -264,7 +263,7 @@ else: f.write("\n"); trans = raw_input(term+" = ") f.write('$_t["%s"]["%s"] = "%s";\n' % (trans_abbrv, term, trans)) - f.write("\n?>"); + f.write("\n?>\n"); f.close() # Print out warnings for unused and little-used common entries. -- 1.5.4.2
Hmm never mind this I think my email client mangled this.
participants (1)
-
Loui