changeset 2767:95a97b45a8e9

simple po file conversion to new (macro) markup
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 26 Aug 2007 13:52:35 +0200
parents 44ebe3cdd515
children d1a1f10a0451
files MoinMoin/i18n/Makefile MoinMoin/i18n/tools/markup15to16.py
diffstat 2 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/i18n/Makefile	Sun Aug 26 12:32:27 2007 +0200
+++ b/MoinMoin/i18n/Makefile	Sun Aug 26 13:52:35 2007 +0200
@@ -14,6 +14,7 @@
 	@lang=`echo $@ | sed -e 's/\.MoinMoin\.po-update$$//'`; \
 	echo "$$lang:"; \
 	tools/wiki2po.py $${lang}; \
+	tools/markup15to16.py $${lang}; \
 	echo "msgmerge $$lang.$(DOMAIN).po $(DOMAIN).pot -o $$lang.$(DOMAIN).new.po"; \
 	if msgmerge $$lang.$(DOMAIN).po $(DOMAIN).pot -o $$lang.$(DOMAIN).new.po; then \
 	  if cmp $$lang.$(DOMAIN).po $$lang.$(DOMAIN).new.po >/dev/null 2>&1; then \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/i18n/tools/markup15to16.py	Sun Aug 26 13:52:35 2007 +0200
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+"""
+    convert some markup contained in po files to new link/macro markup
+"""
+DOMAIN = "MoinMoin"
+
+import re
+import sys
+import codecs
+
+def run():
+    sys.path.insert(0, '../..')
+
+    langfname = sys.argv[1]
+    lang = langfname.replace('_', '-') # module names use _ instead of -
+
+    f = codecs.open("%s.%s.po" % (langfname, DOMAIN), "r", "utf-8")
+    text = f.read()
+    f.close()
+
+    # replace [[Macro(...)]] by <<Macro(...)>>
+    macro_rule = r"\[\[(?P<macro>.*?)\]\]"
+    macro_repl = r"<<\g<macro>>>"
+    macro_re = re.compile(macro_rule, re.U)
+    text = macro_re.sub(macro_repl, text)
+
+    #print repr(text)
+
+    f = codecs.open("%s.%s.po" % (langfname, DOMAIN), "w", "utf-8")
+    f.write(text)
+    f.close()
+
+if __name__ == "__main__":
+    run()
+