SVGHMI: i18n: fix .POT generation + other cosmetic fixes.
authorEdouard Tisserant <edouard@beremiz.fr>
Wed, 20 Mar 2024 12:15:23 +0100
changeset 3918 9f0ef23569cb
parent 3917 43e7fd0cb88e
child 3919 0ce4b50d1182
SVGHMI: i18n: fix .POT generation + other cosmetic fixes.
svghmi/i18n.py
--- a/svghmi/i18n.py	Wed Mar 20 11:09:24 2024 +0100
+++ b/svghmi/i18n.py	Wed Mar 20 12:15:23 2024 +0100
@@ -17,9 +17,6 @@
 import re
 from email.parser import HeaderParser
 
-# to have it for python 2, had to install 
-# https://pypi.org/project/pycountry/18.12.8/
-# python2 -m pip install pycountry==18.12.8 --user
 import pycountry
 from dialogs import MessageBoxOnce
 from POULibrary import UserAddressedException
@@ -185,6 +182,7 @@
 "Content-Transfer-Encoding: 8bit\\n"
 "Generated-By: SVGHMI 1.0\\n"
 
+
 '''
 escapes = []
 
@@ -202,9 +200,7 @@
 make_escapes()
 
 def escape(s):
-    l = [escapes[c] if c < 128 else bytes([c]) for c in s]
-    return b''.join(l)
-    #return bytes([escapes[c] if c < 128 else c for c in s])
+    return b''.join([escapes[c] if c < 128 else bytes([c]) for c in s])
 
 def normalize(s):
     # This converts the various Python string types into a format that is
@@ -257,12 +253,12 @@
                     if len(locline) + len(s) <= 78:
                         locline = locline + s
                     else:
-                        fp.write(locline)
+                        fp.write(locline + b'\n')
                         locline = locpfx + s
                 if len(locline) > len(locpfx):
-                    fp.write(locline)
-                fp.write(b'msgid '+normalize(k))
-                fp.write(b'msgstr ""\n')
+                    fp.write(locline + b'\n')
+                fp.write(b'msgid ' + normalize(k) + b'\n')
+                fp.write(b'msgstr ""\n\n')
 
 
 class POReader: