summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLoui Chang <louipc.ist@gmail.com>2008-12-21 08:23:43 +0100
committerCallan Barrett <wizzomafizzo@gmail.com>2008-12-21 10:03:27 +0100
commit78c2b5c67faec190985c3fb9509e942add4dc54c (patch)
tree8de400422c50db32e530883bc954919c66b4c05c /web/lib
parentcfeb080dcd7f593cf70a7d12ef873c95c95ae40f (diff)
downloadaur-78c2b5c67faec190985c3fb9509e942add4dc54c.tar.gz
aur-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/lib')
-rw-r--r--web/lib/acctfuncs.inc2
-rw-r--r--web/lib/aur.inc15
-rw-r--r--web/lib/pkgfuncs.inc2
-rw-r--r--web/lib/translator.inc18
4 files changed, 24 insertions, 13 deletions
diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc
index d7fabcf0..959ae4af 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 e43ddf62..121c6921 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 ca054dbc..dfda0e88 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 2bb3b23c..25f25245 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;
}