summaryrefslogtreecommitdiffstats
path: root/web/utils/genpopo
diff options
context:
space:
mode:
authoreric <eric>2004-06-18 18:23:14 +0200
committereric <eric>2004-06-18 18:23:14 +0200
commit1e35dc01cf94ba1ec4923b8f040e49b4dc399860 (patch)
tree15404a70070fe01c1bcf432fba6befbdb2f2f097 /web/utils/genpopo
parent79f64a059254bbbae93cf7c2f9dfa512aa5f9f7e (diff)
downloadaur-1e35dc01cf94ba1ec4923b8f040e49b4dc399860.tar.gz
aur-1e35dc01cf94ba1ec4923b8f040e49b4dc399860.tar.xz
finishing touches on genpopo, started playing with _real_ PHP code and svn keywords
Diffstat (limited to 'web/utils/genpopo')
-rwxr-xr-xweb/utils/genpopo52
1 files changed, 28 insertions, 24 deletions
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()