('binary' encoding is not supported, stored as-is)
>>3) Do you have any comments to either script? (the strip charset script has
>>to be extended to include plural support before this code can be committed)
>>  
>>
>I think this parser is overkill. How about something like this (just 
>typing, not testing):
[ ... ]
>I don't think we need anything more complicated than this sed-like 
>replacement in the Windows build.
Ok. How about the attached patch:
Log:
[[[
Add charset stripping to Windows build.
* build/generator/build_locale.ezt: Add intermediate .spo step
  also used in the Makefile build
* build/generator/gen_win.py (): Pass the base name instead of
  .po and .mo.
  (POFile.__Init__): Initialize fields fields from base parameter.
* build/strip-po-charset.py: New file. Contains the actual sed-like
  script.
]]]
Index: build/generator/build_locale.ezt
===================================================================
--- build/generator/build_locale.ezt	(revision 9884)
+++ build/generator/build_locale.ezt	(working copy)
@@ -2,8 +2,11 @@
 @rem **************************************************************************
 cd ..\..\subversion\po
 [for pofiles]echo Running msgfmt on [pofiles.po]...
-msgfmt.exe -o [pofiles.mo] [pofiles.po]
+python ..\..\build\strip-po-charset.py [pofiles.po] [pofiles.spo]
 if not errorlevel 0 goto err
+msgfmt.exe -o [pofiles.mo] [pofiles.spo]
+if not errorlevel 0 goto err
+del [pofiles.spo]
 [end]
 goto end
 @rem **************************************************************************
Index: build/generator/gen_win.py
===================================================================
--- build/generator/gen_win.py	(revision 9884)
+++ build/generator/gen_win.py	(working copy)
@@ -143,7 +143,7 @@
     if self.enable_nls:
       for po in os.listdir(os.path.join('subversion', 'po')):
         if fnmatch.fnmatch(po, '*.po'):
-          pofiles.append(POFile(po, po[:-2] + 'mo'))
+          pofiles.append(POFile(po[:-3]))
     
     data = {'pofiles': pofiles}
     self.write_with_template(os.path.join('build', 'win32', 'build_locale.bat'),
@@ -706,6 +706,7 @@
 
 class POFile:
   "Item class for holding po file info"
-  def __init__(self, po, mo):
-    self.po = po
-    self.mo = mo
+  def __init__(self, base):
+    self.po = base + '.po'
+    self.spo = base + '.spo'
+    self.mo = base + '.mo'
Index: build/strip-po-charset.py
===================================================================
--- build/strip-po-charset.py	(revision 0)
+++ build/strip-po-charset.py	(revision 0)
@@ -0,0 +1,23 @@
+#
+# strip-po-charset.py
+#
+
+import sys
+
+def strip_po_charset(inp, out):
+
+    for line in inp.xreadlines():
+        if line.find("\"Content-Type: text/plain; charset=UTF-8\\n\"") == -1:
+            out.write(line)
+
+
+def main():
+
+    if len(sys.argv) != 3:
+        print "Unsupported number of arguments; 2 required."
+        sys.exit(1)
+
+    strip_po_charset(open(sys.argv[1],'r'), open(sys.argv[2],'w'))
+
+if __name__ == '__main__':
+    main()
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 25 21:28:49 2004