From 1e35dc01cf94ba1ec4923b8f040e49b4dc399860 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 18 Jun 2004 16:23:14 +0000 Subject: finishing touches on genpopo, started playing with _real_ PHP code and svn keywords --- support/schema/aur-schema.sql | 1 + web/html/css/fonts.css | 8 ++++++- web/html/index.php | 13 +++++++---- web/html/testpo.php | 42 +++++++++++++++++++++++++++++++++ web/lang/common_po.inc | 15 +++++++++--- web/lang/index_po.inc | 33 +++++++++----------------- web/lang/test_po.inc | 34 +++++++++++++++++++++++++++ web/lib/aur.inc | 54 +++++++++++++++++++++++++++++++++++++++++++ web/lib/translator.inc | 22 +++++++++++++----- web/utils/genpopo | 52 ++++++++++++++++++++++------------------- 10 files changed, 213 insertions(+), 61 deletions(-) create mode 100644 web/html/testpo.php create mode 100644 web/lang/test_po.inc create mode 100644 web/lib/aur.inc diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql index 37bbc01..662552f 100644 --- a/support/schema/aur-schema.sql +++ b/support/schema/aur-schema.sql @@ -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, diff --git a/web/html/css/fonts.css b/web/html/css/fonts.css index 7def621..3fc35e3 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 58bba8d..fcd57c7 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -1,9 +1,12 @@ \n"; -print _("Hello, again!")."
\n"; -print _("Julie was here!")."
\n"; -print _("Abernathy was here!")."
\n"; +print "Hi, this is worth reading!
\n"; + + + +html_footer("\$Id$"); ?> diff --git a/web/html/testpo.php b/web/html/testpo.php new file mode 100644 index 0000000..fbb0fa8 --- /dev/null +++ b/web/html/testpo.php @@ -0,0 +1,42 @@ +\n"; + +print "

\n"; +print _("Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h.", + array("","English","", + "","Español","", + "","Deutsch","", + "","Français","")); +print "

\n"; + +print "

\n"; +print _("My current language tag is: '%s'.", array($LANG)); +print "

\n"; + +print "\n"; +print "\n"; + +?> diff --git a/web/lang/common_po.inc b/web/lang/common_po.inc index c314876..6c04677 100644 --- a/web/lang/common_po.inc +++ b/web/lang/common_po.inc @@ -1,5 +1,14 @@ \ No newline at end of file diff --git a/web/lang/index_po.inc b/web/lang/index_po.inc index 22b1456..6c04677 100644 --- a/web/lang/index_po.inc +++ b/web/lang/index_po.inc @@ -1,25 +1,14 @@ 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 0000000..d8edf5f --- /dev/null +++ b/web/lang/test_po.inc @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/web/lib/aur.inc b/web/lib/aur.inc new file mode 100644 index 0000000..c45e1dd --- /dev/null +++ b/web/lib/aur.inc @@ -0,0 +1,54 @@ +\n"; + print "\n"; + print "AUR\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print "
AUR: An "; + print "ArchLinux project
\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print "
"; + print ""; + print "ArchLinux User-community Repository
\n"; + print "
\n"; + print "\n\n"; + + return; +} + +# common footer +# +function html_footer($ver="") { + print "\n\n"; + print "

\n"; + if ($ver) { + print "\n"; + print "\n"; + print "
"; + print "".$ver."\n"; + print "
\n"; + } + print "\n"; + return; +} + +# vim: ts=2 sw=2 noet ft=php +?> diff --git a/web/lib/translator.inc b/web/lib/translator.inc index 2d45f2a..79eb39c 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 = "_" . $tag . "_"; } diff --git a/web/utils/genpopo b/web/utils/genpopo index ea6569a..64c71ed 100755 --- a/web/utils/genpopo +++ b/web/utils/genpopo @@ -12,6 +12,22 @@ # -f: force, overwrite existing translated files, otherwise append # +INC_HEADER = """\ + 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(" 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() -- cgit v1.2.3-70-g09d2