Skip to content

Commit

Permalink
fix enum translation; refactor .mo installation (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Jan 9, 2025
1 parent b2c7d39 commit 1696a50
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 144 deletions.
39 changes: 1 addition & 38 deletions assets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,41 +71,4 @@ foreach(LOCALE
)
endforeach()

#
# C++ i18n through gettext
# Use 'pot' to generate the POT file.
#
set(TRANSLATABLE_CXX_SOURCES
src/*.cpp
src/*.h
macosfrontend/*.cpp
macosfrontend/*.h
macosnotifications/*.cpp
macosnotifications/*.h
webpanel/*.cpp
webpanel/*.h
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/po/base.pot
COMMAND xgettext --c++ --keyword=_ ${TRANSLATABLE_CXX_SOURCES} -o ${CMAKE_CURRENT_SOURCE_DIR}/po/base.pot
DEPENDS ${LOCALIZABLE_CXX_SOURCES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating base.pot..."
)
add_custom_target(pot
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/po/base.pot
)

foreach(LOCALE zh_CN)
set(MO_FILE ${CMAKE_CURRENT_BINARY_DIR}/po/${LOCALE}.mo)
add_custom_command(
OUTPUT ${MO_FILE}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/po/${LOCALE}.po
COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/po/${LOCALE}.po -o ${MO_FILE}
)
add_custom_target(${LOCALE}_mo ALL DEPENDS ${MO_FILE})
install(FILES ${MO_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/locale/${LOCALE}/LC_MESSAGES
RENAME fcitx5-macos.mo
)
endforeach()
add_subdirectory(po)
25 changes: 25 additions & 0 deletions assets/po/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# C++ i18n through gettext
# Use 'pot' to generate the POT file.
#
set(TRANSLATABLE_CXX_SOURCES
macosfrontend/macosfrontend.h
macosnotifications/macosnotifications.h
webpanel/webpanel.h
)

list(TRANSFORM TRANSLATABLE_CXX_SOURCES PREPEND "${PROJECT_SOURCE_DIR}/" OUTPUT_VARIABLE TRANSLATABLE_CXX_SOURCES_FULL_PATH)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/base.pot
COMMAND xgettext --c++ --keyword=_ --keyword=N_ ${TRANSLATABLE_CXX_SOURCES} -o ${CMAKE_CURRENT_SOURCE_DIR}/base.pot
DEPENDS ${TRANSLATABLE_CXX_SOURCES_FULL_PATH}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generating base.pot..."
)
add_custom_target(pot
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/base.pot
)

set(FCITX_INSTALL_LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale")
fcitx5_install_translation(fcitx5-macos)
Loading

0 comments on commit 1696a50

Please sign in to comment.