-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathI18N.cmake
124 lines (112 loc) · 5.21 KB
/
I18N.cmake
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
############################################################################
# Copyright 2007-2022 Universidade do Porto - Faculdade de Engenharia #
# Laboratório de Sistemas e Tecnologia Subaquática (LSTS) #
############################################################################
# This file is part of DUNE: Unified Navigation Environment. #
# #
# Commercial Licence Usage #
# Licencees holding valid commercial DUNE licences may use this file in #
# accordance with the commercial licence agreement provided with the #
# Software or, alternatively, in accordance with the terms contained in a #
# written agreement between you and Faculdade de Engenharia da #
# Universidade do Porto. For licensing terms, conditions, and further #
# information contact [email protected]. #
# #
# Modified European Union Public Licence - EUPL v.1.1 Usage #
# Alternatively, this file may be used under the terms of the Modified #
# EUPL, Version 1.1 only (the "Licence"), appearing in the file LICENCE.md #
# included in the packaging of this file. You may not use this work #
# except in compliance with the Licence. Unless required by applicable #
# law or agreed to in writing, software distributed under the Licence is #
# distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF #
# ANY KIND, either express or implied. See the Licence for the specific #
# language governing permissions and limitations at #
# https://github.com/LSTS/dune/blob/master/LICENCE.md and #
# http://ec.europa.eu/idabc/eupl.html. #
############################################################################
# Author: Ricardo Martins #
############################################################################
function(dune_i18n_get_name file name)
get_filename_component(locale_name "${file}" PATH)
get_filename_component(locale_name "${locale_name}/.." ABSOLUTE)
get_filename_component(locale_name "${locale_name}" NAME)
set(${name} ${locale_name} PARENT_SCOPE)
endfunction(dune_i18n_get_name file)
if(DUNE_PROGRAM_MSGMERGE OR DUNE_PROGRAM_MSGFMT)
file(GLOB_RECURSE locales "${PROJECT_SOURCE_DIR}/i18n/*.po")
endif(DUNE_PROGRAM_MSGMERGE OR DUNE_PROGRAM_MSGFMT)
# Extract entity labels from configuration files.
if(DUNE_PROGRAM_PYTHON)
add_custom_target(i18n_texts
COMMAND
${DUNE_PROGRAM_PYTHON}
${PROJECT_SOURCE_DIR}/programs/scripts/dune-extract-elabels.py
${PROJECT_SOURCE_DIR}/etc ${PROJECT_SOURCE_DIR}/i18n/entity_labels.txt)
else(DUNE_PROGRAM_PYTHON)
add_custom_target(i18n_texts)
endif(DUNE_PROGRAM_PYTHON)
# Extract.
if(DUNE_PROGRAM_XGETTEXT)
file(GLOB_RECURSE headers "${PROJECT_SOURCE_DIR}/src/*.hpp")
file(GLOB_RECURSE sources "${PROJECT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE private_headers "${PROJECT_SOURCE_DIR}/private/src/*.hpp")
file(GLOB_RECURSE private_sources "${PROJECT_SOURCE_DIR}/private/src/*.cpp")
file(GLOB_RECURSE user_headers "${PROJECT_SOURCE_DIR}/user/src/*.hpp")
file(GLOB_RECURSE user_sources "${PROJECT_SOURCE_DIR}/user/src/*.cpp")
file(GLOB_RECURSE texts "${PROJECT_SOURCE_DIR}/i18n/*.txt")
add_custom_target(i18n_extract
${XGETTEXT_EXE}
--package-name=${PROJECT_SHORT_NAME}
--package-version=${PROJECT_VERSION}
--copyright-holder=${PROJECT_VENDOR}
--foreign-user
--language=C++
--from-code=UTF-8
--keyword=DTR
--keyword=DTR_RT
--no-wrap
-o dune.pot ${headers} ${sources} ${private_headers} ${private_sources} ${user_headers} ${user_sources} ${texts}
DEPENDS i18n_texts
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/i18n)
endif(DUNE_PROGRAM_XGETTEXT)
# Merge.
if(DUNE_PROGRAM_MSGMERGE)
add_custom_target(i18n_update)
foreach(locale ${locales})
dune_i18n_get_name(${locale} locale_name)
add_custom_target(i18n_update_${locale_name}
${MSGMERGE_EXE}
--quiet
--no-wrap
--update
--backup=off
--lang=${locale_name}
${locale} dune.pot
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/i18n)
add_dependencies(i18n_update i18n_update_${locale_name})
endforeach(locale ${locales})
endif(DUNE_PROGRAM_MSGMERGE)
# Compile.
if(DUNE_PROGRAM_MSGFMT)
add_custom_target(i18n_compile ALL)
foreach(locale ${locales})
dune_i18n_get_name(${locale} locale_name)
set(mo_folder "${DUNE_GENERATED}/i18n/${locale_name}/LC_MESSAGES")
file(MAKE_DIRECTORY ${mo_folder})
add_custom_target(i18n_compile_${locale_name}
${MSGFMT_EXE}
--verbose
--check
--statistics
${locale}
-o ${mo_folder}/dune.mo
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/i18n)
add_dependencies(i18n_compile i18n_compile_${locale_name})
endforeach(locale ${locales})
# Install.
install(DIRECTORY ${DUNE_GENERATED}/i18n DESTINATION .
PATTERN .svn EXCLUDE
PATTERN *.pot EXCLUDE
PATTERN *.po EXCLUDE)
endif(DUNE_PROGRAM_MSGFMT)