aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJohn Szakmeister <john@szakmeister.net>2014-07-09 06:12:28 -0400
committerJohn Szakmeister <john@szakmeister.net>2014-07-17 05:47:32 -0400
commit67533e09489d6d1bc689d4816776307988471efd (patch)
treeb6d87c943fb17f46cf9d27147c1166dbe99d66f1 /cmake
parenta3b3db8256c259d10957d45666cf4179e328f3f4 (diff)
downloadrneovim-67533e09489d6d1bc689d4816776307988471efd.tar.gz
rneovim-67533e09489d6d1bc689d4816776307988471efd.tar.bz2
rneovim-67533e09489d6d1bc689d4816776307988471efd.zip
Move po generation from Make to CMake.
Fixes #902: localization build: `install`, `uninstall`, `prefixcheck targets. All the language-related bits will now build under CMake. Changes include: * Moving all non-generated sources into the NEOVIM_SOURCES variable to aid in generating the .pot file. * Moving a couple generated sources from NEOVIM_SOURCES and into NEOVIM_GENERATED_SOURCES. * Added NEOVIM_HEADERS to the executable and the library for folks who are using something other than Ninja or makefiles (that way the headers will show up in the IDE files). * Now uses gettext's `--update` switch to update the .po files, rather than doing a fragile `mv` dance that could leave you with a broken working tree if you press CTRL-C at the right time. * Creates `update-po-${LANG}` targets for updating individual languages, just like the original Makefile. * Also adds the `update-po` target for updating all the languages. * Ported the `check-${LANG}` style targets. They're `check-po-${LANG}` under CMake. * Handles all the one-off instances that were in the original Makefile. Fixed up ko.UTF-8.po to include the "Original translation" line like other .po files to make the generation of the "Generate from ..." comments consistent. Updated ko.po with the new text.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/ConvertPo.cmake21
-rw-r--r--cmake/RunMsgfmt.cmake9
-rw-r--r--cmake/RunMsgmerge.cmake11
-rw-r--r--cmake/RunXgettext.cmake14
4 files changed, 55 insertions, 0 deletions
diff --git a/cmake/ConvertPo.cmake b/cmake/ConvertPo.cmake
new file mode 100644
index 0000000000..2282b96f56
--- /dev/null
+++ b/cmake/ConvertPo.cmake
@@ -0,0 +1,21 @@
+string(TOUPPER ${INPUT_ENC} upperInputEnc)
+string(TOLOWER ${INPUT_ENC} lowerInputEnc)
+get_filename_component(inputName ${INPUT_FILE} NAME)
+execute_process(
+ COMMAND ${ICONV_PRG} -f ${INPUT_ENC} -t ${OUTPUT_ENC} ${INPUT_FILE}
+ OUTPUT_VARIABLE trans
+ ERROR_VARIABLE err
+ RESULT_VARIABLE res)
+if(NOT res EQUAL 0)
+ message(FATAL_ERROR "iconv failed to run correctly: ${err}")
+endif()
+
+string(REPLACE "charset=${lowerInputEnc}" "charset=${OUTPUT_CHARSET}"
+ trans "${trans}")
+string(REPLACE "charset=${upperInputEnc}" "charset=${OUTPUT_CHARSET}"
+ trans "${trans}")
+string(REPLACE "# Original translations"
+ "# Generated from ${inputName}, DO NOT EDIT"
+ trans "${trans}")
+
+file(WRITE ${OUTPUT_FILE} "${trans}")
diff --git a/cmake/RunMsgfmt.cmake b/cmake/RunMsgfmt.cmake
new file mode 100644
index 0000000000..51606338e0
--- /dev/null
+++ b/cmake/RunMsgfmt.cmake
@@ -0,0 +1,9 @@
+set(ENV{OLD_PO_FILE_INPUT} yes)
+
+execute_process(
+ COMMAND ${MSGFMT_PRG} -o ${MO_FILE} ${PO_FILE}
+ ERROR_VARIABLE err
+ RESULT_VARIABLE res)
+if(NOT res EQUAL 0)
+ message(FATAL_ERROR "msgfmt failed to run correctly: ${err}")
+endif()
diff --git a/cmake/RunMsgmerge.cmake b/cmake/RunMsgmerge.cmake
new file mode 100644
index 0000000000..69e5c7276d
--- /dev/null
+++ b/cmake/RunMsgmerge.cmake
@@ -0,0 +1,11 @@
+set(ENV{OLD_PO_FILE_INPUT} yes)
+set(ENV{OLD_PO_FILE_OUTPUT} yes)
+
+execute_process(
+ COMMAND ${MSGMERGE_PRG} -q --update --backup=none --sort-by-file
+ ${PO_FILE} ${POT_FILE}
+ ERROR_VARIABLE err
+ RESULT_VARIABLE res)
+if(NOT res EQUAL 0)
+ message(FATAL_ERROR "msgmerge failed to run correctly: ${err}")
+endif()
diff --git a/cmake/RunXgettext.cmake b/cmake/RunXgettext.cmake
new file mode 100644
index 0000000000..c9328b151d
--- /dev/null
+++ b/cmake/RunXgettext.cmake
@@ -0,0 +1,14 @@
+set(ENV{OLD_PO_FILE_INPUT} yes)
+set(ENV{OLD_PO_FILE_OUTPUT} yes)
+
+list(SORT SOURCES)
+
+execute_process(
+ COMMAND ${XGETTEXT_PRG} -o ${POT_FILE} --default-domain=nvim
+ --add-comments --keyword=_ --keyword=N_ -D ${SEARCH_DIR}
+ ${SOURCES}
+ ERROR_VARIABLE err
+ RESULT_VARIABLE res)
+if(NOT res EQUAL 0)
+ message(FATAL_ERROR "xgettext failed to run correctly: ${err}")
+endif()