renamed _() function to __() to avoid gettext conflict

This commit is contained in:
eric 2004-06-18 22:42:07 +00:00
parent d92682fbfd
commit 74594e516d
9 changed files with 145 additions and 19 deletions

View file

@ -11,7 +11,7 @@ Directory Layout:
Scripts: Scripts:
-------- --------
- lib/funcs.inc - lib/aur.inc
This is where we can stick functions that can be shared This is where we can stick functions that can be shared
between the various scripts. Also a good place to put the between the various scripts. Also a good place to put the
MySQL authentication variables since it should live outside MySQL authentication variables since it should live outside

View file

@ -4,8 +4,8 @@ include("aur.inc");
html_header(); html_header();
print "Hi, this is worth reading!<br>\n"; #$dbh = db_connect();
print "Connected...<br>\n";
html_footer("\$Id$"); html_footer("\$Id$");

View file

@ -4,10 +4,10 @@ include("index_po.inc"); # use some form of this for i18n support
html_header(); # print out the HTML header html_header(); # print out the HTML header
# Any text you print out to the visitor, use the _() function # Any text you print out to the visitor, use the __() function
# for i18n support. See 'testpo.php' for more details. # for i18n support. See 'testpo.php' for more details.
# #
print _("Hi, this is worth reading!")."<br/>\n"; print __("Hi, this is worth reading!")."<br/>\n";
html_footer("\$Id$"); # Use the $Id$ keyword html_footer("\$Id$"); # Use the $Id$ keyword

View file

@ -1,7 +1,7 @@
<? <?
# This is a sample script to demonstrate how the AUR will # This is a sample script to demonstrate how the AUR will
# handle i18n. Note: When the PHP script is finished, and # handle i18n. Note: When the PHP script is finished, and
# has the proper include file (see below), and the _() # has the proper include file (see below), and the __()
# function has been used (see below), use the web/utils/genpopo # function has been used (see below), use the web/utils/genpopo
# script to parse the PHP script and pull out the text # script to parse the PHP script and pull out the text
# that requires translation and puts the mapping into the # that requires translation and puts the mapping into the
@ -15,14 +15,14 @@
include("test_po.inc"); include("test_po.inc");
# Use the _() function to identify text that requires # Use the __() function to identify text that requires
# translation to other languages. The examples below # translation to other languages. The examples below
# show how to use %-substitution. # show how to use %-substitution.
# #
print "<html><body bgcolor='white'>\n"; print "<html><body bgcolor='white'>\n";
print "<p>\n"; print "<p>\n";
print _("Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h.", 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>", array("<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=es'>","Español","</a>",
"<a href='".$_SERVER['PHP_SELF']."?LANG=de'>","Deutsch","</a>", "<a href='".$_SERVER['PHP_SELF']."?LANG=de'>","Deutsch","</a>",
@ -30,12 +30,12 @@ print _("Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h.",
print "</p>\n"; print "</p>\n";
print "<p>\n"; print "<p>\n";
print _("My current language tag is: '%s'.", array($LANG)); print __("My current language tag is: '%s'.", array($LANG));
print "</p>\n"; print "</p>\n";
print "<ul>\n"; print "<ul>\n";
print _("Hello, world!")."<br/>\n"; print __("Hello, world!")."<br/>\n";
print _("Hello, again!")."<br/>\n"; print __("Hello, again!")."<br/>\n";
print "</ul>\n"; print "</ul>\n";
print "</body>\n</html>"; print "</body>\n</html>";

64
web/lang/aur_po.inc Normal file
View file

@ -0,0 +1,64 @@
<?
# 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;
$_t["en"]["ArchLinux User-community Repository"] = "ArchLinux User-community Repository";
# $_t["es"]["ArchLinux User-community Repository"] = "--> Traducción española aquí. <--";
# $_t["fr"]["ArchLinux User-community Repository"] = "--> Traduction française ici. <--";
# $_t["de"]["ArchLinux User-community Repository"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["AUR: An ArchLinux project"] = "AUR: An ArchLinux project";
# $_t["es"]["AUR: An ArchLinux project"] = "--> Traducción española aquí. <--";
# $_t["fr"]["AUR: An ArchLinux project"] = "--> Traduction française ici. <--";
# $_t["de"]["AUR: An ArchLinux project"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Logout"] = "Logout";
# $_t["es"]["Logout"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Logout"] = "--> Traduction française ici. <--";
# $_t["de"]["Logout"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Manage"] = "Manage";
# $_t["es"]["Manage"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Manage"] = "--> Traduction française ici. <--";
# $_t["de"]["Manage"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Submit"] = "Submit";
# $_t["es"]["Submit"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Submit"] = "--> Traduction française ici. <--";
# $_t["de"]["Submit"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["%s: An ArchLinux project"] = "%s: An ArchLinux project";
# $_t["es"]["%s: An ArchLinux project"] = "--> Traducción española aquí. <--";
# $_t["fr"]["%s: An ArchLinux project"] = "--> Traduction française ici. <--";
# $_t["de"]["%s: An ArchLinux project"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Accounts"] = "Accounts";
# $_t["es"]["Accounts"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Accounts"] = "--> Traduction française ici. <--";
# $_t["de"]["Accounts"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Vote"] = "Vote";
# $_t["es"]["Vote"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Vote"] = "--> Traduction française ici. <--";
# $_t["de"]["Vote"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Home"] = "Home";
# $_t["es"]["Home"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Home"] = "--> Traduction française ici. <--";
# $_t["de"]["Home"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Packages"] = "Packages";
# $_t["es"]["Packages"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Packages"] = "--> Traduction française ici. <--";
# $_t["de"]["Packages"] = "--> Deutsche Übersetzung hier. <--";
?>

View file

@ -11,4 +11,9 @@
include_once("translator.inc"); include_once("translator.inc");
global $_t; global $_t;
$_t["en"]["Hi, this is worth reading!"] = "Hi, this is worth reading!";
# $_t["es"]["Hi, this is worth reading!"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Hi, this is worth reading!"] = "--> Traduction française ici. <--";
# $_t["de"]["Hi, this is worth reading!"] = "--> Deutsche Übersetzung hier. <--";
?> ?>

View file

@ -1,4 +1,32 @@
<? <?
include_once("aur_po.inc");
# Define global variables
#
# connect to the database
#
function db_connect() {
# NOTE: modify these variables if your MySQL setup is different
#
$AUR_db_host = "localhost:/tmp/mysql.sock";
$AUR_db_name = "AUR";
$AUR_db_user = "aur"; # XXX use something better when deploying
$AUR_db_pass = "aur"; # XXX use something better when deploying
$handle = mysql_pconnect($AUR_db_host, $AUR_db_user, $AUR_db_pass);
if (!$handle) {
die("Error connecting to AUR database: " . mysql_error());
}
mysql_select_db($AUR_db_name, $handle) or
die("Error selecting AUR database: " . mysql_error());
return $handle;
}
# common header # common header
# #
function html_header() { function html_header() {
@ -13,8 +41,9 @@ function html_header() {
print "<table cellspacing='0' "; print "<table cellspacing='0' ";
print "style='background-color: #000; width: 100%;'>\n"; print "style='background-color: #000; width: 100%;'>\n";
print " <tr>\n"; print " <tr>\n";
print " <td class='preHeader'><span class='preHeader'>AUR: An "; print " <td class='preHeader'><span class='preHeader'>";
print "ArchLinux project</span></td>\n"; print __("%s: An ArchLinux project", array("AUR"));
print "</span></td>\n";
print " </tr>\n"; print " </tr>\n";
print " <tr>\n"; print " <tr>\n";
print " <td class='headerFill'>\n"; print " <td class='headerFill'>\n";
@ -28,16 +57,43 @@ function html_header() {
print " </tr>\n"; print " </tr>\n";
print " </table>\n"; print " </table>\n";
print " </tr>\n"; print " </tr>\n";
print "</table>\n";
# Menu items
#
print " <tr>\n";
print " <td class='mainLinks' align='center'>";
print " <span class='f2'><span class='black'>.:</span>";
print " <a href='/index.php'>".__("Home")."</a> ";
print " <span class='black'> - </span> ";
print " <a href='/account.php'>".__("Accounts")."</a> ";
print " <span class='black'> - </span> ";
print " <a href='/pkgsearch.php'>".__("Packages")."</a> ";
print " <span class='black'> - </span> ";
print " <a href='/pkgvote.php'>".__("Vote")."</a> ";
print " <span class='black'> - </span> ";
print " <a href='/pkgmgmnt.php'>".__("Manage")."</a> ";
print " <span class='black'> - </span> ";
print " <a href='/pkgsubmit.php'>".__("Submit")."</a> ";
print " <span class='black'> - </span> ";
print " <a href='/logout.php'>".__("Logout")."</a> ";
print " <span class='black'>:.</span></span>";
print " </td>";
print " </tr>";
print " <tr>\n";
print " <td class='contentDisplay'>\n";
print "<!-- Start of main content -->\n\n"; print "<!-- Start of main content -->\n\n";
return; return;
} }
# common footer # common footer
# #
function html_footer($ver="") { function html_footer($ver="") {
print "\n\n<!-- End of main content -->"; print "\n\n<!-- End of main content -->";
print " </td>\n";
print " </tr>\n";
print "</table>\n";
print "<p>\n"; print "<p>\n";
if ($ver) { if ($ver) {
print "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n"; print "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";

View file

@ -3,7 +3,7 @@
# #
# usage: # usage:
# use the _() function for returning translated strings of # use the __() function for returning translated strings of
# text. The string can contain escape codes %h for HTML # text. The string can contain escape codes %h for HTML
# and %s for regular text. # and %s for regular text.
# #
@ -17,12 +17,13 @@
# $_t["es"]["My cat is large."] = "Mi gato esta grande."; # $_t["es"]["My cat is large."] = "Mi gato esta grande.";
# #
# examples: # examples:
# print _("%s has %s apples.", array("Bill", "5")); # print __("%s has %s apples.", array("Bill", "5"));
# print _("This is a %h%s%h problem!", array("<b>","major","</b>")); # print __("This is a %h%s%h problem!", array("<b>","major","</b>"));
include_once("common_po.inc"); include_once("common_po.inc");
function _($tag, $args=array()) {
function __($tag, $args=array()) {
global $_t; global $_t;
global $_REQUEST; global $_REQUEST;
global $LANG; global $LANG;

View file

@ -3,7 +3,7 @@
# this script iterates through the 'html' and 'lib' directories # this script iterates through the 'html' and 'lib' directories
# looking for php scripts that contain a include_once("xxx_po.inc") # looking for php scripts that contain a include_once("xxx_po.inc")
# line and _() functions. It creates/appends to the corresponding # line and __() functions. It creates/appends to the corresponding
# "xxx_po.inc" file in the 'lang' subdirectory and places the # "xxx_po.inc" file in the 'lang' subdirectory and places the
# i18n strings into the file in the proper format. # i18n strings into the file in the proper format.
# #