summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/html/css/fonts.css8
-rw-r--r--web/html/index.php13
-rw-r--r--web/html/testpo.php42
-rw-r--r--web/lang/common_po.inc15
-rw-r--r--web/lang/index_po.inc33
-rw-r--r--web/lang/test_po.inc34
-rw-r--r--web/lib/aur.inc54
-rw-r--r--web/lib/translator.inc22
-rwxr-xr-xweb/utils/genpopo52
9 files changed, 212 insertions, 61 deletions
diff --git a/web/html/css/fonts.css b/web/html/css/fonts.css
index 7def6210..3fc35e38 100644
--- a/web/html/css/fonts.css
+++ b/web/html/css/fonts.css
@@ -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
{
diff --git a/web/html/index.php b/web/html/index.php
index 58bba8db..fcd57c7f 100644
--- a/web/html/index.php
+++ b/web/html/index.php
@@ -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$");
?>
diff --git a/web/html/testpo.php b/web/html/testpo.php
new file mode 100644
index 00000000..fbb0fa84
--- /dev/null
+++ b/web/html/testpo.php
@@ -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>";
+
+?>
diff --git a/web/lang/common_po.inc b/web/lang/common_po.inc
index c3148760..6c04677c 100644
--- a/web/lang/common_po.inc
+++ b/web/lang/common_po.inc
@@ -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;
+
?> \ No newline at end of file
diff --git a/web/lang/index_po.inc b/web/lang/index_po.inc
index 22b14566..6c04677c 100644
--- a/web/lang/index_po.inc
+++ b/web/lang/index_po.inc
@@ -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. <--";
-
-$_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. <--";
+# 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;
?> \ No newline at end of file
diff --git a/web/lang/test_po.inc b/web/lang/test_po.inc
new file mode 100644
index 00000000..d8edf5f5
--- /dev/null
+++ b/web/lang/test_po.inc
@@ -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'.";
+
+?> \ No newline at end of file
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
new file mode 100644
index 00000000..c45e1dd2
--- /dev/null
+++ b/web/lib/aur.inc
@@ -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
+?>
diff --git a/web/lib/translator.inc b/web/lib/translator.inc
index 2d45f2ab..79eb39c7 100644
--- a/web/lib/translator.inc
+++ b/web/lib/translator.inc
@@ -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>";
}
diff --git a/web/utils/genpopo b/web/utils/genpopo
index ea6569a2..64c71ede 100755
--- a/web/utils/genpopo
+++ b/web/utils/genpopo
@@ -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()