diff --git a/Messages.sh b/Messages.sh index 878703fb6..44108339f 100755 --- a/Messages.sh +++ b/Messages.sh @@ -11,6 +11,6 @@ echo > po/LINGUAS for pofile in $(ls po/*.po | sort); do pofilebase=$(basename $pofile) pofilebase=${pofilebase/.po/} - msgmerge -U $pofile ${POT_FILE} + msgmerge -U --backup=none $pofile ${POT_FILE} echo $pofilebase >> po/LINGUAS done diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 3eb768439..b379b64f4 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -1,2 +1 @@ -file(GLOB PO_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.po) -gettext_create_translations(fcitx5.pot ALL ${PO_FILES}) +fcitx5_install_translation(fcitx5) diff --git a/po/fcitx.pot b/po/fcitx.pot deleted file mode 100644 index f26a63fe8..000000000 --- a/po/fcitx.pot +++ /dev/null @@ -1,90 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-09-14 19:48-0700\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: src/modules/unicode/charselectdata.cpp:214 -msgid "" -msgstr "" - -#: src/modules/unicode/charselectdata.cpp:210 -msgid "" -msgstr "" - -#: src/modules/unicode/charselectdata.cpp:212 -msgid "" -msgstr "" - -#: src/modules/unicode/charselectdata.cpp:216 -msgid "" -msgstr "" - -#: src/modules/unicode/charselectdata.cpp:246 -msgid "" -msgstr "" - -#: src/modules/clipboard/clipboard.cpp:290 -msgid "Clipboard:" -msgstr "" - -#: src/lib/fcitx/inputmethodmanager.cpp:186 -msgid "Default" -msgstr "" - -#: src/modules/notifications/notifications.cpp:231 -msgid "Do not show again" -msgstr "" - -#: src/im/keyboard/keyboard.cpp:153 src/im/keyboard/keyboard.cpp:167 -msgid "Keyboard" -msgstr "" - -#: src/modules/clipboard/clipboard.cpp:292 -msgid "No clipboard history." -msgstr "" - -#: src/modules/quickphrase/quickphrase.cpp:283 -msgid "Quick Phrase: " -msgstr "" - -#: src/im/keyboard/keyboard.cpp:264 -msgid "Spell hint" -msgstr "" - -#: src/im/keyboard/keyboard.cpp:266 -msgid "Spell hint is disabled." -msgstr "" - -#: src/im/keyboard/keyboard.cpp:265 -msgid "Spell hint is enabled." -msgstr "" - -#: src/modules/unicode/unicode.cpp:244 -msgid "Unicode: " -msgstr "" - -#: src/modules/unicode/unicode.conf.in:3 -msgid "unicode" -msgstr "" - -#: src/modules/unicode/unicode.conf.in:4 -msgid "Fcitx Unicode Typing Support" -msgstr "" - -#: src/modules/unicode/unicode.conf.in:5 -msgid "Add Unicode Typing Support" -msgstr "" diff --git a/src/lib/fcitx-utils/Fcitx5Macros.cmake b/src/lib/fcitx-utils/Fcitx5Macros.cmake index 38123a64c..376f8d9f9 100644 --- a/src/lib/fcitx-utils/Fcitx5Macros.cmake +++ b/src/lib/fcitx-utils/Fcitx5Macros.cmake @@ -121,3 +121,26 @@ function(fcitx5_translate_desktop_file SRC DEST) DEPENDS "${SRC}") add_custom_target("${SRC_BASE}-fmt" ALL DEPENDS "${DEST}") endfunction() + +# Gettext function are not good for our use case. +# GETTEXT_CREATE_TRANSLATIONS will call msgmerge which may update po file +function(fcitx5_install_translation domain) + file(GLOB PO_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.po) + set(MO_FILES) + foreach(PO_FILE IN LISTS PO_FILES) + get_filename_component(PO_LANG ${PO_FILE} NAME_WE) + get_filename_component(ABS_PO_FILE ${PO_FILE} ABSOLUTE) + set(MO_FILE ${CMAKE_CURRENT_BINARY_DIR}/${domain}-${PO_LANG}.mo) + + add_custom_command( + OUTPUT ${MO_FILE} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${MO_FILE} ${ABS_PO_FILE} + DEPENDS ${ABS_PO_FILE} + ) + + install(FILES ${MO_FILE} RENAME ${domain}.mo DESTINATION share/locale/${PO_LANG}/LC_MESSAGES) + set(MO_FILES ${MO_FILES} ${MO_FILE}) + endforeach () + add_custom_target("${domain}-translation" ALL DEPENDS ${MO_FILES}) + +endfunction()