]> git.lyx.org Git - features.git/commitdiff
Simplify .po file generation
authorGeorg Baum <baum@lyx.org>
Tue, 10 May 2016 05:03:54 +0000 (07:03 +0200)
committerRichard Heck <rgheck@lyx.org>
Sun, 29 May 2016 21:55:44 +0000 (17:55 -0400)
We can generate the file with the cirrect line endings directly instead of
calling a helper script to convert them.

development/Makefile.am
development/cmake/po/cat.py
development/cmake/po/dos2unix.py [deleted file]
po/CMakeLists.txt

index 43ca80821ed935aced12626c47cd70e06aca499c..796e964d4a84f4a646537a00cbf7d8c64cb78a44 100644 (file)
@@ -159,7 +159,6 @@ cmake/modules/PCHSupport_26.cmake \
 cmake/modules/ProjectSourceGroup.cmake \
 cmake/pcheaders.h \
 cmake/po/cat.py \
-cmake/po/dos2unix.py \
 cmake/po/unix2dos.py \
 cmake/post_install/CMakeLists.txt \
 cmake/scripts/LyXCreateImagesResource.cmake \
index 02655dc5646585efce0af3165890cb1fd4bd3244..7a1ee2699b585064522acaeba7198083c9b74d90 100644 (file)
@@ -25,11 +25,17 @@ for (opt, param) in options:
 
 out = sys.stdout
 if outfile:
-       out = open(outfile, "w")
+       # always write unix line endings, even on windows
+       out = open(outfile, "wb")
 
 for f in args:
-       fil = open(f, "r")
+       # accept both windows and unix line endings, since it can happen that we
+       # are on unix, but the file has been written on windows or vice versa.
+       fil = open(f, "rU")
        for l in fil:
+               # this does always write unix line endings since the file has
+               # been opened in binary mode. This is needed since both gettext
+               # and our .pot file manipulation scripts assume unix line ends.
                out.write(l)
        fil.close()
 
diff --git a/development/cmake/po/dos2unix.py b/development/cmake/po/dos2unix.py
deleted file mode 100644 (file)
index a5b6431..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#! /usr/bin/env python
-
-###############
-import sys
-
-for fname in sys.argv[1:]:
-    infile = open( fname, "r" )
-    instr = infile.read()
-    infile.close()
-    outstr = instr.replace( "\r\n", "\n" ).replace( "\r", "\n" )
-
-    if outstr == instr:
-        continue
-    
-    outfile = open( fname , "w" )
-    outfile.write( outstr )
-    outfile.close()
index 4d70d24042cd6ca141a91b222f6a509adf4ee6ae..3f2f9ad7e781f7713750b3cb4f640fb8934df89e 100755 (executable)
@@ -90,8 +90,6 @@ ADD_CUSTOM_COMMAND(
     OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
     COMMAND ${LYX_PYTHON_EXECUTABLE}
     ARGS   "${TOP_CMAKE_PATH}/po/cat.py" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat_tmp.pot"
-    COMMAND ${LYX_PYTHON_EXECUTABLE}
-      ARGS   "${TOP_CMAKE_PATH}/po/dos2unix.py" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat_tmp.pot"
     COMMAND ${CMAKE_COMMAND} -E copy_if_different
       "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat_tmp.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
     DEPENDS ${_py_sources}