On 04/07/2016 05:21 PM, Pavel Sanda wrote: > Richard Heck wrote: >> I think the problem may not be that gettext works differently but, >> perhaps, that it works the same. I am guessing that what happens is this. >> First, lyx_pot.py writes the po files with native line endings. > Yep, that might explain the original problem, why line wrapping is different: > +1/2 \r characters would make the line of different length causing different > break of the lines seen in diffs.
Then maybe the solution is to disable the writing of native line endings. Apparently, we can do this by opening the output files in binary mode. The attached patch does this. Can someone test? Richard
>From d14232cd816070295fd177a789041090b9b21e3d Mon Sep 17 00:00:00 2001 From: Richard Heck <rgh...@lyx.org> Date: Thu, 7 Apr 2016 17:34:23 -0400 Subject: [PATCH] Open output pot files in binary mode, so that line endings are always written explicitly as "\n". --- po/lyx_pot.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/po/lyx_pot.py b/po/lyx_pot.py index 500185f..f1f16f7 100755 --- a/po/lyx_pot.py +++ b/po/lyx_pot.py @@ -44,7 +44,7 @@ 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, 'wb', encoding='utf_8') Submenu = re.compile(r'^[^#]*Submenu\s+"([^"]*)"', re.IGNORECASE) Popupmenu = re.compile(r'^[^#]*PopupMenu\s+"[^"]+"\s+"([^"]*)"', re.IGNORECASE) IconPalette = re.compile(r'^[^#]*IconPalette\s+"[^"]+"\s+"([^"]*)"', re.IGNORECASE) @@ -166,7 +166,7 @@ def layouts_l10n(input_files, output, base, layouttranslations): if 'wa' in languages: languages.remove('wa') - out = io.open(output, 'w', encoding='utf_8') + out = io.open(output, 'wb', encoding='utf_8') for src in input_files: readingDescription = False readingI18nPreamble = False @@ -433,7 +433,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, 'wb', encoding='utf_8') pat = re.compile(r'\s*<string>(.*)</string>') prop = re.compile(r'\s*<property.*name.*=.*shortcut') for src in input_files: @@ -462,7 +462,7 @@ def qt4_l10n(input_files, output, base): def languages_l10n(input_files, output, base): '''Generate pot file from lib/languages''' - out = io.open(output, 'w', encoding='utf_8') + out = io.open(output, 'wb', encoding='utf_8') GuiName = re.compile(r'^[^#]*GuiName\s+(.*)', re.IGNORECASE) for src in input_files: @@ -482,7 +482,7 @@ def languages_l10n(input_files, output, base): def latexfonts_l10n(input_files, output, base): '''Generate pot file from lib/latexfonts''' - out = io.open(output, 'w', encoding='utf_8') + out = io.open(output, 'wb', encoding='utf_8') GuiName = re.compile(r'^[^#]*GuiName\s+(.*)', re.IGNORECASE) for src in input_files: @@ -502,7 +502,7 @@ def latexfonts_l10n(input_files, output, base): def external_l10n(input_files, output, base): '''Generate pot file from lib/external_templates''' - output = io.open(output, 'w', encoding='utf_8') + output = io.open(output, 'wb', encoding='utf_8') Template = re.compile(r'^Template\s+(.*)', re.IGNORECASE) GuiName = re.compile(r'\s*GuiName\s+(.*)', re.IGNORECASE) HelpTextStart = re.compile(r'\s*HelpText\s', re.IGNORECASE) @@ -551,7 +551,7 @@ def external_l10n(input_files, output, base): def formats_l10n(input_files, output, base): '''Generate pot file from configure.py''' - output = io.open(output, 'w', encoding='utf_8') + output = io.open(output, 'wb', encoding='utf_8') GuiName = re.compile(r'.*\\Format\s+\S+\s+\S+\s+"([^"]*)"\s+(\S*)\s+.*', re.IGNORECASE) GuiName2 = re.compile(r'.*\\Format\s+\S+\s+\S+\s+([^"]\S+)\s+(\S*)\s+.*', re.IGNORECASE) input = io.open(input_files[0], encoding='utf_8') @@ -581,7 +581,7 @@ def formats_l10n(input_files, output, base): def encodings_l10n(input_files, output, base): '''Generate pot file from lib/encodings''' - output = io.open(output, 'w', encoding='utf_8') + output = io.open(output, 'wb', encoding='utf_8') # assuming only one encodings file # Encoding utf8 utf8 "Unicode (utf8)" UTF-8 variable inputenc reg = re.compile('Encoding [\w-]+\s+[\w-]+\s+"([\w \-\(\)]+)"\s+[\w-]+\s+(fixed|variable|variableunsafe)\s+\w+.*') -- 2.1.0