summaryrefslogtreecommitdiff
path: root/navit/po/CMakeLists.txt
blob: a0f66b32ca5f5e3406fa970db5f02481b19846d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
FIND_PROGRAM(XGETTEXT xgettext)

set(POTFILES
      ${PROJECT_SOURCE_DIR}/navit/main.c
      ${PROJECT_SOURCE_DIR}/navit/navigation.c
      ${PROJECT_SOURCE_DIR}/navit/navit.c
      ${PROJECT_SOURCE_DIR}/navit/popup.c
      ${PROJECT_SOURCE_DIR}/navit/country.c
      ${PROJECT_SOURCE_DIR}/navit/gui/gtk/destination.c
      ${PROJECT_SOURCE_DIR}/navit/gui/gtk/gui_gtk_action.c
      ${PROJECT_SOURCE_DIR}/navit/gui/gtk/gui_gtk_statusbar.c
      ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal.c
      ${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
      ${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.glade
)     

ADD_CUSTOM_COMMAND(
   OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
   DEPENDS ${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml
   COMMAND ${CMAKE_COMMAND} -D SRC=${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml -D DST=${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
                     -P ${PROJECT_SOURCE_DIR}/cmake/navit_xml_parser.cmake
)

ADD_CUSTOM_COMMAND(
   OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.glade
   DEPENDS ${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml
   COMMAND ${CMAKE_COMMAND} -D SRC=${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml -D DST=${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.glade
                     -P ${PROJECT_SOURCE_DIR}/cmake/navit_xml_parser_glade.cmake
)

ADD_CUSTOM_COMMAND(
   OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/navit.po
   DEPENDS ${POTFILES}
   COMMAND ${XGETTEXT} --no-location --default-domain=navit --add-comments --keyword=_ --keyword=_n ${POTFILES}
)

FILE(GLOB POIN_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.po.in")

string(REPLACE ".po.in" "" LANGUAGES "${POIN_FILES}")

foreach (LANG ${LANGUAGES})
   ADD_CUSTOM_COMMAND(
      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/navit.po
      COMMAND sed 's/^\"Project-Id-Version:.*/\"Project-Id-Version: ${PACKAGE_STRING}\\\\n\"/' <  "${CMAKE_CURRENT_SOURCE_DIR}/${LANG}.po.in" | ${GETTEXT_MSGMERGE_EXECUTABLE} --no-fuzzy-matching --verbose -o "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po" - ${CMAKE_CURRENT_BINARY_DIR}/navit.po
   )
endforeach(LANG ${LANGUAGES})

foreach (LANG ${LANGUAGES})
   ADD_CUSTOM_COMMAND(
      OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po
      COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check --verbose --statistics --output-file="${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo" "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po" 
      COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/locale/${LANG}/LC_MESSAGES" 
      COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo" "${PROJECT_BINARY_DIR}/locale/${LANG}/LC_MESSAGES/navit.mo"
   )
   SET(MOFILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo ${MOFILES})
endforeach(LANG ${LANGUAGES})

add_custom_target(locales ALL DEPENDS  ${MOFILES})