forked from qt-creator/qt-creator
CMake: Handle translations
(Optionally) re-generate .ts files from CMake by running lupdate and run lrelease to generate .qm files. Changes to qmake: * src/libs/3rdparty/syntax-highlighting/src/cli/kate-syntax-highlighter.cpp is no longer translated: It's a command line tool that is not used by creator * src/libs/aggregation/examples/text/main.cpp is no longer included in ts files * src/libs/qt-breakpad/qtcrashhandler/* is no longer included in ts files: It is not built right now Change-Id: Iec018da86a111a68ec983a880cef2961b48ccdf9 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -35,8 +35,8 @@ if (WITH_TESTS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Qt5
|
find_package(Qt5
|
||||||
COMPONENTS Concurrent Core Network PrintSupport Qml Quick QuickWidgets
|
COMPONENTS Concurrent Core LinguistTools Network PrintSupport Qml Quick
|
||||||
Sql Widgets ${_TEST_QT_COMPONENT}
|
QuickWidgets Sql Widgets ${_TEST_QT_COMPONENT}
|
||||||
REQUIRED
|
REQUIRED
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -94,6 +94,22 @@ set(__QTC_TESTS "" CACHE INTERNAL "*** Internal ***")
|
|||||||
# Internal functions
|
# Internal functions
|
||||||
#
|
#
|
||||||
|
|
||||||
|
function(append_extra_translations target_name)
|
||||||
|
if(NOT ARGN)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(TARGET "${target_name}")
|
||||||
|
get_target_property(_input "${target_name}" QT_EXTRA_TRANSLATIONS)
|
||||||
|
if (_input)
|
||||||
|
set(_output "${_input}" "${ARGN}")
|
||||||
|
else()
|
||||||
|
set(_output "${ARGN}")
|
||||||
|
endif()
|
||||||
|
set_target_properties("${target_name}" PROPERTIES QT_EXTRA_TRANSLATIONS "${_output}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
function(update_cached_list name value)
|
function(update_cached_list name value)
|
||||||
set(_tmp_list "${${name}}")
|
set(_tmp_list "${${name}}")
|
||||||
list(APPEND _tmp_list "${value}")
|
list(APPEND _tmp_list "${value}")
|
||||||
@@ -321,8 +337,8 @@ endfunction()
|
|||||||
#
|
#
|
||||||
|
|
||||||
function(add_qtc_library name)
|
function(add_qtc_library name)
|
||||||
cmake_parse_arguments(_arg "STATIC;OBJECT" ""
|
cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION" ""
|
||||||
"DEFINES;DEPENDS;INCLUDES;PUBLIC_DEFINES;PUBLIC_DEPENDS;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;PROPERTIES" ${ARGN}
|
"DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;PUBLIC_DEFINES;PUBLIC_DEPENDS;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;PROPERTIES" ${ARGN}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${_arg_UNPARSED_ARGUMENTS})
|
if (${_arg_UNPARSED_ARGUMENTS})
|
||||||
@@ -384,6 +400,11 @@ function(add_qtc_library name)
|
|||||||
set_property(SOURCE ${file} PROPERTY SKIP_AUTOMOC ON)
|
set_property(SOURCE ${file} PROPERTY SKIP_AUTOMOC ON)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
set(skip_translation OFF)
|
||||||
|
if (_arg_SKIP_TRANSLATION)
|
||||||
|
set(skip_translation ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
qtc_output_binary_dir(_output_binary_dir)
|
qtc_output_binary_dir(_output_binary_dir)
|
||||||
set_target_properties(${name} PROPERTIES
|
set_target_properties(${name} PROPERTIES
|
||||||
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
|
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
@@ -426,13 +447,15 @@ function(add_qtc_library name)
|
|||||||
COMPONENT Devel EXCLUDE_FROM_ALL
|
COMPONENT Devel EXCLUDE_FROM_ALL
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
append_extra_translations("${name}" "${_arg_EXTRA_TRANSLATIONS}")
|
||||||
endfunction(add_qtc_library)
|
endfunction(add_qtc_library)
|
||||||
|
|
||||||
function(add_qtc_plugin target_name)
|
function(add_qtc_plugin target_name)
|
||||||
cmake_parse_arguments(_arg
|
cmake_parse_arguments(_arg
|
||||||
"EXPERIMENTAL;SKIP_DEBUG_CMAKE_FILE_CHECK;SKIP_INSTALL;INTERNAL_ONLY"
|
"EXPERIMENTAL;SKIP_DEBUG_CMAKE_FILE_CHECK;SKIP_INSTALL;INTERNAL_ONLY;SKIP_TRANSLATION"
|
||||||
"VERSION;COMPAT_VERSION;PLUGIN_JSON_IN;PLUGIN_PATH;PLUGIN_NAME;OUTPUT_NAME"
|
"VERSION;COMPAT_VERSION;PLUGIN_JSON_IN;PLUGIN_PATH;PLUGIN_NAME;OUTPUT_NAME"
|
||||||
"CONDITION;DEPENDS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;PLUGIN_DEPENDS;PLUGIN_RECOMMENDS;SOURCES;EXPLICIT_MOC"
|
"CONDITION;DEPENDS;EXTRA_TRANSLATIONS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;PLUGIN_DEPENDS;PLUGIN_RECOMMENDS;SOURCES;EXPLICIT_MOC"
|
||||||
${ARGN}
|
${ARGN}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -585,6 +608,11 @@ function(add_qtc_plugin target_name)
|
|||||||
set(plugin_dir "${_arg_PLUGIN_PATH}")
|
set(plugin_dir "${_arg_PLUGIN_PATH}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(skip_translation OFF)
|
||||||
|
if (_arg_SKIP_TRANSLATION)
|
||||||
|
set(skip_translation ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
qtc_output_binary_dir(_output_binary_dir)
|
qtc_output_binary_dir(_output_binary_dir)
|
||||||
set_target_properties(${target_name} PROPERTIES
|
set_target_properties(${target_name} PROPERTIES
|
||||||
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
|
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
@@ -598,8 +626,10 @@ function(add_qtc_plugin target_name)
|
|||||||
ARCHIVE_OUTPUT_DIRECTORY "${_output_binary_dir}/${plugin_dir}"
|
ARCHIVE_OUTPUT_DIRECTORY "${_output_binary_dir}/${plugin_dir}"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${plugin_dir}"
|
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${plugin_dir}"
|
||||||
OUTPUT_NAME "${name}"
|
OUTPUT_NAME "${name}"
|
||||||
|
QT_SKIP_TRANSLATION "${skip_translation}"
|
||||||
${_arg_PROPERTIES}
|
${_arg_PROPERTIES}
|
||||||
)
|
)
|
||||||
|
append_extra_translations("${target_name}" "${_arg_EXTRA_TRANSLATIONS}")
|
||||||
enable_pch(${target_name})
|
enable_pch(${target_name})
|
||||||
|
|
||||||
foreach(file IN LISTS _arg_EXPLICIT_MOC)
|
foreach(file IN LISTS _arg_EXPLICIT_MOC)
|
||||||
@@ -693,7 +723,9 @@ function(extend_qtc_plugin target_name)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(add_qtc_executable name)
|
function(add_qtc_executable name)
|
||||||
cmake_parse_arguments(_arg "SKIP_INSTALL" "DESTINATION" "DEFINES;DEPENDS;INCLUDES;SOURCES;PROPERTIES" ${ARGN})
|
cmake_parse_arguments(_arg "SKIP_INSTALL;SKIP_TRANSLATION"
|
||||||
|
"DESTINATION"
|
||||||
|
"DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;SOURCES;PROPERTIES" ${ARGN})
|
||||||
|
|
||||||
if ($_arg_UNPARSED_ARGUMENTS)
|
if ($_arg_UNPARSED_ARGUMENTS)
|
||||||
message(FATAL_ERROR "add_qtc_executable had unparsed arguments!")
|
message(FATAL_ERROR "add_qtc_executable had unparsed arguments!")
|
||||||
@@ -736,13 +768,21 @@ function(add_qtc_executable name)
|
|||||||
target_include_directories("${name}" PRIVATE "${CMAKE_BINARY_DIR}/src" ${_arg_INCLUDES})
|
target_include_directories("${name}" PRIVATE "${CMAKE_BINARY_DIR}/src" ${_arg_INCLUDES})
|
||||||
target_compile_definitions("${name}" PRIVATE ${_arg_DEFINES} ${TEST_DEFINES} ${DEFAULT_DEFINES})
|
target_compile_definitions("${name}" PRIVATE ${_arg_DEFINES} ${TEST_DEFINES} ${DEFAULT_DEFINES})
|
||||||
target_link_libraries("${name}" PRIVATE ${_arg_DEPENDS} ${_TEST_DEPENDS})
|
target_link_libraries("${name}" PRIVATE ${_arg_DEPENDS} ${_TEST_DEPENDS})
|
||||||
|
|
||||||
|
set(skip_translation OFF)
|
||||||
|
if (_arg_SKIP_TRANSLATION)
|
||||||
|
set(skip_translation ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
qtc_output_binary_dir(_output_binary_dir)
|
qtc_output_binary_dir(_output_binary_dir)
|
||||||
set_target_properties("${name}" PROPERTIES
|
set_target_properties("${name}" PROPERTIES
|
||||||
BUILD_RPATH "${_RPATH_BASE}/${_RELATIVE_LIB_PATH}"
|
BUILD_RPATH "${_RPATH_BASE}/${_RELATIVE_LIB_PATH}"
|
||||||
INSTALL_RPATH "${_RPATH_BASE}/${_RELATIVE_LIB_PATH}"
|
INSTALL_RPATH "${_RPATH_BASE}/${_RELATIVE_LIB_PATH}"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${_DESTINATION}"
|
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${_DESTINATION}"
|
||||||
|
QT_SKIP_TRANSLATION "${skip_translation}"
|
||||||
${_arg_PROPERTIES}
|
${_arg_PROPERTIES}
|
||||||
)
|
)
|
||||||
|
append_extra_translations("${name}" "${_arg_EXTRA_TRANSLATIONS}")
|
||||||
enable_pch(${name})
|
enable_pch(${name})
|
||||||
|
|
||||||
if (NOT _arg_SKIP_INSTALL)
|
if (NOT _arg_SKIP_INSTALL)
|
||||||
@@ -790,6 +830,9 @@ function(add_qtc_test name)
|
|||||||
add_test(NAME ${name} COMMAND ${name})
|
add_test(NAME ${name} COMMAND ${name})
|
||||||
fix_test_environment(${name})
|
fix_test_environment(${name})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Never translate tests:
|
||||||
|
set_tests_properties(${name} PROPERTIES QT_SKIP_TRANSLATION ON)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(finalize_qtc_gtest test_name)
|
function(finalize_qtc_gtest test_name)
|
||||||
|
@@ -21,3 +21,5 @@ install(
|
|||||||
FILES indexer_preincludes/qglobal.h indexer_preincludes/windows.h
|
FILES indexer_preincludes/qglobal.h indexer_preincludes/windows.h
|
||||||
DESTINATION "${IDE_DATA_PATH}/indexer_preincludes"
|
DESTINATION "${IDE_DATA_PATH}/indexer_preincludes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_subdirectory(translations)
|
||||||
|
214
share/qtcreator/translations/CMakeLists.txt
Normal file
214
share/qtcreator/translations/CMakeLists.txt
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
set(languages cs da de fr ja pl ru sl uk zh_CN zh_TW)
|
||||||
|
set(bad_languages hu) # Fix these before including them in languages!
|
||||||
|
|
||||||
|
find_package(PythonInterp)
|
||||||
|
|
||||||
|
set(json_wizards_h "")
|
||||||
|
set(custom_wizards_h "")
|
||||||
|
set(externaltools_h "")
|
||||||
|
set(snippets_h "")
|
||||||
|
|
||||||
|
if (NOT PYTHONINTERP_FOUND OR NOT PYTHON_VERSION_STRING VERSION_GREATER_EQUAL "3.0.0")
|
||||||
|
message(WARNING "No python3 interpreter found, skipping extraction of data from XML and JSON files.\n *** Please pass -DPYTHON_EXECUTABLE=/path/to/python3 to cmake.")
|
||||||
|
else()
|
||||||
|
set(json_wizards_h "${CMAKE_CURRENT_BINARY_DIR}/jsonwizards_tr.h")
|
||||||
|
add_custom_command(OUTPUT "${json_wizards_h}"
|
||||||
|
COMMAND "${PYTHON_EXECUTABLE}"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/extract-jsonwizards.py"
|
||||||
|
"${PROJECT_SOURCE_DIR}/share/qtcreator/templates/wizards" "${json_wizards_h}"
|
||||||
|
COMMENT Generate translation data from JSON wizards
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
set(custom_wizards_h "${CMAKE_CURRENT_BINARY_DIR}/customwizards_tr.h")
|
||||||
|
add_custom_command(OUTPUT "${custom_wizards_h}"
|
||||||
|
COMMAND "${PYTHON_EXECUTABLE}"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/extract-customwizards.py"
|
||||||
|
"${PROJECT_SOURCE_DIR}/share/qtcreator/templates/wizards" "${custom_wizards_h}"
|
||||||
|
COMMENT Generate translation data from XML wizards
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
set(externaltools_h "${CMAKE_CURRENT_BINARY_DIR}/externaltools_tr.h")
|
||||||
|
add_custom_command(OUTPUT "${externaltools_h}"
|
||||||
|
COMMAND "${PYTHON_EXECUTABLE}"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/extract-externaltools.py"
|
||||||
|
"${PROJECT_SOURCE_DIR}/src/share/qtcreator/externaltools" "${externaltools_h}"
|
||||||
|
COMMENT Generate translation data from external tools definitions
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
set(snippets_h "${CMAKE_CURRENT_BINARY_DIR}/snippets_tr.h")
|
||||||
|
add_custom_command(OUTPUT "${snippets_h}"
|
||||||
|
COMMAND "${PYTHON_EXECUTABLE}"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/extract-snippets.py"
|
||||||
|
"${PROJECT_SOURCE_DIR}/share/qtcreator/snippets" "${snippets_h}"
|
||||||
|
COMMENT Generate translation data from snippets definitions
|
||||||
|
VERBATIM)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(_extract_ts_data_from_targets outprefix)
|
||||||
|
set(_sources "")
|
||||||
|
set(_includes "")
|
||||||
|
|
||||||
|
set(_targets "${ARGN}")
|
||||||
|
list(REMOVE_DUPLICATES _targets)
|
||||||
|
|
||||||
|
foreach(t IN ITEMS ${_targets})
|
||||||
|
if (TARGET "${t}")
|
||||||
|
get_target_property(_skip_translation "${t}" QT_SKIP_TRANSLATION)
|
||||||
|
get_target_property(_source_dir "${t}" SOURCE_DIR)
|
||||||
|
get_target_property(_interface_include_dirs "${t}" INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
get_target_property(_include_dirs "${t}" INCLUDE_DIRECTORIES)
|
||||||
|
get_target_property(_source_files "${t}" SOURCES)
|
||||||
|
get_target_property(_extra_translations "${t}" QT_EXTRA_TRANSLATIONS)
|
||||||
|
|
||||||
|
if (NOT _skip_translation)
|
||||||
|
if(_include_dirs)
|
||||||
|
list(APPEND _includes ${_include_dirs})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(_interface_include_dirs)
|
||||||
|
list(APPEND _interface_includes ${_include_dirs})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_target_sources "")
|
||||||
|
if(_source_files)
|
||||||
|
list(APPEND _target_sources ${_source_files})
|
||||||
|
endif()
|
||||||
|
if(_extra_translations)
|
||||||
|
list(APPEND _target_sources ${_extra_translations})
|
||||||
|
endif()
|
||||||
|
foreach(s IN ITEMS ${_target_sources})
|
||||||
|
get_filename_component(_abs_source "${s}" ABSOLUTE BASE_DIR "${_source_dir}")
|
||||||
|
list(APPEND _sources "${_abs_source}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set("${outprefix}_sources" "${_sources}" PARENT_SCOPE)
|
||||||
|
set("${outprefix}_includes" "${_includes}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(_create_ts_custom_target name)
|
||||||
|
cmake_parse_arguments(_arg "" "FILE_PREFIX;TS_TARGET_PREFIX" "LANGUAGES;SOURCES;INCLUDES" ${ARGN})
|
||||||
|
if (_arg_UNPARSED_ARGUMENTS)
|
||||||
|
message(FATAL_ERROR "Invalid parameters to _create_ts_custom_target: ${_arg_UNPARSED_ARGUMENTS}.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT _arg_TS_TARGET_PREFIX)
|
||||||
|
set(_arg_TS_TARGET_PREFIX "ts_")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(ts_languages ${_arg_LANGUAGES})
|
||||||
|
if (NOT ts_languages)
|
||||||
|
set(ts_languages "${name}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(l IN ITEMS ${ts_languages})
|
||||||
|
list(APPEND ts_files "${CMAKE_CURRENT_SOURCE_DIR}/${_arg_FILE_PREFIX}_${l}.ts")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(_sources "${_arg_SOURCES}")
|
||||||
|
list(SORT _sources)
|
||||||
|
|
||||||
|
set(_includes "${_arg_INCLUDES}")
|
||||||
|
|
||||||
|
list(REMOVE_DUPLICATES _sources)
|
||||||
|
list(REMOVE_DUPLICATES _includes)
|
||||||
|
|
||||||
|
list(REMOVE_ITEM _sources "")
|
||||||
|
list(REMOVE_ITEM _includes "")
|
||||||
|
|
||||||
|
set(_prepended_includes)
|
||||||
|
foreach(include IN LISTS _includes)
|
||||||
|
list(APPEND _prepended_includes "-I${include}")
|
||||||
|
endforeach()
|
||||||
|
set(_includes "${_prepended_includes}")
|
||||||
|
|
||||||
|
string(REPLACE ";" "\n" _sources_str "${_sources}")
|
||||||
|
string(REPLACE ";" "\n" _includes_str "${_includes}")
|
||||||
|
|
||||||
|
set(ts_file_list "${CMAKE_CURRENT_BINARY_DIR}/ts_${name}.lst")
|
||||||
|
file(WRITE "${ts_file_list}" "${_sources_str}\n${_includes_str}\n")
|
||||||
|
|
||||||
|
add_custom_target("${_arg_TS_TARGET_PREFIX}${name}"
|
||||||
|
COMMAND Qt5::lupdate -locations relative -no-ui-lines -no-sort "@${ts_file_list}" -ts ${ts_files}
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
COMMENT "Generate .ts files"
|
||||||
|
DEPENDS ${_sources}
|
||||||
|
VERBATIM)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(add_translation_targets file_prefix)
|
||||||
|
if (NOT TARGET Qt5::lrelease)
|
||||||
|
# No Qt translation tools were found: Skip this directory
|
||||||
|
message(WARNING "No Qt translation tools found, skipping translation targets. Add find_package(Qt5 COMPONENTS LinguistTools) to CMake to enable.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
cmake_parse_arguments(_arg ""
|
||||||
|
"OUTPUT_DIRECTORY;INSTALL_DESTINATION;TS_TARGET_PREFIX;QM_TARGET_PREFIX;ALL_QM_TARGET"
|
||||||
|
"LANGUAGES;TARGETS;SOURCES;INCLUDES" ${ARGN})
|
||||||
|
if (_arg_UNPARSED_ARGUMENTS)
|
||||||
|
message(FATAL_ERROR "Invalid parameters to add_translation_targets: ${_arg_UNPARSED_ARGUMENTS}.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT _arg_TS_TARGET_PREFIX)
|
||||||
|
set(_arg_TS_TARGET_PREFIX "ts_")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT _arg_QM_TARGET_PREFIX)
|
||||||
|
set(_arg_QM_TARGET_PREFIX "generate_qm_file_")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT _arg_ALL_QM_TARGET)
|
||||||
|
set(_arg_ALL_QM_TARGET "generate_qm_files")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT _arg_OUTPUT_DIRECTORY)
|
||||||
|
set(_arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT _arg_INSTALL_DESTINATION)
|
||||||
|
message(FATAL_ERROR "Please provide a INSTALL_DESTINATION to add_translation_targets")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
_extract_ts_data_from_targets(_to_process "${_arg_TARGETS}")
|
||||||
|
|
||||||
|
_create_ts_custom_target(untranslated
|
||||||
|
FILE_PREFIX "${file_prefix}" TS_TARGET_PREFIX "${_arg_TS_TARGET_PREFIX}"
|
||||||
|
SOURCES ${_to_process_sources} ${_arg_SOURCES} INCLUDES ${_to_process_includes} ${_arg_INCLUDES})
|
||||||
|
|
||||||
|
if (NOT TARGET "${_arg_ALL_QM_TARGET}")
|
||||||
|
add_custom_target("${_arg_ALL_QM_TARGET}" ALL COMMENT "Generate .qm-files")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(l IN ITEMS ${_arg_LANGUAGES})
|
||||||
|
set(_ts_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}_${l}.ts")
|
||||||
|
set(_qm_file "${_arg_OUTPUT_DIRECTORY}/${file_prefix}_${l}.qm")
|
||||||
|
|
||||||
|
_create_ts_custom_target("${l}" FILE_PREFIX "${file_prefix}" TS_TARGET_PREFIX "${_arg_TS_TARGET_PREFIX}"
|
||||||
|
SOURCES ${_to_process_sources} ${_arg_SOURCES} INCLUDES ${_to_process_includes} ${_arg_INCLUDES})
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT "${_qm_file}"
|
||||||
|
COMMAND Qt5::lrelease "${_ts_file}" -qm "${_qm_file}"
|
||||||
|
MAIN_DEPENDENCY "${_ts_file}"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
COMMENT "Generate .qm file"
|
||||||
|
VERBATIM)
|
||||||
|
add_custom_target("${_arg_QM_TARGET_PREFIX}${l}" DEPENDS "${_qm_file}")
|
||||||
|
install(FILES "${_qm_file}" DESTINATION ${_arg_INSTALL_DESTINATION})
|
||||||
|
|
||||||
|
add_dependencies("${_arg_ALL_QM_TARGET}" "${_arg_QM_TARGET_PREFIX}${l}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
_create_ts_custom_target(all LANGUAGES ${_arg_LANGUAGES} FILE_PREFIX "${file_prefix}"
|
||||||
|
SOURCES ${_to_process_sources} ${_arg_SOURCES} INCLUDES ${_to_process_includes} ${_arg_INCLUDES})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
### collect targets to include in documentation:
|
||||||
|
add_translation_targets(qtcreator
|
||||||
|
LANGUAGES ${languages}
|
||||||
|
OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${IDE_DATA_PATH}/translations"
|
||||||
|
INSTALL_DESTINATION "${IDE_DATA_PATH}/translations"
|
||||||
|
TARGETS "${__QTC_LIBRARIES}" "${__QTC_PLUGINS}"
|
||||||
|
SOURCES "${json_wizards_h}" "${custom_wizards_h}" "${externaltools_h}" "${snippets_h}")
|
67
share/qtcreator/translations/extract-customwizards.py
Normal file
67
share/qtcreator/translations/extract-customwizards.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
# Contact: https://www.qt.io/licensing/
|
||||||
|
#
|
||||||
|
# This file is part of Qt Creator.
|
||||||
|
#
|
||||||
|
# Commercial License Usage
|
||||||
|
# Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
# accordance with the commercial license agreement provided with the
|
||||||
|
# Software or, alternatively, in accordance with the terms contained in
|
||||||
|
# a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
# and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
# information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
#
|
||||||
|
# GNU General Public License Usage
|
||||||
|
# Alternatively, this file may be used under the terms of the GNU
|
||||||
|
# General Public License version 3 as published by the Free Software
|
||||||
|
# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
# included in the packaging of this file. Please review the following
|
||||||
|
# information to ensure the GNU General Public License requirements will
|
||||||
|
# be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print("Please provide a top level directory to scan and a file to write into.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
top_dir = sys.argv[1]
|
||||||
|
target_file = sys.argv[2]
|
||||||
|
|
||||||
|
|
||||||
|
def fix_value(value):
|
||||||
|
value = value.replace('\"', '\\\"')
|
||||||
|
value = value.replace('\n', '\\\n')
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def parse_file(file_path):
|
||||||
|
root = ET.parse(file_path).getroot()
|
||||||
|
result = ''
|
||||||
|
|
||||||
|
for i in ['.//description', './/displayname', './/displaycategory',
|
||||||
|
'.//fieldpagetitle', './/fielddescription',
|
||||||
|
'.//comboentrytext',
|
||||||
|
'.//message']:
|
||||||
|
for e in root.findall(i):
|
||||||
|
result += 'QT_TRANSLATE_NOOP("ProjectExplorer::CustomWizard", "{}"); // {}\n'.format(fix_value(e.text), file_path)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
result = ''
|
||||||
|
|
||||||
|
# traverse root directory, and list directories as dirs and files as files
|
||||||
|
for root, _, files in os.walk(top_dir):
|
||||||
|
for file in files:
|
||||||
|
if file == "wizard.xml":
|
||||||
|
result += parse_file(os.path.join(root, file))
|
||||||
|
|
||||||
|
with open(target_file, 'w') as header_file:
|
||||||
|
header_file.write(result)
|
64
share/qtcreator/translations/extract-externaltools.py
Normal file
64
share/qtcreator/translations/extract-externaltools.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
# Contact: https://www.qt.io/licensing/
|
||||||
|
#
|
||||||
|
# This file is part of Qt Creator.
|
||||||
|
#
|
||||||
|
# Commercial License Usage
|
||||||
|
# Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
# accordance with the commercial license agreement provided with the
|
||||||
|
# Software or, alternatively, in accordance with the terms contained in
|
||||||
|
# a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
# and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
# information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
#
|
||||||
|
# GNU General Public License Usage
|
||||||
|
# Alternatively, this file may be used under the terms of the GNU
|
||||||
|
# General Public License version 3 as published by the Free Software
|
||||||
|
# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
# included in the packaging of this file. Please review the following
|
||||||
|
# information to ensure the GNU General Public License requirements will
|
||||||
|
# be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print("Please provide a top level directory to scan and a file to write into.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
top_dir = sys.argv[1]
|
||||||
|
target_file = sys.argv[2]
|
||||||
|
|
||||||
|
|
||||||
|
def fix_value(value):
|
||||||
|
value = value.replace('\"', '\\\"')
|
||||||
|
value = value.replace('\n', '\\\n')
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def parse_file(file_path):
|
||||||
|
root = ET.parse(file_path).getroot()
|
||||||
|
result = ''
|
||||||
|
|
||||||
|
for i in ['.//description', './/displayname', './/category']:
|
||||||
|
for e in root.findall(i):
|
||||||
|
result += 'QT_TRANSLATE_NOOP("Core::Internal::ExternalTool", "{}"); // {}\n'.format(fix_value(e.text), file_path)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
result = ''
|
||||||
|
|
||||||
|
# traverse root directory, and list directories as dirs and files as files
|
||||||
|
for root, _, files in os.walk(top_dir):
|
||||||
|
for file in files:
|
||||||
|
if file.endswith('.xml'):
|
||||||
|
result += parse_file(os.path.join(root, file))
|
||||||
|
|
||||||
|
with open(target_file, 'w') as header_file:
|
||||||
|
header_file.write(result)
|
81
share/qtcreator/translations/extract-jsonwizards.py
Normal file
81
share/qtcreator/translations/extract-jsonwizards.py
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
# Contact: https://www.qt.io/licensing/
|
||||||
|
#
|
||||||
|
# This file is part of Qt Creator.
|
||||||
|
#
|
||||||
|
# Commercial License Usage
|
||||||
|
# Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
# accordance with the commercial license agreement provided with the
|
||||||
|
# Software or, alternatively, in accordance with the terms contained in
|
||||||
|
# a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
# and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
# information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
#
|
||||||
|
# GNU General Public License Usage
|
||||||
|
# Alternatively, this file may be used under the terms of the GNU
|
||||||
|
# General Public License version 3 as published by the Free Software
|
||||||
|
# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
# included in the packaging of this file. Please review the following
|
||||||
|
# information to ensure the GNU General Public License requirements will
|
||||||
|
# be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print("Please provide a top level directory to scan and a file to write into.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
top_dir = sys.argv[1]
|
||||||
|
target_file = sys.argv[2]
|
||||||
|
|
||||||
|
|
||||||
|
def recursive_iter(obj, key=''):
|
||||||
|
if isinstance(obj, dict):
|
||||||
|
for k in sorted(obj.keys()):
|
||||||
|
yield from recursive_iter(obj[k], k)
|
||||||
|
elif isinstance(obj, tuple):
|
||||||
|
for item in obj:
|
||||||
|
yield from recursive_iter(item, '')
|
||||||
|
elif isinstance(obj, list):
|
||||||
|
for item in obj:
|
||||||
|
yield from recursive_iter(item, '')
|
||||||
|
else:
|
||||||
|
yield key, obj
|
||||||
|
|
||||||
|
|
||||||
|
def fix_value(value):
|
||||||
|
value = value.replace('\"', '\\\"')
|
||||||
|
value = value.replace('\n', '\\\n')
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def parse_file(file_path):
|
||||||
|
root = ''
|
||||||
|
result = ''
|
||||||
|
|
||||||
|
with open(file_path) as f:
|
||||||
|
root = json.load(f)
|
||||||
|
|
||||||
|
for key, value in recursive_iter(root):
|
||||||
|
if key.startswith('tr'):
|
||||||
|
result += 'QT_TRANSLATE_NOOP("ProjectExplorer::JsonWizard", "{}"); // {}\n'.format(fix_value(value), file_path)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
result = '// This file is autogenerated\n'
|
||||||
|
|
||||||
|
# traverse root directory, and list directories as dirs and files as files
|
||||||
|
for root, _, files in os.walk(top_dir):
|
||||||
|
for file in files:
|
||||||
|
if file == "wizard.json":
|
||||||
|
result += parse_file(os.path.join(root, file))
|
||||||
|
|
||||||
|
with open(target_file, 'w') as header_file:
|
||||||
|
header_file.write(result)
|
65
share/qtcreator/translations/extract-snippets.py
Normal file
65
share/qtcreator/translations/extract-snippets.py
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 The Qt Company Ltd.
|
||||||
|
# Contact: https://www.qt.io/licensing/
|
||||||
|
#
|
||||||
|
# This file is part of Qt Creator.
|
||||||
|
#
|
||||||
|
# Commercial License Usage
|
||||||
|
# Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
# accordance with the commercial license agreement provided with the
|
||||||
|
# Software or, alternatively, in accordance with the terms contained in
|
||||||
|
# a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
# and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
# information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
#
|
||||||
|
# GNU General Public License Usage
|
||||||
|
# Alternatively, this file may be used under the terms of the GNU
|
||||||
|
# General Public License version 3 as published by the Free Software
|
||||||
|
# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
# included in the packaging of this file. Please review the following
|
||||||
|
# information to ensure the GNU General Public License requirements will
|
||||||
|
# be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print("Please provide a top level directory to scan and a file to write into.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
top_dir = sys.argv[1]
|
||||||
|
target_file = sys.argv[2]
|
||||||
|
|
||||||
|
|
||||||
|
def fix_value(value):
|
||||||
|
value = value.replace('\"', '\\\"')
|
||||||
|
value = value.replace('\n', '\\\n')
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def parse_file(file_path):
|
||||||
|
root = ET.parse(file_path).getroot()
|
||||||
|
result = ''
|
||||||
|
|
||||||
|
for e in root.findall('snippet'):
|
||||||
|
if 'complement' in e.attrib:
|
||||||
|
result += 'QT_TRANSLATE_NOOP3("TextEditor::Internal::Snippets", "{}", "group:\'{}\' trigger:\'{}\'"); // {}\n' \
|
||||||
|
.format(fix_value(e.attrib['complement']), e.attrib['group'], e.attrib['trigger'], file_path)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
result = ''
|
||||||
|
|
||||||
|
# traverse root directory, and list directories as dirs and files as files
|
||||||
|
for root, _, files in os.walk(top_dir):
|
||||||
|
for file in files:
|
||||||
|
if file.endswith('.xml'):
|
||||||
|
result += parse_file(os.path.join(root, file))
|
||||||
|
|
||||||
|
with open(target_file, 'w') as header_file:
|
||||||
|
header_file.write(result)
|
@@ -1,4 +1,5 @@
|
|||||||
add_qtc_plugin(HelloWorld
|
add_qtc_plugin(HelloWorld
|
||||||
|
SKIP_TRANSLATION
|
||||||
PLUGIN_DEPENDS Core
|
PLUGIN_DEPENDS Core
|
||||||
SOURCES
|
SOURCES
|
||||||
helloworldplugin.cpp helloworldplugin.h
|
helloworldplugin.cpp helloworldplugin.h
|
||||||
|
@@ -28,6 +28,8 @@ add_qtc_plugin(QmlDesigner
|
|||||||
components/propertyeditor/propertyeditorvalue.h
|
components/propertyeditor/propertyeditorvalue.h
|
||||||
components/connectioneditor/connectionviewwidget.h
|
components/connectioneditor/connectionviewwidget.h
|
||||||
SKIP_DEBUG_CMAKE_FILE_CHECK
|
SKIP_DEBUG_CMAKE_FILE_CHECK
|
||||||
|
EXTRA_TRANSLATIONS
|
||||||
|
"${PROJECT_SOURCE_DIR}/share/qtcreator/qmldesigner"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(QmlDesignerPluginInstallPrefix "${IDE_PLUGIN_PATH}/qmldesigner")
|
set(QmlDesignerPluginInstallPrefix "${IDE_PLUGIN_PATH}/qmldesigner")
|
||||||
|
@@ -7,4 +7,6 @@ add_qtc_plugin(StudioWelcome
|
|||||||
studiowelcome_global.h
|
studiowelcome_global.h
|
||||||
studiowelcome.qrc
|
studiowelcome.qrc
|
||||||
"${PROJECT_SOURCE_DIR}/src/share/3rdparty/studiofonts/studiofonts.qrc"
|
"${PROJECT_SOURCE_DIR}/src/share/3rdparty/studiofonts/studiofonts.qrc"
|
||||||
|
EXTRA_TRANSLATIONS
|
||||||
|
qml
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user