Port to Qt translations

This commit is contained in:
Jonas Kvinge 2024-10-19 22:21:10 +02:00
parent fbf7fa51e5
commit 1b1ab2e833
62 changed files with 196850 additions and 113543 deletions

View File

@ -42,7 +42,6 @@ jobs:
tar
make
cmake
gettext-tools
openssh-clients
glibc-devel
libboost_headers-devel
@ -162,7 +161,6 @@ jobs:
glib
man
tar
gettext
openssh
rsync
boost-devel
@ -245,7 +243,6 @@ jobs:
make
cmake
glib
gettext
lsb-release
rpmdevtools
rpm-build
@ -349,7 +346,6 @@ jobs:
man
tar
rpmdevtools
gettext
lib64boost-devel
lib64sqlite3-devel
lib64alsa2-devel
@ -441,7 +437,6 @@ jobs:
g++
pkg-config
fakeroot
gettext
lsb-release
dpkg-dev
libglib2.0-dev
@ -519,7 +514,6 @@ jobs:
fakeroot
wget
curl
gettext
lsb-release
dpkg-dev
libglib2.0-dev
@ -598,7 +592,6 @@ jobs:
gcc
g++
fakeroot
gettext
lsb-release
gpg
dput

View File

@ -187,7 +187,6 @@ else()
pkg_check_modules(TAGLIB REQUIRED IMPORTED_TARGET taglib>=1.12)
endif()
find_package(Gettext)
find_package(GTest)
find_library(GMOCK_LIBRARY gmock)
@ -206,10 +205,6 @@ if(Qt${QT_VERSION_MAJOR}DBus_FOUND)
set(DBUS_FOUND ON)
endif()
if(Qt${QT_VERSION_MAJOR}LinguistTools_FOUND)
get_target_property(QT_LCONVERT_EXECUTABLE Qt${QT_VERSION_MAJOR}::lconvert LOCATION)
endif()
if(X11_FOUND)
find_path(QPA_QPLATFORMNATIVEINTERFACE_H qpa/qplatformnativeinterface.h PATHS ${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS})
@ -333,7 +328,6 @@ optional_component(GPOD ON "Devices: iPod classic support"
)
optional_component(TRANSLATIONS ON "Translations"
DEPENDS "gettext" GETTEXT_FOUND
DEPENDS "Qt LinguistTools" Qt${QT_VERSION_MAJOR}LinguistTools_FOUND
)
@ -354,10 +348,6 @@ if(HAVE_X11_GLOBALSHORTCUTS OR HAVE_KDE_GLOBALSHORTCUTS OR HAVE_GNOME_GLOBALSHOR
set(HAVE_GLOBALSHORTCUTS ON)
endif()
if(HAVE_TRANSLATIONS)
include(cmake/Translations.cmake)
endif()
if(NOT CMAKE_CROSSCOMPILING)
# Check that we have Qt with sqlite driver
set(CMAKE_REQUIRED_FLAGS "-std=c++17")
@ -1413,38 +1403,6 @@ qt_wrap_cpp(SOURCES ${HEADERS})
qt_wrap_ui(SOURCES ${UI})
qt_add_resources(SOURCES data/data.qrc data/icons.qrc)
if(HAVE_TRANSLATIONS)
set(LINGUAS "All" CACHE STRING "A space-seperated list of translations to compile in to Strawberry, or \"None\".")
if(LINGUAS STREQUAL "All")
# build LANGUAGES from all existing .po files
file(GLOB pofiles src/translations/*.po)
foreach(pofile ${pofiles})
get_filename_component(lang ${pofile} NAME_WE)
list(APPEND LANGUAGES ${lang})
endforeach(pofile)
else(LINGUAS STREQUAL "All")
if(NOT LINGUAS OR LINGUAS STREQUAL "None")
set(LANGUAGES "")
else(NOT LINGUAS OR LINGUAS STREQUAL "None")
string(REGEX MATCHALL [a-zA-Z_@]+ LANGUAGES ${LINGUAS})
endif(NOT LINGUAS OR LINGUAS STREQUAL "None")
endif(LINGUAS STREQUAL "All")
if(NOT MSVC)
add_pot(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/translations/header
${CMAKE_CURRENT_SOURCE_DIR}/src/translations/translations.pot
${SOURCES}
${MOC}
${UIC}
${CMAKE_SOURCE_DIR}/data/html/oauthsuccess.html
)
endif()
add_po(SOURCES strawberry_ LANGUAGES ${LANGUAGES} DIRECTORY src/translations)
endif()
target_sources(strawberry PRIVATE ${SOURCES})
if(WIN32)
@ -1462,6 +1420,16 @@ if(LINUX AND LSB_RELEASE_EXEC AND DPKG_BUILDPACKAGE)
add_subdirectory(debian)
endif()
if(HAVE_TRANSLATIONS)
file(GLOB_RECURSE ts_files src/translations/*.ts)
set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/data")
qt_add_lupdate(strawberry TS_FILES ${ts_files} OPTIONS -no-ui-lines -locations none -no-obsolete)
qt_add_lrelease(strawberry TS_FILES ${ts_files} QM_FILES_OUTPUT_VARIABLE INSTALL_TRANSLATIONS_FILES)
if(NOT INSTALL_TRANSLATIONS)
qt_add_resources(strawberry "translations" PREFIX "/i18n" BASE "${CMAKE_CURRENT_BINARY_DIR}/data" FILES "${INSTALL_TRANSLATIONS_FILES}")
endif()
endif()
target_include_directories(strawberry PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}

View File

@ -25,6 +25,7 @@ Enhancements:
* Remove old MacFSListener.
* Remove external tagreader and protobuf dependency.
* Remove VLC support.
* Ported to Qt translation (.ts) files and removed gettext dependency.
Version 1.1.3 (2024.09.21):

View File

@ -1,97 +0,0 @@
find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext REQUIRED)
if(NOT MSVC)
find_program(CAT_EXECUTABLE cat REQUIRED)
endif()
list(APPEND XGETTEXT_OPTIONS
--qt
--keyword=tr:1,2c
--keyword=tr
--flag=tr:1:pass-c-format
--flag=tr:1:pass-qt-format
--keyword=trUtf8
--flag=tr:1:pass-c-format
--flag=tr:1:pass-qt-format
--keyword=translate:2,3c
--keyword=translate:2
--flag=translate:2:pass-c-format
--flag=translate:2:pass-qt-format
--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
)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/translations)
macro(add_pot outfiles header pot)
# 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)
# Generate the .pot
add_custom_command(
OUTPUT ${pot}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} ${XGETTEXT_OPTIONS} -C --omit-header --no-location --output="${CMAKE_CURRENT_BINARY_DIR}/pot.temp" ${add_pot_sources}
COMMAND cat ${header} ${CMAKE_CURRENT_BINARY_DIR}/pot.temp > ${pot}
DEPENDS ${add_pot_sources} ${header}
)
list(APPEND ${outfiles} ${pot})
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
"LANGUAGES;DIRECTORY"
""
${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 "strawberry_${_lang}.qm")
set(_qm_filepath "${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/${_qm_filename}")
# Convert the .po files to .qm files
add_custom_command(
OUTPUT ${_qm_filepath}
COMMAND ${QT_LCONVERT_EXECUTABLE} ARGS ${_po_filepath} -o ${_qm_filepath} -of qm -target-language ${_lang}
DEPENDS ${_po_filepath} ${_po_filepath}
)
list(APPEND ${outfiles} ${_qm_filepath})
list(APPEND INSTALL_TRANSLATIONS_FILES ${_qm_filepath})
endforeach (_lang)
# Generate a qrc file for the translations
if(NOT INSTALL_TRANSLATIONS)
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc)
file(WRITE ${_qrc} "<RCC>\n")
file(APPEND ${_qrc} "<qresource prefix=\"/${ADD_PO_DIRECTORY}\">\n")
foreach(_lang ${ADD_PO_LANGUAGES})
file(APPEND ${_qrc} "<file>${po_prefix}${_lang}.qm</file>\n")
endforeach(_lang)
file(APPEND ${_qrc} "</qresource>\n")
file(APPEND ${_qrc} "</RCC>\n")
qt_add_resources(${outfiles} ${_qrc})
endif()
endmacro(add_po)

View File

@ -1,3 +1,3 @@
files:
- source: /src/translations/translations.pot
translation: /src/translations/%locale_with_underscore%.po
- source: /src/translations/strawberry_en_US.ts
translation: /src/translations/strawberry_%locale_with_underscore%.ts

View File

@ -14,7 +14,7 @@
<developer id="net.jkvinge.jonas">
<name>Jonas Kvinge</name>
</developer>
<translation type="gettext">strawberry</translation>
<translation type="qt">strawberry</translation>
<content_rating type="oars-1.1" />
<description>
<p>

View File

@ -21,7 +21,6 @@ BuildRequires: gcc-c++
BuildRequires: hicolor-icon-theme
BuildRequires: make
BuildRequires: git
BuildRequires: gettext
BuildRequires: desktop-file-utils
%if 0%{?suse_version}
BuildRequires: update-desktop-files

View File

@ -279,7 +279,7 @@ int main(int argc, char *argv[]) {
ScopedPtr<Translations> translations(new Translations);
translations->LoadTranslation(u"qt"_s, QLibraryInfo::path(QLibraryInfo::TranslationsPath), language);
translations->LoadTranslation(u"strawberry"_s, u":/src/translations"_s, language);
translations->LoadTranslation(u"strawberry"_s, u":/i18n"_s, language);
translations->LoadTranslation(u"strawberry"_s, QStringLiteral(TRANSLATIONS_DIR), language);
translations->LoadTranslation(u"strawberry"_s, QCoreApplication::applicationDirPath(), language);
translations->LoadTranslation(u"strawberry"_s, QDir::currentPath(), language);

View File

@ -81,7 +81,7 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog, QWidget *pa
#ifdef HAVE_TRANSLATIONS
// Populate the language combo box. We do this by looking at all the compiled in translations.
QDir dir1(QStringLiteral(":/src/translations/"));
QDir dir1(QStringLiteral(":/i18n"));
QDir dir2(QStringLiteral(TRANSLATIONS_DIR));
QStringList codes = dir1.entryList(QStringList() << QStringLiteral("*.qm"));
if (dir2.exists()) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
# Strawberry Music Player
#
#, fuzzy
msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff