summaryrefslogtreecommitdiff
path: root/po/CMakeLists.txt
blob: ffa968beae674a30ef1109513441c12f6ce82004 (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
61
62
63
64
65
66
# libhangul
# Copyright 2021 Choe Hwanjin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

cmake_minimum_required(VERSION 3.0)

find_package(Gettext)
include(GNUInstallDirs)

file(READ LINGUAS LINGUAS)
string(REPLACE "\n" ";" LINGUAS "${LINGUAS}")

foreach(lang ${LINGUAS})
    GETTEXT_PROCESS_PO_FILES(${lang} ALL
        INSTALL_DESTINATION "${CMAKE_INSTALL_LOCALEDIR}"
        PO_FILES ${lang}.po
    )
endforeach()

find_program(XGETTEXT_EXECUTABLE xgettext)
set(PACKAGE_NAME libhangul)
set(DOMAIN libhangul)
set(COPYRIGHT_HOLDER "Choe Hwanjin")
set(MSGID_BUGS_ADDRESS "https://github.com/libhangul/libhangul")

add_custom_target(update-po)

add_custom_target(update-pot
    COMMAND
        ${XGETTEXT_EXECUTABLE}
            --default-domain=${DOMAIN}
            --directory="${CMAKE_SOURCE_DIR}"
            --add-comments=TRANSLATORS:
            --keyword=_
            --keyword=N_
            --files-from="${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in"
            --copyright-holder="${COPYRIGHT_HOLDER}"
            --package-name="${PACKAGE_NAME}"
            --package-version="${PACKAGE_VERSION}"
            --msgid-bugs-address="${MSGID_BUGS_ADDRESS}"
            --output-dir="${CMAKE_CURRENT_SOURCE_DIR}"
            --output=${DOMAIN}.pot
)
add_dependencies(update-po update-pot)

foreach(lang ${LINGUAS})
    add_custom_target(update-po-${lang}
        COMMAND "${GETTEXT_MSGMERGE_EXECUTABLE}" --update --lang=${lang} ${lang}.po ${DOMAIN}.pot
        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
        DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${DOMAIN}.pot"
    )
    add_dependencies(update-po update-po-${lang})
endforeach()