checking in latest genpopo code - still not wrking

This commit is contained in:
eric 2004-06-14 23:58:32 +00:00
parent 5268aa5802
commit d96a600997
2 changed files with 39 additions and 16 deletions

4
web/lang/common_po.list Normal file
View file

@ -0,0 +1,4 @@
# This file contains the list of text strings that appear
# in more than one PHP script. It only supports one line
# strings at the moment.
#

View file

@ -7,9 +7,14 @@
# "xxx_po.inc" file in the 'lang' subdirectory and places the # "xxx_po.inc" file in the 'lang' subdirectory and places the
# i18n strings into the file in the proper format. # i18n strings into the file in the proper format.
# #
# usage: genpopo [-v] [-f]
# -v: verbose, print duplicate terms that could be moved to common_po
# -f: force, overwrite existing translated files, otherwise append
#
import sys import sys
print_dupes = '-v' in sys.argv print_dupes = '-v' in sys.argv
force = '-f' in sys.argv
import re, os import re, os
up = re.compile('_\(\s*"(([^"]|(?<=\\\\)["])+)"') up = re.compile('_\(\s*"(([^"]|(?<=\\\\)["])+)"')
@ -29,6 +34,7 @@ for dir in ['../lang', 'lang']:
lines = f.readlines() lines = f.readlines()
f.close() f.close()
for line in lines: for line in lines:
if line[0] != '#':
common[line[:-1]] = 0 common[line[:-1]] = 0
lang['common_po.po'][line[:-1]] = 1 lang['common_po.po'][line[:-1]] = 1
os.chdir(current_dir) os.chdir(current_dir)
@ -105,23 +111,36 @@ for dir in ['../html', '../lib', 'html', 'lib']:
# if they do exist, only append new stuff to the end. If the 'force' # if they do exist, only append new stuff to the end. If the 'force'
# option is passed, just overwrite the entire thing. # option is passed, just overwrite the entire thing.
# #
mapre = re.compile('^\$_t\["en\]["(.*)"].*$')
os.chdir(lang_dir) os.chdir(lang_dir)
if force:
# just going to overwrite any existing files
#
for po in lang.keys(): for po in lang.keys():
print "Generating %s..." % po print "Generating %s..." % po
f = open(po,'w') f = open(po,'w')
f.write("<?\n")
f.write("""# INSTRUCTIONS TO TRANSLATORS: f.write("""# INSTRUCTIONS TO TRANSLATORS:
# blah blah blah.... # blah blah blah....
""") """)
for term in lang[po].keys(): for term in lang[po].keys():
f.write("\n"); f.write("\n");
f.write('_$t["en"]["%s"] = "%s";\n' % (term, term)) f.write('$_t["en"]["%s"] = "%s";\n' % (term, term))
f.write('# _$t["es"]["%s"] = "--> Spanish translation here. <--";\n' % term) f.write('# $_t["es"]["%s"] = "--> Spanish translation here. <--";\n' % term)
f.write('# _$t["fr"]["%s"] = "--> French 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["de"]["%s"] = "--> German translation here. <--";\n' % term)
f.write("\n"); f.write("\n");
f.write("?>");
f.close() f.close()
else:
# TODO left off here... need to leave existing file intact, and only
# append on terms that are new
#
pass
# Print out warnings for unused and little-used common entries. # Print out warnings for unused and little-used common entries.
# #