2021-04-17 07:08:31 +02:00
|
|
|
cmake_minimum_required(VERSION 3.0.0)
|
2010-06-09 00:39:31 +02:00
|
|
|
|
2014-02-07 17:20:59 +01:00
|
|
|
set (XGETTEXT_OPTIONS --qt --keyword=tr:1,2c --keyword=tr --flag=tr:1:pass-c-format --flag=tr:1:pass-qt-format
|
2010-06-09 00:39:31 +02:00
|
|
|
--keyword=trUtf8 --flag=tr:1:pass-c-format --flag=tr:1:pass-qt-format
|
2014-02-08 15:08:37 +01:00
|
|
|
--keyword=translate:2,3c --keyword=translate:2 --flag=translate:2:pass-c-format --flag=translate:2:pass-qt-format
|
2010-06-09 00:39:31 +02:00
|
|
|
--keyword=QT_TR_NOOP --flag=QT_TR_NOOP:1:pass-c-format --flag=QT_TR_NOOP:1:pass-qt-format
|
|
|
|
--keyword=QT_TRANSLATE_NOOP:2 --flag=QT_TRANSLATE_NOOP:2:pass-c-format --flag=QT_TRANSLATE_NOOP:2:pass-qt-format
|
|
|
|
--keyword=_ --flag=_:1:pass-c-format --flag=_:1:pass-qt-format
|
|
|
|
--keyword=N_ --flag=N_:1:pass-c-format --flag=N_:1:pass-qt-format
|
|
|
|
--from-code=utf-8)
|
|
|
|
|
2011-11-01 19:56:56 +01:00
|
|
|
macro(add_pot outfiles header pot)
|
2011-11-03 00:55:03 +01:00
|
|
|
# Make relative filenames for all source files
|
|
|
|
set(add_pot_sources)
|
|
|
|
foreach(_filename ${ARGN})
|
|
|
|
get_filename_component(_absolute_filename ${_filename} ABSOLUTE)
|
|
|
|
file(RELATIVE_PATH _relative_filename ${CMAKE_CURRENT_SOURCE_DIR} ${_absolute_filename})
|
|
|
|
list(APPEND add_pot_sources ${_relative_filename})
|
|
|
|
endforeach(_filename)
|
|
|
|
|
2010-06-09 00:39:31 +02:00
|
|
|
# Generate the .pot
|
2011-02-03 23:01:31 +01:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${pot}
|
2011-11-03 00:55:03 +01:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
2010-06-09 00:39:31 +02:00
|
|
|
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
|
2011-11-01 19:14:22 +01:00
|
|
|
${XGETTEXT_OPTIONS} -s -C --omit-header
|
2010-06-09 00:39:31 +02:00
|
|
|
--output=${CMAKE_CURRENT_BINARY_DIR}/pot.temp
|
2011-11-03 00:55:03 +01:00
|
|
|
${add_pot_sources}
|
2010-06-09 00:39:31 +02:00
|
|
|
COMMAND cat ${header} ${CMAKE_CURRENT_BINARY_DIR}/pot.temp > ${pot}
|
2011-11-03 00:55:03 +01:00
|
|
|
DEPENDS ${add_pot_sources} ${header}
|
2010-06-09 00:39:31 +02:00
|
|
|
)
|
2011-11-01 19:56:56 +01:00
|
|
|
|
|
|
|
list(APPEND ${outfiles} ${pot})
|
2010-06-09 00:39:31 +02:00
|
|
|
endmacro(add_pot)
|
|
|
|
|
|
|
|
# Syntax is:
|
|
|
|
# add_po(sources_var po_prefix
|
|
|
|
# LANGUAGES language1 language2 ...
|
|
|
|
# DIRECTORY dir
|
|
|
|
#
|
|
|
|
macro(add_po outfiles po_prefix)
|
|
|
|
parse_arguments(ADD_PO
|
2011-11-01 19:56:56 +01:00
|
|
|
"LANGUAGES;DIRECTORY"
|
2010-06-09 00:39:31 +02:00
|
|
|
""
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
|
|
|
foreach (_lang ${ADD_PO_LANGUAGES})
|
|
|
|
set(_po_filename "${_lang}.po")
|
|
|
|
set(_po_filepath "${CMAKE_CURRENT_SOURCE_DIR}/${ADD_PO_DIRECTORY}/${_po_filename}")
|
|
|
|
set(_qm_filename "clementine_${_lang}.qm")
|
|
|
|
set(_qm_filepath "${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/${_qm_filename}")
|
|
|
|
|
2011-02-03 23:01:31 +01:00
|
|
|
# Convert the .po files to .qm files
|
2010-06-09 00:39:31 +02:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${_qm_filepath}
|
|
|
|
COMMAND ${QT_LCONVERT_EXECUTABLE} ARGS ${_po_filepath} -o ${_qm_filepath} -of qm
|
2011-11-01 19:56:56 +01:00
|
|
|
DEPENDS ${_po_filepath} ${_po_filepath}
|
2010-06-09 00:39:31 +02:00
|
|
|
)
|
2011-02-03 23:01:31 +01:00
|
|
|
|
2011-11-01 19:56:56 +01:00
|
|
|
list(APPEND ${outfiles} ${_qm_filepath})
|
2010-06-09 00:39:31 +02:00
|
|
|
endforeach (_lang)
|
|
|
|
|
|
|
|
# Generate a qrc file for the translations
|
|
|
|
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc)
|
|
|
|
file(WRITE ${_qrc} "<RCC><qresource prefix=\"/${ADD_PO_DIRECTORY}\">")
|
|
|
|
foreach(_lang ${ADD_PO_LANGUAGES})
|
|
|
|
file(APPEND ${_qrc} "<file>${po_prefix}${_lang}.qm</file>")
|
|
|
|
endforeach(_lang)
|
|
|
|
file(APPEND ${_qrc} "</qresource></RCC>")
|
2015-04-11 22:49:34 +02:00
|
|
|
qt5_add_resources(${outfiles} ${_qrc})
|
2010-06-09 00:39:31 +02:00
|
|
|
endmacro(add_po)
|