Author: esr
Date: Sat Apr 4 15:56:48 2009
New Revision: 34458
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34458&view=rev
Log:
Add to new wmlgettext the ability to embed translation notes
Modified:
trunk/data/tools/wesnoth/wmliterator.py
trunk/data/tools/wmlxgettext
Modified: trunk/data/tools/wesnoth/wmliterator.py
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/wmliterator.py?rev=34458&r1=34457&r2=34458&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmliterator.py (original)
+++ trunk/data/tools/wesnoth/wmliterator.py Sat Apr 4 15:56:48 2009
@@ -240,6 +240,8 @@
return (['#define'],)*2
elif text.find('#enddef') >= 0:
elements.append(('#enddef', text.find('#enddef'), -1))
+ elif text.startswith('#po:') or text.startswith('# po:'):
+ elements.append(("#po", 0, 0))
else:
commentSearch = 0
begincomment = text.find('#', commentSearch)
Modified: trunk/data/tools/wmlxgettext
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmlxgettext?rev=34458&r1=34457&r2=34458&view=diff
==============================================================================
--- trunk/data/tools/wmlxgettext (original)
+++ trunk/data/tools/wmlxgettext Sat Apr 4 15:56:48 2009
@@ -78,6 +78,8 @@
sys.exit(1)
else:
version = string_strip(m.group(1))
+
+ os.chdir(directory)
print '''\
msgid ""
@@ -181,9 +183,15 @@
print "Inline macro", nav
nav.element = nav.element[0]
get_translatables(nav, fn)
+ elif nav.element == "#po":
+ if verbose > 1:
+ print "Passthrough for", nav
+ opener_stack.append((nav.element, fn, nav.lineno))
+ translatables.append((nav.text.lstrip(), opener_stack[:]))
+ opener_stack.pop()
elif verbose > 1:
print "Unhandled", nav
- # Gather a dictionary describing the context of every
+ # Gather a list describing the context of every
# translatable string.
for dir in arguments:
seqno = 0
@@ -208,7 +216,11 @@
for (key, value) in contexts.items():
print key, "->", value
# Generate a report from the translatables
+ notes = ""
for (translatable, context) in translatables:
+ if translatable.startswith("#po"):
+ notes += translatable.replace("po:", "")
+ continue
attribs = ""
for (i, (tag, file, line)) in enumerate(context):
if i == len(context)-1 or tag.startswith("{"):
@@ -219,6 +231,8 @@
if key[0] == tag and key[1] == file and key[2] == line:
attribs = " has " + ", ".join(value)
print "# %s, line %d: %s%s" % (file, line, tag, attribs)
+ print notes,
+ notes = ""
print 'msgid "%s"' % translatable
print 'msgstr ""'
print ""
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits