diff options
author | Loui Chang <louipc.ist@gmail.com> | 2008-12-21 02:23:43 -0500 |
---|---|---|
committer | Callan Barrett <wizzomafizzo@gmail.com> | 2008-12-21 18:03:27 +0900 |
commit | 78c2b5c67faec190985c3fb9509e942add4dc54c (patch) | |
tree | 8de400422c50db32e530883bc954919c66b4c05c /web | |
parent | cfeb080dcd7f593cf70a7d12ef873c95c95ae40f (diff) | |
download | aurweb-78c2b5c67faec190985c3fb9509e942add4dc54c.tar.xz |
Introduce function include_lang for translations.
This includes only the requested language for each page and
makes top level language include files obsolete.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web')
-rw-r--r-- | web/html/account.php | 13 | ||||
-rw-r--r-- | web/html/addvote.php | 4 | ||||
-rw-r--r-- | web/html/index.php | 10 | ||||
-rw-r--r-- | web/html/logout.php | 5 | ||||
-rw-r--r-- | web/html/packages.php | 6 | ||||
-rw-r--r-- | web/html/pkgedit.php | 4 | ||||
-rw-r--r-- | web/html/pkgsubmit.php | 4 | ||||
-rw-r--r-- | web/html/tu.php | 4 | ||||
-rw-r--r-- | web/lang/account_po.inc | 28 | ||||
-rw-r--r-- | web/lang/acctfuncs_po.inc | 32 | ||||
-rw-r--r-- | web/lang/aur_po.inc | 32 | ||||
-rw-r--r-- | web/lang/common_po.inc | 32 | ||||
-rw-r--r-- | web/lang/index_po.inc | 30 | ||||
-rw-r--r-- | web/lang/logout_po.inc | 30 | ||||
-rw-r--r-- | web/lang/pkgedit_po.inc | 32 | ||||
-rw-r--r-- | web/lang/pkgfuncs_po.inc | 32 | ||||
-rw-r--r-- | web/lang/search_po.inc | 32 | ||||
-rw-r--r-- | web/lang/submit_po.inc | 32 | ||||
-rw-r--r-- | web/lang/tu_po.inc | 11 | ||||
-rw-r--r-- | web/lib/acctfuncs.inc | 2 | ||||
-rw-r--r-- | web/lib/aur.inc | 15 | ||||
-rw-r--r-- | web/lib/pkgfuncs.inc | 2 | ||||
-rw-r--r-- | web/lib/translator.inc | 18 | ||||
-rw-r--r-- | web/template/template.phps | 4 |
24 files changed, 51 insertions, 363 deletions
diff --git a/web/html/account.php b/web/html/account.php index 5efc401..d0273dd 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -1,15 +1,16 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); -include("aur.inc"); # access AUR common functions -include_once("acctfuncs.inc"); # access Account specific functions -include("pkgfuncs_po.inc"); # Add to handle the i18n of My Packages -include("account_po.inc"); # use some form of this for i18n support +include('aur.inc'); # access AUR common functions +include_once('acctfuncs.inc'); # access Account specific functions set_lang(); # this sets up the visitor's language check_sid(); # see if they're still logged in -html_header(__("Accounts")); # print out the HTML header +include_lang('pkgfuncs_po.inc'); # Add to handle the i18n of My Packages +include_lang('account_po.inc'); # use some form of this for i18n support + +html_header(__('Accounts')); # Main page processing here # diff --git a/web/html/addvote.php b/web/html/addvote.php index 6b30e49..a31a1ff 100644 --- a/web/html/addvote.php +++ b/web/html/addvote.php @@ -1,9 +1,9 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); -include("tu_po.inc"); include("aur.inc"); +include_lang('tu_po.inc'); set_lang(); check_sid(); html_header(); diff --git a/web/html/index.php b/web/html/index.php index d664086..e2c840a 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -1,15 +1,15 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); -include('index_po.inc'); -include("pkgfuncs_po.inc"); include("aur.inc"); -include('stats.inc'); - set_lang(); check_sid(); +include('stats.inc'); +include_lang('index_po.inc'); +include_lang('pkgfuncs_po.inc'); + html_header( __("Home") ); $dbh = db_connect(); diff --git a/web/html/logout.php b/web/html/logout.php index 41dedc3..88a1e26 100644 --- a/web/html/logout.php +++ b/web/html/logout.php @@ -1,11 +1,10 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include("aur.inc"); # access AUR common functions include_once("acctfuncs.inc"); # access AUR common functions -include("logout_po.inc"); # use some form of this for i18n support -set_lang(); # this sets up the visitor's language + # if they've got a cookie, log them out - need to do this before # sending any HTML output. diff --git a/web/html/packages.php b/web/html/packages.php index 2452991..90ab72c 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -1,11 +1,11 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include("aur.inc"); # access AUR common functions -include("pkgfuncs.inc"); # package specific functions -include("search_po.inc"); # use some form of this for i18n support set_lang(); # this sets up the visitor's language +include('pkgfuncs.inc'); # package specific functions +include_lang('search_po.inc'); # use some form of this for i18n support check_sid(); # see if they're still logged in # Set the title to the current query if required diff --git a/web/html/pkgedit.php b/web/html/pkgedit.php index 974f14b..ff82663 100644 --- a/web/html/pkgedit.php +++ b/web/html/pkgedit.php @@ -1,10 +1,10 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include("aur.inc"); # access AUR common functions include("pkgfuncs.inc"); # use some form of this for i18n support -include("pkgedit_po.inc"); # i18n translations for this script +include_lang("pkgedit_po.inc"); # i18n translations for this script set_lang(); # this sets up the visitor's language check_sid(); # see if they're still logged in html_header(); # print out the HTML header diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 0e4f448..a3949ed 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -1,15 +1,15 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include("config.inc"); require('Archive/Tar.php'); require('Find.php'); include("aur.inc"); # access AUR common functions -include("submit_po.inc"); # use some form of this for i18n support include("pkgfuncs.inc"); # package functions +include_lang('submit_po.inc'); # use some form of this for i18n support set_lang(); # this sets up the visitor's language check_sid(); # see if they're still logged in diff --git a/web/html/tu.php b/web/html/tu.php index 0b8b5c7..2d1eaf3 100644 --- a/web/html/tu.php +++ b/web/html/tu.php @@ -1,9 +1,9 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); -include("tu_po.inc"); include("aur.inc"); +include_lang('tu_po.inc'); set_lang(); check_sid(); html_header(); diff --git a/web/lang/account_po.inc b/web/lang/account_po.inc deleted file mode 100644 index fc23194..0000000 --- a/web/lang/account_po.inc +++ /dev/null @@ -1,28 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/account_po.inc"); - -include_once("it/account_po.inc"); - -include_once("ca/account_po.inc"); - -include_once("pt/account_po.inc"); - -include_once("es/account_po.inc"); - -include_once("de/account_po.inc"); - -include_once("ru/account_po.inc"); -include_once("tr/account_po.inc"); - diff --git a/web/lang/acctfuncs_po.inc b/web/lang/acctfuncs_po.inc deleted file mode 100644 index 5bfbf0a..0000000 --- a/web/lang/acctfuncs_po.inc +++ /dev/null @@ -1,32 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/acctfuncs_po.inc"); - -include_once("it/acctfuncs_po.inc"); - -include_once("ca/acctfuncs_po.inc"); - -include_once("pt/acctfuncs_po.inc"); - -include_once("es/acctfuncs_po.inc"); - -include_once("de/acctfuncs_po.inc"); - -include_once("ru/acctfuncs_po.inc"); - -include_once("fr/acctfuncs_po.inc"); -include_once("tr/acctfuncs_po.inc"); - -include_once("uk/acctfuncs_po.inc"); - diff --git a/web/lang/aur_po.inc b/web/lang/aur_po.inc deleted file mode 100644 index b08e241..0000000 --- a/web/lang/aur_po.inc +++ /dev/null @@ -1,32 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/aur_po.inc"); - -include_once("it/aur_po.inc"); - -include_once("ca/aur_po.inc"); - -include_once("pt/aur_po.inc"); - -include_once("es/aur_po.inc"); - -include_once("de/aur_po.inc"); - -include_once("ru/aur_po.inc"); - -include_once("fr/aur_po.inc"); -include_once("tr/aur_po.inc"); - -include_once("uk/aur_po.inc"); - diff --git a/web/lang/common_po.inc b/web/lang/common_po.inc deleted file mode 100644 index 43237c2..0000000 --- a/web/lang/common_po.inc +++ /dev/null @@ -1,32 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/common_po.inc"); - -include_once("it/common_po.inc"); - -include_once("ca/common_po.inc"); - -include_once("pt/common_po.inc"); - -include_once("es/common_po.inc"); - -include_once("de/common_po.inc"); - -include_once("ru/common_po.inc"); - -include_once("fr/common_po.inc"); -include_once("tr/common_po.inc"); - -include_once("uk/common_po.inc"); - diff --git a/web/lang/index_po.inc b/web/lang/index_po.inc deleted file mode 100644 index 5e783a7..0000000 --- a/web/lang/index_po.inc +++ /dev/null @@ -1,30 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/index_po.inc"); - -include_once("it/index_po.inc"); - -include_once("ca/index_po.inc"); - -include_once("pt/index_po.inc"); - -include_once("es/index_po.inc"); - -include_once("de/index_po.inc"); - -include_once("ru/index_po.inc"); - -include_once("fr/index_po.inc"); -include_once("tr/index_po.inc"); - diff --git a/web/lang/logout_po.inc b/web/lang/logout_po.inc deleted file mode 100644 index 471f53e..0000000 --- a/web/lang/logout_po.inc +++ /dev/null @@ -1,30 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/logout_po.inc"); - -include_once("it/logout_po.inc"); - -include_once("ca/logout_po.inc"); - -include_once("pt/logout_po.inc"); - -include_once("es/logout_po.inc"); - -include_once("de/logout_po.inc"); - -include_once("ru/logout_po.inc"); -include_once("tr/logout_po.inc"); - -include_once("fr/logout_po.inc"); - diff --git a/web/lang/pkgedit_po.inc b/web/lang/pkgedit_po.inc deleted file mode 100644 index b471d9b..0000000 --- a/web/lang/pkgedit_po.inc +++ /dev/null @@ -1,32 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/pkgedit_po.inc"); - -include_once("it/pkgedit_po.inc"); - -include_once("ca/pkgedit_po.inc"); - -include_once("pt/pkgedit_po.inc"); - -include_once("es/pkgedit_po.inc"); - -include_once("de/pkgedit_po.inc"); - -include_once("ru/pkgedit_po.inc"); - -include_once("fr/pkgedit_po.inc"); -include_once("tr/pkgedit_po.inc"); - -include_once("uk/pkgedit_po.inc"); - diff --git a/web/lang/pkgfuncs_po.inc b/web/lang/pkgfuncs_po.inc deleted file mode 100644 index 5868f45..0000000 --- a/web/lang/pkgfuncs_po.inc +++ /dev/null @@ -1,32 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/pkgfuncs_po.inc"); - -include_once("it/pkgfuncs_po.inc"); - -include_once("ca/pkgfuncs_po.inc"); - -include_once("pt/pkgfuncs_po.inc"); - -include_once("es/pkgfuncs_po.inc"); - -include_once("de/pkgfuncs_po.inc"); - -include_once("ru/pkgfuncs_po.inc"); - -include_once("fr/pkgfuncs_po.inc"); -include_once("tr/pkgfuncs_po.inc"); - -include_once("uk/pkgfuncs_po.inc"); - diff --git a/web/lang/search_po.inc b/web/lang/search_po.inc deleted file mode 100644 index 92c9589..0000000 --- a/web/lang/search_po.inc +++ /dev/null @@ -1,32 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/search_po.inc"); - -include_once("it/search_po.inc"); - -include_once("ca/search_po.inc"); - -include_once("pt/search_po.inc"); - -include_once("es/search_po.inc"); - -include_once("de/search_po.inc"); - -include_once("ru/search_po.inc"); - -include_once("fr/search_po.inc"); -include_once("tr/search_po.inc"); - -include_once("uk/search_po.inc"); - diff --git a/web/lang/submit_po.inc b/web/lang/submit_po.inc deleted file mode 100644 index 60a2041..0000000 --- a/web/lang/submit_po.inc +++ /dev/null @@ -1,32 +0,0 @@ -<?php -# INSTRUCTIONS TO TRANSLATORS -# -# This file contains the i18n translations for a subset of the -# Arch Linux User-community Repository (AUR). This is a PHP -# script, and as such, you MUST pay great attention to the syntax. -# If your text contains any double-quotes ("), you MUST escape -# them with the backslash character (\). -# - -include_once("translator.inc"); -global $_t; - -include_once("pl/submit_po.inc"); - -include_once("it/submit_po.inc"); - -include_once("ca/submit_po.inc"); - -include_once("pt/submit_po.inc"); - -include_once("es/submit_po.inc"); - -include_once("de/submit_po.inc"); - -include_once("ru/submit_po.inc"); - -include_once("fr/submit_po.inc"); -include_once("tr/submit_po.inc"); - -include_once("uk/submit_po.inc"); - diff --git a/web/lang/tu_po.inc b/web/lang/tu_po.inc deleted file mode 100644 index b26d02a..0000000 --- a/web/lang/tu_po.inc +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -include_once("translator.inc"); -global $_t; - -include_once("ru/tu_po.inc"); - -include_once("it/tu_po.inc"); - -include_once("fr/tu_po.inc"); - diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc index d7fabcf..959ae4a 100644 --- a/web/lib/acctfuncs.inc +++ b/web/lib/acctfuncs.inc @@ -1,5 +1,5 @@ <?php -include_once("acctfuncs_po.inc"); +include_lang('acctfuncs_po.inc'); # Display the standard Account form, pass in default values if any # diff --git a/web/lib/aur.inc b/web/lib/aur.inc index e43ddf6..121c692 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -1,22 +1,23 @@ <?php -set_include_path(get_include_path() . PATH_SEPARATOR . '../template'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../template'); header('Content-Type: text/html; charset=utf-8'); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Tue, 11 Oct 1988 22:00:00 GMT'); // quite a special day header('Pragma: no-cache'); -include_once("version.inc"); + +include_once('translator.inc'); +set_lang(); +include_lang('aur_po.inc'); +include_lang('common_po.inc'); + include_once("config.inc"); -include_once("aur_po.inc"); -// TODO: remove this, move translations over for login form -include_once("index_po.inc"); +include_once("version.inc"); include_once("acctfuncs.inc"); # TODO do we need to set the domain on cookies? I seem to remember some # security concerns about not using domains - but it's not like # we really care if another site can see what language/SID a user # is using... -# - # return an array of info for each Trusted user diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index ca054db..dfda0e8 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -1,5 +1,5 @@ <?php -include_once("pkgfuncs_po.inc"); +include_lang('pkgfuncs_po.inc'); include_once("config.inc"); # define variables used during pkgsearch diff --git a/web/lib/translator.inc b/web/lib/translator.inc index 2bb3b23..25f2524 100644 --- a/web/lib/translator.inc +++ b/web/lib/translator.inc @@ -1,4 +1,6 @@ <?php +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); + # this include file provides support for i18n # @@ -23,7 +25,17 @@ # deprecated usage: # print __("%s has %s apples.", array("Bill", "5")); -include_once("common_po.inc"); +include_once('config.inc'); + +function include_lang($trans) { + global $LANG; + + if ($LANG != DEFAULT_LANG) { + return include_once("$LANG/$trans"); + } + else + return true; +} function __() { global $_t; @@ -41,10 +53,8 @@ function __() { else $translated = $_t[$LANG][$tag]; + # If there is no translation, just print the given string. if (empty($translated)) { - # if it's a supported language, but there isn't a translation, - # alert the visitor to the missing translation. - # $translated = $tag; } diff --git a/web/template/template.phps b/web/template/template.phps index 7a86686..358bf52 100644 --- a/web/template/template.phps +++ b/web/template/template.phps @@ -2,10 +2,10 @@ # This template shows how a front page script is commonly coded. -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include("aur.inc"); # access AUR common functions -include("template_po.inc"); # use some form of this for i18n support +include_lang('template_po.inc'); # use some form of this for i18n support set_lang(); # this sets up the visitor's language check_sid(); # see if they're still logged in html_header(); # print out the HTML header |