Prep for translations

pull/2/head
Aaron Rainbolt 1 year ago
parent f13034ecc2
commit c6b13dd919

@ -1,38 +1,61 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.16)
project(lubuntu-installer-prompt VERSION 1.0.0 LANGUAGES CXX)
project(lubuntu-installer-prompt VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find the required Qt and KDE packages
find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Network)
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core Widgets Network LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Network LinguistTools)
find_package(KF5 REQUIRED COMPONENTS NetworkManagerQt Notifications)
# Set the CMAKE variables for automatic code generation with Qt
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(TS_FILES
src/translations/lubuntu-installer-prompt_en_US.ts
src/translations/lubuntu-installer-prompt_es_ES.ts
src/translations/lubuntu-installer-prompt_zh_CN.ts
)
# Specify project source files
include_directories(${PROJECT_SOURCE_DIR}/src)
file(GLOB PROJECT_SOURCES
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/*.h"
"${PROJECT_SOURCE_DIR}/src/*.ui"
set(PROJECT_SOURCES
src/main.cpp
src/installerprompt.cpp
src/installerprompt.h
src/installerprompt.ui
src/resource.qrc
)
# Add executable target with project source files
add_executable(lubuntu-installer-prompt ${PROJECT_SOURCES} src/resource.qrc)
set(TRANSLATION_RESOURCES "src/translations.qrc")
configure_file(${TRANSLATION_RESOURCES} translations.qrc COPYONLY)
qt5_add_translation(QM_FILES ${TS_FILES})
qt5_add_resources(QM_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
# Link libraries with the executable target
target_link_libraries(lubuntu-installer-prompt Qt5::Widgets Qt5::Network KF5::NetworkManagerQt KF5::Notifications)
target_link_libraries(lubuntu-installer-prompt Qt5::Widgets KF5::NetworkManagerQt KF5::Notifications)
add_custom_target(translations ALL DEPENDS ${QM_FILES})
add_executable(lubuntu-installer-prompt
${PROJECT_SOURCES}
${QM_RESOURCES}
)
install(TARGETS lubuntu-installer-prompt DESTINATION bin)
add_dependencies(lubuntu-installer-prompt translations)
target_link_libraries(lubuntu-installer-prompt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt5::Network KF5::NetworkManagerQt KF5::Notifications)
install(TARGETS lubuntu-installer-prompt
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(PROGRAMS "scripts/lubuntu-installer" DESTINATION libexec)
install(PROGRAMS "scripts/start-lubuntu-live-env" DESTINATION bin)
install(FILES "img/background.png" DESTINATION share/lubuntu/installer-prompt)
install(FILES "lubuntu-live-environment.desktop" DESTINATION share/xsessions)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink /etc/xdg/xdg-Lubuntu /etc/xdg/xdg-lubuntu-live-environment)")
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(lubuntu-installer-prompt)
endif()

@ -24,3 +24,29 @@ This section serves to explain how lubuntu-installer-prompt's various components
10. If Calamares closes, the installer prompt detects this and exits.
11. When the installer prompt exits, start-lubuntu-live-env kills Openbox, then runs startlxqt.
12. If "Try Lubuntu" is clicked, steps 10 and 11 are executed immediately.
## Translations
Run the `gen_ts.sh` script after making any code modifications to ensure that the translations files are up-to-date for translators to work on.
To add a new language to be translated:
* Open the `gen_ts.sh` script and add the locale code for the new language to the `langList` array.
* Run the script after doing this - a new template .ts file will be generated under `src/translations/`.
* Next, add the new template file to the `TS_FILES` list in `CMakeLists.txt` - it will be named `src/translations/lubuntu-installer-prompt-locale_CODE.ts`, where `locale_CODE` is the locale code of the added language.
* Finally, add a line in the src/translations.qrc resource file to include the new translation file. The line should look like `<file alias="locale_CODE">lubuntu-installer-prompt_locale_CODE.qm</file>`, where `locale_CODE` is the locale code of the added language. This line should go inside the `<qresource>` tag.
For instance, if I were to add Chinese to the list of languages that could be translated into, I would do this:
vim gen_ts.sh
# add this code to the langList array:
# 'zh_CN'
./gen_ts.sh
vim CMakeLists.txt
# add this line to the TS_FILES list:
# src/translations/lubuntu-installer-prompt_zh_CN.ts
vim src/translations.qrc
# add this line to the list of file resources:
# <file alias="zh_CN">lubuntu-installer-prompt_zh_CN.qm</file>
The program will now pick up the added language at build time. Any translations added to the newly created .ts file will be shown to program users who select the new language.

@ -0,0 +1,11 @@
#!/bin/bash
langList=('en_US' 'es_ES' 'zh_CN')
for i in ${langList[@]}; do
targetFile="src/translations/lubuntu-installer-prompt_$i.ts"
if [ ! -e $targetFile ]; then
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > $targetFile
echo "<!DOCTYPE TS>" >> $targetFile
echo "<TS version=\"2.1\" language=\"$i\"></TS>" >> $targetFile
fi
done
lupdate src/*.cpp src/*.h src/*.ui -ts src/translations/*

@ -1,10 +1,22 @@
#include "installerprompt.h"
#include <QApplication>
#include <QScreen>
#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
app.installTranslator(&translator);
break;
}
}
QList<InstallerPrompt*> ws;
// Iterate through all available screens

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/i18n">
<file alias="en_US">lubuntu-installer-prompt_en_US.qm</file>
<file alias="es_ES">lubuntu-installer-prompt_es_ES.qm</file>
<file alias="zh_CN">lubuntu-installer-prompt_zh_CN.qm</file>
</qresource>
</RCC>

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>InstallerPrompt</name>
<message>
<location filename="../installerprompt.ui" line="20"/>
<source>Try or Install Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="207"/>
<source>Select Your Language:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="284"/>
<source>Select a Wi-Fi Network:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="329"/>
<location filename="../installerprompt.cpp" line="186"/>
<source>Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="371"/>
<source>(For advanced network configuration, select &quot;Try Lubuntu&quot;)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="466"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Try Lubuntu without installing it on your system. Allows you to use programs, browse the Web, and even temporarily install apps without modifying your system. Changes made within the live environment will be lost when the computer shuts down.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="480"/>
<source> Try Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="542"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Install Lubuntu onto your system. You can install Lubuntu by itself, or alongside an existing operating system.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="553"/>
<source> Install Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="684"/>
<source>Connection Status: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="28"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="28"/>
<source>Background image cannot be loaded.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="81"/>
<source>Not Connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="86"/>
<source>Connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="90"/>
<source>Connecting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="94"/>
<source>Disconnecting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="98"/>
<source>Unknown Status</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="179"/>
<source>Enter Wi-Fi Password for %1:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="182"/>
<source>Wrong Wi-Fi password for %1. Try again:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="237"/>
<source>Connection Failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="237"/>
<source>Unable to connect to the network.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="303"/>
<source>WiFi Not Available</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="303"/>
<source>No WiFi devices were found on this system.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="es_ES">
<context>
<name>InstallerPrompt</name>
<message>
<location filename="../installerprompt.ui" line="20"/>
<source>Try or Install Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="207"/>
<source>Select Your Language:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="284"/>
<source>Select a Wi-Fi Network:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="329"/>
<location filename="../installerprompt.cpp" line="186"/>
<source>Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="371"/>
<source>(For advanced network configuration, select &quot;Try Lubuntu&quot;)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="466"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Try Lubuntu without installing it on your system. Allows you to use programs, browse the Web, and even temporarily install apps without modifying your system. Changes made within the live environment will be lost when the computer shuts down.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="480"/>
<source> Try Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="542"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Install Lubuntu onto your system. You can install Lubuntu by itself, or alongside an existing operating system.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="553"/>
<source> Install Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="684"/>
<source>Connection Status: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="28"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="28"/>
<source>Background image cannot be loaded.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="81"/>
<source>Not Connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="86"/>
<source>Connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="90"/>
<source>Connecting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="94"/>
<source>Disconnecting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="98"/>
<source>Unknown Status</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="179"/>
<source>Enter Wi-Fi Password for %1:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="182"/>
<source>Wrong Wi-Fi password for %1. Try again:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="237"/>
<source>Connection Failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="237"/>
<source>Unable to connect to the network.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="303"/>
<source>WiFi Not Available</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="303"/>
<source>No WiFi devices were found on this system.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>InstallerPrompt</name>
<message>
<location filename="../installerprompt.ui" line="20"/>
<source>Try or Install Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="207"/>
<source>Select Your Language:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="284"/>
<source>Select a Wi-Fi Network:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="329"/>
<location filename="../installerprompt.cpp" line="186"/>
<source>Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="371"/>
<source>(For advanced network configuration, select &quot;Try Lubuntu&quot;)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="466"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Try Lubuntu without installing it on your system. Allows you to use programs, browse the Web, and even temporarily install apps without modifying your system. Changes made within the live environment will be lost when the computer shuts down.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="480"/>
<source> Try Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="542"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Install Lubuntu onto your system. You can install Lubuntu by itself, or alongside an existing operating system.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="553"/>
<source> Install Lubuntu</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.ui" line="684"/>
<source>Connection Status: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="28"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="28"/>
<source>Background image cannot be loaded.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="81"/>
<source>Not Connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="86"/>
<source>Connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="90"/>
<source>Connecting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="94"/>
<source>Disconnecting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="98"/>
<source>Unknown Status</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="179"/>
<source>Enter Wi-Fi Password for %1:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="182"/>
<source>Wrong Wi-Fi password for %1. Try again:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="237"/>
<source>Connection Failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="237"/>
<source>Unable to connect to the network.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="303"/>
<source>WiFi Not Available</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../installerprompt.cpp" line="303"/>
<source>No WiFi devices were found on this system.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
Loading…
Cancel
Save