Skip to content

Commit

Permalink
don't update po file when build
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Sep 15, 2017
1 parent b8011ec commit 71e00da
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions po/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
90 changes: 0 additions & 90 deletions po/fcitx.pot

This file was deleted.

23 changes: 23 additions & 0 deletions src/lib/fcitx-utils/Fcitx5Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 71e00da

Please sign in to comment.