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>
This commit is contained in:
Loui Chang 2008-12-21 02:23:43 -05:00 committed by Callan Barrett
parent cfeb080dcd
commit 78c2b5c67f
24 changed files with 51 additions and 363 deletions

View file

@ -1,15 +1,16 @@
<?php <?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('aur.inc'); # access AUR common functions
include_once("acctfuncs.inc"); # access Account specific 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
set_lang(); # this sets up the visitor's language set_lang(); # this sets up the visitor's language
check_sid(); # see if they're still logged in 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 # Main page processing here
# #

View file

@ -1,9 +1,9 @@
<?php <?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("aur.inc");
include_lang('tu_po.inc');
set_lang(); set_lang();
check_sid(); check_sid();
html_header(); html_header();

View file

@ -1,15 +1,15 @@
<?php <?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("aur.inc");
include('stats.inc');
set_lang(); set_lang();
check_sid(); check_sid();
include('stats.inc');
include_lang('index_po.inc');
include_lang('pkgfuncs_po.inc');
html_header( __("Home") ); html_header( __("Home") );
$dbh = db_connect(); $dbh = db_connect();

View file

@ -1,11 +1,10 @@
<?php <?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("aur.inc"); # access AUR common functions
include_once("acctfuncs.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 # if they've got a cookie, log them out - need to do this before
# sending any HTML output. # sending any HTML output.

View file

@ -1,11 +1,11 @@
<?php <?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("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 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 check_sid(); # see if they're still logged in
# Set the title to the current query if required # Set the title to the current query if required

View file

@ -1,10 +1,10 @@
<?php <?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("aur.inc"); # access AUR common functions
include("pkgfuncs.inc"); # use some form of this for i18n support 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 set_lang(); # this sets up the visitor's language
check_sid(); # see if they're still logged in check_sid(); # see if they're still logged in
html_header(); # print out the HTML header html_header(); # print out the HTML header

View file

@ -1,15 +1,15 @@
<?php <?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"); include("config.inc");
require('Archive/Tar.php'); require('Archive/Tar.php');
require('Find.php'); require('Find.php');
include("aur.inc"); # access AUR common functions 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("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 set_lang(); # this sets up the visitor's language
check_sid(); # see if they're still logged in check_sid(); # see if they're still logged in

View file

@ -1,9 +1,9 @@
<?php <?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("aur.inc");
include_lang('tu_po.inc');
set_lang(); set_lang();
check_sid(); check_sid();
html_header(); html_header();

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -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");

View file

@ -1,5 +1,5 @@
<?php <?php
include_once("acctfuncs_po.inc"); include_lang('acctfuncs_po.inc');
# Display the standard Account form, pass in default values if any # Display the standard Account form, pass in default values if any
# #

View file

@ -1,22 +1,23 @@
<?php <?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('Content-Type: text/html; charset=utf-8');
header('Cache-Control: no-cache, must-revalidate'); header('Cache-Control: no-cache, must-revalidate');
header('Expires: Tue, 11 Oct 1988 22:00:00 GMT'); // quite a special day header('Expires: Tue, 11 Oct 1988 22:00:00 GMT'); // quite a special day
header('Pragma: no-cache'); 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("config.inc");
include_once("aur_po.inc"); include_once("version.inc");
// TODO: remove this, move translations over for login form
include_once("index_po.inc");
include_once("acctfuncs.inc"); include_once("acctfuncs.inc");
# TODO do we need to set the domain on cookies? I seem to remember some # 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 # security concerns about not using domains - but it's not like
# we really care if another site can see what language/SID a user # we really care if another site can see what language/SID a user
# is using... # is using...
#
# return an array of info for each Trusted user # return an array of info for each Trusted user

View file

@ -1,5 +1,5 @@
<?php <?php
include_once("pkgfuncs_po.inc"); include_lang('pkgfuncs_po.inc');
include_once("config.inc"); include_once("config.inc");
# define variables used during pkgsearch # define variables used during pkgsearch

View file

@ -1,4 +1,6 @@
<?php <?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang');
# this include file provides support for i18n # this include file provides support for i18n
# #
@ -23,7 +25,17 @@
# deprecated usage: # deprecated usage:
# print __("%s has %s apples.", array("Bill", "5")); # 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 __() { function __() {
global $_t; global $_t;
@ -41,10 +53,8 @@ function __() {
else else
$translated = $_t[$LANG][$tag]; $translated = $_t[$LANG][$tag];
# If there is no translation, just print the given string.
if (empty($translated)) { 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;
} }

View file

@ -2,10 +2,10 @@
# This template shows how a front page script is commonly coded. # 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("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 set_lang(); # this sets up the visitor's language
check_sid(); # see if they're still logged in check_sid(); # see if they're still logged in
html_header(); # print out the HTML header html_header(); # print out the HTML header