]> git.lyx.org Git - lyx.git/blobdiff - po/lyx_pot.py
Math.lyx: add workaround that this manual can be compiled also without having the...
[lyx.git] / po / lyx_pot.py
index 551f00953328c78699c5297e97ac68eb2a20529e..ac2efeb16aeb078fc21adf2dbd7c21d02ebc25bd 100755 (executable)
@@ -84,9 +84,13 @@ def layouts_l10n(input_files, output, base):
     InsetLayout = re.compile(r'^InsetLayout\s+(.*)')
     DescBegin = re.compile(r'#+\s*DescriptionBegin\s*$')
     DescEnd = re.compile(r'#+\s*DescriptionEnd\s*$')
+    I18nPreamble = re.compile(r'\s*(Lang)|(Babel)Preamble\s*$')
+    EndI18nPreamble = re.compile(r'\s*End(Lang)|(Babel)Preamble\s*$')
+    I18nString = re.compile(r'_\(([^\)]+)\)')
 
     for src in input_files:
         readingDescription = False
+        readingI18nPreamble = False
         descStartLine = -1
         descLines = []
         lineno = 0
@@ -106,6 +110,20 @@ def layouts_l10n(input_files, output, base):
                 readingDescription = True
                 descStartLine = lineno
                 continue
+            if readingI18nPreamble:
+                res = EndI18nPreamble.search(line)
+                if res != None:
+                    readingI18nPreamble = False
+                    continue
+                res = I18nString.search(line)
+                if res != None:
+                    string = res.group(1)
+                    writeString(out, src, base, lineno, string)
+                continue
+            res = I18nPreamble.search(line)
+            if res != None:
+                readingI18nPreamble = True
+                continue
             res = NameRE.search(line)
             if res != None:
                 string = res.group(1)
@@ -180,7 +198,7 @@ def languages_l10n(input_files, output, base):
     '''Generate pot file from lib/language'''
     output = open(output, 'w')
     # assuming only one language file
-    reg = re.compile('[\w-]+\s+[\w"]+\s+"([\w \-\(\)]+)"\s+(true|false)\s+[\w-]+\s+\w+\s+"[^"]*"')
+    reg = re.compile('[\w-]+\s+[\w"]+\s+"([\w \-\(\),]+)"\s+(true|false)\s+[\w-]+\s+\w+\s+"[^"]*"')
     input = open(input_files[0])
     for lineno, line in enumerate(input.readlines()):
         if line[0] == '#':
@@ -358,3 +376,4 @@ if __name__ == '__main__':
     else:
         languages_l10n(args, output, base)
 
+