summaryrefslogtreecommitdiffstats
path: root/web/utils/genpopo
diff options
context:
space:
mode:
authorsimo <simo>2005-06-10 19:30:49 +0000
committersimo <simo>2005-06-10 19:30:49 +0000
commit7044610e32b37c079e03cab8bf9cfa8a8f381ec9 (patch)
tree666a7c8c77a274b0c9cb0ba6b7fd20a535d418cf /web/utils/genpopo
parentf1889a9e3d968f194e4b6955915f0e0c3c43622c (diff)
downloadaurweb-7044610e32b37c079e03cab8bf9cfa8a8f381ec9.tar.xz
New Translation Structure
Diffstat (limited to 'web/utils/genpopo')
-rwxr-xr-xweb/utils/genpopo55
1 files changed, 46 insertions, 9 deletions
diff --git a/web/utils/genpopo b/web/utils/genpopo
index 6e59b1e..652f9fc 100755
--- a/web/utils/genpopo
+++ b/web/utils/genpopo
@@ -128,6 +128,9 @@ for dir in ['../html', '../lib', 'html', 'lib']:
# option is passed, just overwrite the entire thing.
#
os.chdir(lang_dir)
+if not os.path.exists('en'):
+ os.mkdir('en')
+
if force:
# just going to overwrite any existing files
#
@@ -136,13 +139,15 @@ if force:
f = open(po,'w')
f.write(INC_HEADER)
-
+ f.write('\ninclude_once(\"en/%s\");\n' % po)
+ f.write('\n?>')
+ f.close()
+
+ f = open("en/"+po,'w')
+ f.write(INC_HEADER)
for term in lang[po].keys():
f.write("\n")
f.write('$_t["en"]["%s"] = "%s";\n' % (term, 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("?>");
@@ -150,13 +155,48 @@ if force:
else:
# need to leave existing file intact, and only append on terms that are new
#
+ incre = re.compile('^include_once\("en\/(.*)"\);')
mapre = re.compile('^\$_t\["en"\]\["(.*)"\].*$')
for po in lang.keys():
+ got_match = False
print "Updating %s..." % po
+ try:
+ f = open(po, 'r')
+ new_file = 0
+ except:
+ new_file = 1
+
+ if not new_file:
+ contents = f.readlines()
+ f.close()
+ # strip off beginning/ending empty lines
+ #
+ while contents[0] == '':
+ del contents[0]
+ while contents[-1] in ['', "\n", "?>", "?>\n", "\n?>"]:
+ del contents[-1]
+
+ for line in contents:
+ match = incre.search(line)
+ if match:
+ got_match = True
+ if not got_match:
+ f = open(po,'w')
+ f.write("".join(contents))
+ f.write('\ninclude_once(\"en/%s\");\n' % po)
+ f.write("\n?>");
+ f.close()
+ else:
+ f = open(po,'w')
+ f.write(INC_HEADER)
+ f.write('\ninclude_once(\"en/%s\");\n' % po)
+ f.write('\n?>')
+ f.close()
+
# first read in file contents so we can hash what already exists
#
try:
- f = open(po, 'r')
+ f = open('en/'+po, 'r')
new_file = 0
except:
new_file = 1
@@ -182,7 +222,7 @@ else:
# now append any new terms to EOF
#
- f = open(po, 'w')
+ f = open('en/'+po, 'w')
if not new_file:
f.write("".join(contents))
else:
@@ -192,9 +232,6 @@ else:
if term not in existing_terms:
f.write("\n");
f.write('$_t["en"]["%s"] = "%s";\n' % (term, 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()