mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
finishing touches on genpopo, started playing with _real_ PHP code and svn keywords
This commit is contained in:
parent
79f64a0592
commit
1e35dc01cf
10 changed files with 212 additions and 60 deletions
|
@ -25,6 +25,7 @@ CREATE TABLE Users (
|
|||
Email CHAR(64) NOT NULL,
|
||||
Passwd CHAR(32) NOT NULL,
|
||||
RealName CHAR(64) NOT NULL DEFAULT '',
|
||||
LangPreference CHAR(2) NOT NULL DEFAULT 'en',
|
||||
IRCNick CHAR(32) NOT NULL DEFAULT '',
|
||||
LastVoted BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
NewPkgNotify TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
|
|
|
@ -34,7 +34,13 @@
|
|||
font-family: trebuchet ms, tahoma, verdana;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
span.fixed /* Monospace fixed-font */
|
||||
{
|
||||
color: #000;
|
||||
font-family: monospace, fixed, terminal;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Font Attribute Change (#6c83b0)*/
|
||||
span.blue
|
||||
{
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?
|
||||
include_once("index_po.inc");
|
||||
include("index_po.inc");
|
||||
include("aur.inc");
|
||||
html_header();
|
||||
|
||||
print _("Hello, world!")."<br/>\n";
|
||||
print _("Hello, again!")."<br/>\n";
|
||||
print _("Julie was here!")."<br/>\n";
|
||||
print _("Abernathy was here!")."<br/>\n";
|
||||
|
||||
print "Hi, this is worth reading!<br>\n";
|
||||
|
||||
|
||||
|
||||
html_footer("\$Id$");
|
||||
?>
|
||||
|
|
42
web/html/testpo.php
Normal file
42
web/html/testpo.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?
|
||||
# This is a sample script to demonstrate how the AUR will
|
||||
# handle i18n. Note: When the PHP script is finished, and
|
||||
# has the proper include file (see below), and the _()
|
||||
# function has been used (see below), use the web/utils/genpopo
|
||||
# script to parse the PHP script and pull out the text
|
||||
# that requires translation and puts the mapping into the
|
||||
# include file.
|
||||
#
|
||||
|
||||
# Each AUR PHP script that requires i18n support, needs to
|
||||
# define an 'xxx_po.inc' file where the i18n mapping will
|
||||
# reside.
|
||||
#
|
||||
include("test_po.inc");
|
||||
|
||||
|
||||
# Use the _() function to identify text that requires
|
||||
# translation to other languages. The examples below
|
||||
# show how to use %-substitution.
|
||||
#
|
||||
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=es'>","Español","</a>",
|
||||
"<a href='".$_SERVER['PHP_SELF']."?LANG=de'>","Deutsch","</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 "</p>\n";
|
||||
|
||||
print "<ul>\n";
|
||||
print _("Hello, world!")."<br/>\n";
|
||||
print _("Hello, again!")."<br/>\n";
|
||||
print "</ul>\n";
|
||||
print "</body>\n</html>";
|
||||
|
||||
?>
|
|
@ -1,5 +1,14 @@
|
|||
<?
|
||||
# INSTRUCTIONS TO TRANSLATORS:
|
||||
# blah blah blah....
|
||||
|
||||
# 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;
|
||||
|
||||
?>
|
|
@ -1,25 +1,14 @@
|
|||
<?
|
||||
# INSTRUCTIONS TO TRANSLATORS:
|
||||
# blah blah blah....
|
||||
|
||||
$_t["en"]["Julie was here!"] = "Julie was here!";
|
||||
# $_t["es"]["Julie was here!"] = "--> Spanish translation here. <--";
|
||||
# $_t["fr"]["Julie was here!"] = "--> French translation here. <--";
|
||||
# $_t["de"]["Julie was here!"] = "--> German translation here. <--";
|
||||
# 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 (\).
|
||||
#
|
||||
|
||||
$_t["en"]["Hello, again!"] = "Hello, again!";
|
||||
# $_t["es"]["Hello, again!"] = "--> Spanish translation here. <--";
|
||||
# $_t["fr"]["Hello, again!"] = "--> French translation here. <--";
|
||||
# $_t["de"]["Hello, again!"] = "--> German translation here. <--";
|
||||
|
||||
$_t["en"]["Hello, world!"] = "Hello, world!";
|
||||
# $_t["es"]["Hello, world!"] = "--> Spanish translation here. <--";
|
||||
# $_t["fr"]["Hello, world!"] = "--> French translation here. <--";
|
||||
# $_t["de"]["Hello, world!"] = "--> German translation here. <--";
|
||||
|
||||
$_t["en"]["Abernathy was here!"] = "Abernathy was here!";
|
||||
# $_t["es"]["Abernathy was here!"] = "--> Spanish translation here. <--";
|
||||
# $_t["fr"]["Abernathy was here!"] = "--> French translation here. <--";
|
||||
# $_t["de"]["Abernathy was here!"] = "--> German translation here. <--";
|
||||
include_once("translator.inc");
|
||||
global $_t;
|
||||
|
||||
?>
|
34
web/lang/test_po.inc
Normal file
34
web/lang/test_po.inc
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?
|
||||
# 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"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h.";
|
||||
$_t["es"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Seleccione su lengua aquí: %h%s%h, %h%s%h, %h%s%h, %h%s%h.";
|
||||
$_t["fr"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Choisissez votre langue ici: %h%s%h, %h%s%h, %h%s%h, %h%s%h.";
|
||||
$_t["de"]["Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h."] = "Wählen Sie Ihre Sprache hier vor: %h%s%h, %h%s%h, %h%s%h, %h%s%h.";
|
||||
|
||||
$_t["en"]["Hello, world!"] = "Hello, world!";
|
||||
$_t["es"]["Hello, world!"] = "¡Hola, mundo!";
|
||||
$_t["fr"]["Hello, world!"] = "Bonjour, monde!";
|
||||
$_t["de"]["Hello, world!"] = "Hallo, Welt!";
|
||||
|
||||
$_t["en"]["Hello, again!"] = "Hello, again!";
|
||||
$_t["es"]["Hello, again!"] = "¡Hola, otra vez!";
|
||||
$_t["fr"]["Hello, again!"] = "Bonjour, encore!";
|
||||
$_t["de"]["Hello, again!"] = "Hallo, wieder!";
|
||||
|
||||
$_t["en"]["My current language tag is: '%s'."] = "My current language tag is: '%s'.";
|
||||
$_t["es"]["My current language tag is: '%s'."] = "Mi etiqueta de lengua actual es: '%s'.";
|
||||
$_t["fr"]["My current language tag is: '%s'."] = "Ma étiquette de langue courante est: '%s'.";
|
||||
$_t["de"]["My current language tag is: '%s'."] = "Meine gegenwärtige Sprachflagge ist: '%s'.";
|
||||
|
||||
?>
|
54
web/lib/aur.inc
Normal file
54
web/lib/aur.inc
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?
|
||||
# common header
|
||||
#
|
||||
function html_header() {
|
||||
print "<html>\n";
|
||||
print "<head>\n";
|
||||
print "<title>AUR</title>\n";
|
||||
print "<link rel='stylesheet' type='text/css' href='/css/fonts.css'/>\n";
|
||||
print "<link rel='stylesheet' type='text/css' href='/css/containers.css'/>\n";
|
||||
print "<link rel='shortcut icon' href='/favicon.ico'/>\n";
|
||||
print "</head>\n";
|
||||
print "<body bgcolor='white'>\n";
|
||||
print "<table cellspacing='0' ";
|
||||
print "style='background-color: #000; width: 100%;'>\n";
|
||||
print " <tr>\n";
|
||||
print " <td class='preHeader'><span class='preHeader'>AUR: An ";
|
||||
print "ArchLinux project</span></td>\n";
|
||||
print " </tr>\n";
|
||||
print " <tr>\n";
|
||||
print " <td class='headerFill'>\n";
|
||||
print " <table width='100%'>\n";
|
||||
print " <tr>\n";
|
||||
print " <td class='headerDisplay'><a href='";
|
||||
print $_SERVER['PHP_SELF']."'>";
|
||||
print "<img src='/images/aur.png' border='0'></a></td>\n";
|
||||
print " <td class='headerDisplay' align='right'>";
|
||||
print "<span class='fix'>ArchLinux User-community Repository</span></td>\n";
|
||||
print " </tr>\n";
|
||||
print " </table>\n";
|
||||
print " </tr>\n";
|
||||
print "</table>\n";
|
||||
print "<!-- Start of main content -->\n\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# common footer
|
||||
#
|
||||
function html_footer($ver="") {
|
||||
print "\n\n<!-- End of main content -->";
|
||||
print "<p>\n";
|
||||
if ($ver) {
|
||||
print "<table border='0' cellpadding='0' cellspacing='0' width='90%'>\n";
|
||||
print "<tr><td align='right'>";
|
||||
print "<span class='fix'>".$ver."<span/>\n";
|
||||
print "</td></tr>\n";
|
||||
print "</table>\n";
|
||||
}
|
||||
print "</body>\n</html>";
|
||||
return;
|
||||
}
|
||||
|
||||
# vim: ts=2 sw=2 noet ft=php
|
||||
?>
|
|
@ -24,20 +24,30 @@ include_once("common_po.inc");
|
|||
|
||||
function _($tag, $args=array()) {
|
||||
global $_t;
|
||||
global $_REQUEST;
|
||||
global $LANG;
|
||||
|
||||
# default to English if the lang hasn't been provided
|
||||
$supported_langs = array(
|
||||
"en" => 1, # English
|
||||
"es" => 1, # Español
|
||||
"de" => 1, # Deutsch
|
||||
"fr" => 1, # Français
|
||||
);
|
||||
|
||||
# default to English if the lang hasn't been provided or isn't supported
|
||||
#
|
||||
if (!$LANG) {
|
||||
$lang = "en";
|
||||
} else {
|
||||
$lang = $LANG;
|
||||
$LANG = $_REQUEST['LANG'];
|
||||
if (!$LANG || !array_key_exists($LANG, $supported_langs)) {
|
||||
$LANG = "en";
|
||||
}
|
||||
|
||||
# create the translation, if it doesn't exist, highlight it
|
||||
#
|
||||
$translated = $_t[$lang][$tag];
|
||||
$translated = $_t[$LANG][$tag];
|
||||
if (!$translated) {
|
||||
# if it's a supported language, but there isn't a translation,
|
||||
# alert the visitor to the missing translation.
|
||||
#
|
||||
$translated = "<blink><b>_" . $tag . "_</b></blink>";
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,22 @@
|
|||
# -f: force, overwrite existing translated files, otherwise append
|
||||
#
|
||||
|
||||
INC_HEADER = """\
|
||||
<?
|
||||
# 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;
|
||||
"""
|
||||
|
||||
|
||||
import sys
|
||||
print_dupes = '-v' in sys.argv
|
||||
force = '-f' in sys.argv
|
||||
|
@ -107,7 +123,7 @@ for dir in ['../html', '../lib', 'html', 'lib']:
|
|||
|
||||
os.chdir(current_dir)
|
||||
|
||||
# TODO Now generate all the .inc files if they don't already exist.
|
||||
# Now generate all the .inc files if they don't already exist.
|
||||
# if they do exist, only append new stuff to the end. If the 'force'
|
||||
# option is passed, just overwrite the entire thing.
|
||||
#
|
||||
|
@ -119,17 +135,14 @@ if force:
|
|||
print "Generating %s..." % po
|
||||
|
||||
f = open(po,'w')
|
||||
f.write("<?\n")
|
||||
f.write("""# INSTRUCTIONS TO TRANSLATORS:
|
||||
# blah blah blah....
|
||||
""")
|
||||
f.write(INC_HEADER)
|
||||
|
||||
for term in lang[po].keys():
|
||||
f.write("\n");
|
||||
f.write("\n")
|
||||
f.write('$_t["en"]["%s"] = "%s";\n' % (term, term))
|
||||
f.write('# $_t["es"]["%s"] = "--> Spanish translation here. <--";\n' % term)
|
||||
f.write('# $_t["fr"]["%s"] = "--> French translation here. <--";\n' % term)
|
||||
f.write('# $_t["de"]["%s"] = "--> German translation here. <--";\n' % term)
|
||||
f.write('# $_t["es"]["%s"] = "--> Traducción española aquí. <--";\n' % term)
|
||||
f.write('# $_t["fr"]["%s"] = "--> Traduction française ici. <--";\n' % term)
|
||||
f.write('# $_t["de"]["%s"] = "--> Deutsche Übersetzung hier. <--";\n' % term)
|
||||
|
||||
f.write("\n");
|
||||
f.write("?>");
|
||||
|
@ -153,21 +166,11 @@ else:
|
|||
contents = f.readlines()
|
||||
f.close()
|
||||
|
||||
# remove PHP tags
|
||||
#
|
||||
stripped_contents = []
|
||||
for line in contents:
|
||||
if line.strip() not in ["<?", "?>"]:
|
||||
stripped_contents.append(line)
|
||||
contents = stripped_contents
|
||||
|
||||
# strip off beginning/ending empty lines
|
||||
#
|
||||
while contents[0] == '':
|
||||
del contents[0]
|
||||
while contents[-1] == '':
|
||||
del contents[-1]
|
||||
if contents[-1] == "\n":
|
||||
while contents[-1] in ['', "\n", "?>", "?>\n", "\n?>"]:
|
||||
del contents[-1]
|
||||
|
||||
# next, collect existing terms
|
||||
|
@ -180,17 +183,18 @@ else:
|
|||
# now append any new terms to EOF
|
||||
#
|
||||
f = open(po, 'w')
|
||||
f.write("<?\n")
|
||||
if not new_file:
|
||||
f.write("".join(contents))
|
||||
else:
|
||||
f.write(INC_HEADER)
|
||||
|
||||
for term in lang[po].keys():
|
||||
if term not in existing_terms:
|
||||
f.write("\n");
|
||||
f.write('$_t["en"]["%s"] = "%s";\n' % (term, term))
|
||||
f.write('# $_t["es"]["%s"] = "--> Spanish translation here. <--";\n' % term)
|
||||
f.write('# $_t["fr"]["%s"] = "--> French translation here. <--";\n' % term)
|
||||
f.write('# $_t["de"]["%s"] = "--> German translation here. <--";\n' % term)
|
||||
f.write('# $_t["es"]["%s"] = "--> Traducción española aquí. <--";\n' % term)
|
||||
f.write('# $_t["fr"]["%s"] = "--> Traduction française ici. <--";\n' % term)
|
||||
f.write('# $_t["de"]["%s"] = "--> Deutsche Übersetzung hier. <--";\n' % term)
|
||||
f.write("\n?>");
|
||||
f.close()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue