aboutsummaryrefslogtreecommitdiffstats
path: root/po/CMakeLists.txt
blob: 0be492c8d3842eaccecb1ded0bea91dcd6de88be (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
# Gettext support - mostly borrowed from the Licq project

file(STRINGS LINGUAS po_FILES)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS LINGUAS)

if (NOT GETTEXT_MSGMERGE_EXECUTABLE AND NOT GETTEXT_MSGFMT_EXECUTABLE)
  message(FATAL_ERROR "Gettext message catalog tools NOT found")
endif (NOT GETTEXT_MSGMERGE_EXECUTABLE AND NOT GETTEXT_MSGFMT_EXECUTABLE)

find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
if (GETTEXT_XGETTEXT_EXECUTABLE)
  # Get list of all source files
  file(GLOB_RECURSE po_source
    RELATIVE ${PROJECT_SOURCE_DIR}
    ${PROJECT_SOURCE_DIR}/vncviewer/*.h
    ${PROJECT_SOURCE_DIR}/vncviewer/*.cxx
    ${PROJECT_SOURCE_DIR}/vncviewer/*.desktop.in.in
    ${PROJECT_SOURCE_DIR}/vncviewer/*.metainfo.xml.in
  )

  add_custom_target(translations_update
    ${GETTEXT_XGETTEXT_EXECUTABLE}
      "--directory=${PROJECT_SOURCE_DIR}"
      "--output=${CMAKE_CURRENT_SOURCE_DIR}/tigervnc.pot"
      --default-domain=tigervnc
      --keyword=_
      --keyword=p_:1c,2
      --keyword=N_
      "--copyright-holder=TigerVNC Team and many others \(see README.rst\)"
      --msgid-bugs-address=tigervnc-devel@googlegroups.com
      --sort-by-file
      --add-location
      --add-comments=TRANSLATORS
      ${po_source}
    COMMENT "Updating tigervnc.pot"
    VERBATIM
  )
endif (GETTEXT_XGETTEXT_EXECUTABLE)

foreach(lang ${po_FILES})
  set(po  "${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po")
  set(mo "${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo")

  # Add command to build X.mo from X.po
  add_custom_command(OUTPUT ${mo}
    COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check --check-accelerators -o ${mo} ${po}
    DEPENDS ${po}
  )

  install(FILES ${mo}
    DESTINATION "${CMAKE_INSTALL_FULL_LOCALEDIR}/${lang}/LC_MESSAGES"
    RENAME tigervnc.mo
  )

  set(moFiles ${moFiles} ${mo})
endforeach(lang)

add_custom_target(translations ALL DEPENDS ${moFiles})