X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=po%2Flyx_pot.py;h=226e6ecf859feaac32c8d7c6788d76e9cc9883d6;hb=0c8eea0fe526e17c75c524c0eacdacfd78d8d7b2;hp=500185fdba6a38a5f3c49bf74c4226c117d67dc4;hpb=262ae8264abe38dea41bff6e384e27cffc76bd3b;p=lyx.git diff --git a/po/lyx_pot.py b/po/lyx_pot.py index 500185fdba..226e6ecf85 100755 --- a/po/lyx_pot.py +++ b/po/lyx_pot.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # file lyx_pot.py @@ -18,7 +18,7 @@ # from __future__ import print_function -import sys, os, re, getopt +import glob, sys, os, re, getopt import io def relativePath(path, base): @@ -44,9 +44,10 @@ def writeString(outfile, infile, basefile, lineno, string): def ui_l10n(input_files, output, base): '''Generate pot file from lib/ui/*''' - output = io.open(output, 'w', encoding='utf_8') + output = io.open(output, 'w', encoding='utf_8', newline='\n') Submenu = re.compile(r'^[^#]*Submenu\s+"([^"]*)"', re.IGNORECASE) Popupmenu = re.compile(r'^[^#]*PopupMenu\s+"[^"]+"\s+"([^"]*)"', re.IGNORECASE) + Dynamicmenu = re.compile(r'^[^#]*DynamicMenu\s+"[^"]+"\s+"([^"]*)"', re.IGNORECASE) IconPalette = re.compile(r'^[^#]*IconPalette\s+"[^"]+"\s+"([^"]*)"', re.IGNORECASE) Toolbar = re.compile(r'^[^#]*Toolbar\s+"[^"]+"\s+"([^"]*)"', re.IGNORECASE) Item = re.compile(r'[^#]*Item\s+"([^"]*)"', re.IGNORECASE) @@ -59,6 +60,8 @@ def ui_l10n(input_files, output, base): string = string.replace('_', ' ') elif Popupmenu.match(line): (string,) = Popupmenu.match(line).groups() + elif Dynamicmenu.match(line): + (string,) = Dynamicmenu.match(line).groups() elif IconPalette.match(line): (string,) = IconPalette.match(line).groups() elif Toolbar.match(line): @@ -78,23 +81,24 @@ def ui_l10n(input_files, output, base): def layouts_l10n(input_files, output, base, layouttranslations): - '''Generate pot file from lib/layouts/*.{layout,inc,module}''' + '''Generate pot file from lib/layouts/*.{layout,inc,module} and lib/citeengines/*.citeengine''' ClassDescription = re.compile(r'^\s*#\s*\\Declare(LaTeX|DocBook)Class.*\{(.*)\}$', re.IGNORECASE) ClassCategory = re.compile(r'^\s*#\s*\\DeclareCategory\{(.*)\}$', re.IGNORECASE) Style = re.compile(r'^\s*Style\s+(.*\S)\s*$', re.IGNORECASE) # match LabelString, EndLabelString, LabelStringAppendix and maybe others but no comments LabelString = re.compile(r'^[^#]*LabelString\S*\s+(.*\S)\s*$', re.IGNORECASE) MenuString = re.compile(r'^[^#]*MenuString\S*\s+(.*\S)\s*$', re.IGNORECASE) - OutlinerName = re.compile(r'^[^#]*OutlinerName\s+(\S+|\"[^\"]*\")\s+(\S+|\"[^\"]*\")\s*$', re.IGNORECASE) + OutlinerName = re.compile(r'^[^#]*OutlinerName\s+(\S+|\"[^\"]*\")\s+\"([^\"]*)\"', re.IGNORECASE) Tooltip = re.compile(r'^\s*Tooltip\S*\s+(.*\S)\s*$', re.IGNORECASE) GuiName = re.compile(r'^\s*GuiName\s+(.*\S)\s*$', re.IGNORECASE) ListName = re.compile(r'^\s*ListName\s+(.*\S)\s*$', re.IGNORECASE) CategoryName = re.compile(r'^\s*Category\s+(.*\S)\s*$', re.IGNORECASE) NameRE = re.compile(r'^\s*#\s*\\DeclareLyXModule.*{(.*)}$', re.IGNORECASE) + CiteNameRE = re.compile(r'^\s*#\s*\\DeclareLyXCiteEngine.*\{(.*)\}$', re.IGNORECASE) InsetLayout = re.compile(r'^InsetLayout\s+\"?(.*)\"?\s*$', re.IGNORECASE) FlexCheck = re.compile(r'^Flex:(.*)', re.IGNORECASE) CaptionCheck = re.compile(r'^Caption:(.*)', re.IGNORECASE) - DescBegin = re.compile(r'^\s*#DescriptionBegin\s*$', re.IGNORECASE) + DescBegin = re.compile(r'^\s*#\s*DescriptionBegin\s*$', re.IGNORECASE) DescEnd = re.compile(r'^\s*#\s*DescriptionEnd\s*$', re.IGNORECASE) Category = re.compile(r'^\s*#\s*Category:\s+(.*\S)\s*$', re.IGNORECASE) I18nPreamble = re.compile(r'^\s*((Lang)|(Babel))Preamble\s*$', re.IGNORECASE) @@ -102,7 +106,8 @@ def layouts_l10n(input_files, output, base, layouttranslations): I18nString = re.compile(r'_\(([^\)]+)\)') CounterFormat = re.compile(r'^\s*PrettyFormat\s+"?(.*)"?\s*$', re.IGNORECASE) CiteFormat = re.compile(r'^\s*CiteFormat', re.IGNORECASE) - KeyVal = re.compile(r'^\s*_\w+\s+(.*\S)\s*$') + # Note: preceding and trailing space in the val below matters + KeyVal = re.compile(r'^\s*_\w+\s(.*\S)*$') Float = re.compile(r'^\s*Float\s*$', re.IGNORECASE) UsesFloatPkg = re.compile(r'^\s*UsesFloatPkg\s+(.*\S)\s*$', re.IGNORECASE) IsPredefined = re.compile(r'^\s*IsPredefined\s+(.*\S)\s*$', re.IGNORECASE) @@ -166,7 +171,10 @@ def layouts_l10n(input_files, output, base, layouttranslations): if 'wa' in languages: languages.remove('wa') - out = io.open(output, 'w', encoding='utf_8') + if layouttranslations: + out = io.open(output, 'w', encoding='utf_8') + else: + out = io.open(output, 'w', encoding='utf_8', newline='\n') for src in input_files: readingDescription = False readingI18nPreamble = False @@ -226,6 +234,12 @@ def layouts_l10n(input_files, output, base, layouttranslations): readingI18nPreamble = True continue res = NameRE.search(line) + if res != None: + string = res.group(1) + if not layouttranslations: + writeString(out, src, base, lineno + 1, string) + continue + res = CiteNameRE.search(line) if res != None: string = res.group(1) if not layouttranslations: @@ -433,7 +447,7 @@ def layouts_l10n(input_files, output, base, layouttranslations): def qt4_l10n(input_files, output, base): '''Generate pot file from src/frontends/qt4/ui/*.ui''' - output = io.open(output, 'w', encoding='utf_8') + output = io.open(output, 'w', encoding='utf_8', newline='\n') pat = re.compile(r'\s*(.*)') prop = re.compile(r'\s*