Merge pull request 'Modernizar el sistema de traducción' (#3) from translation into main

Reviewed-on: #3
main
Vadim vtroshchinskiy 2023-12-20 15:23:53 +01:00
commit 1cab7f07b5
11 changed files with 347 additions and 287 deletions

View File

@ -26,6 +26,18 @@ El sistema esta basado en CMake. Para compilar:
make -j8 # 8 cores -- cambiar según el numero de cores del hardware
### Traducción
Se usa el sistema de traducción de Qt. Los archivos de lenguaje se encuentran en src/i18n. El sistema de traducción busca cadenas identificadas for `tr("texto")` en el código fuente,
y las reemplaza por versiones traducidas.
Para actualizar los archivos de traducción con cadenas nuevas y/o modificadas en el código, ejecutar `src/update_translations.sh`.
Para traducir, ejecutar Qt Linguist, por ejemplo:
linguist-qt6 i18n/OGBrowser_ca.ts
## Uso
src/OGBrowser URL
@ -64,3 +76,9 @@ El administrador dispone de una consola y mas información sobre la ejecución d
Se activa estableciendo la variable de entorno `ogactiveadmin=true`
## Modo quiosco
Se puede activar el modo quiosco que impide la salida del navegador con Alt+F4.
Se activa estableciendo la variable de entorno `OGKIOSKMODE=true`

118
po/ca.po
View File

@ -1,118 +0,0 @@
# OpenGnsys Client Browser messeages file.
# Copyright (C) 2016
# This file is distributed under the same license as the browser package.
# Ramón M. Gómez <ramongomez@us.es>, 2016.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: OpenGnsys Client Browser 1.1.0\n"
"Report-Msgid-Bugs-To: https://opengnsys.es/\n"
"POT-Creation-Date: 2019-09-11 15:48+0000\n"
"PO-Revision-Date: 2016-05-03 10:25+0200\n"
"Last-Translator: Ramón M. Gómez <ramongomez@us.es>\n"
"Language-Team: CATALAN <LL@li.org>\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/main.cpp:20
#, c-format
msgid "Uso: %s -qws http://sitioweb.com/\n"
msgstr "Ús: %s -qws http://web.com/\n"
#: src/mainwindow.cpp:47
msgid "El fichero de log no ha podido ser abierto: "
msgstr "Log file could not be opened: "
#: src/mainwindow.cpp:68
msgid "&Nueva Terminal"
msgstr "&Nova Terminal"
#: src/mainwindow.cpp:72
msgid "Salida"
msgstr "Sortida"
#: src/mainwindow.cpp:104
msgid "Proyecto OpenGnsys"
msgstr "Projecte OpenGnsys"
#: src/mainwindow.cpp:167
msgid "Hay otro proceso en ejecución. Por favor espere."
msgstr ""
#: src/mainwindow.cpp:183 src/mainwindow.cpp:250
msgid "AVISO"
msgstr "AVIS"
#: src/mainwindow.cpp:186
msgid ""
"La siguiente acci&oacute;n puede modificar datos o tardar varios minutos. El "
"equipo no podr&aacute; ser utilizado durante su ejecuci&oacute;n."
msgstr ""
#: src/mainwindow.cpp:187
msgid "Ejecutar"
msgstr "Executar"
#: src/mainwindow.cpp:188
msgid "Cancelar"
msgstr "Cancel-lar"
#: src/mainwindow.cpp:233
#, c-format
msgid "%p% Cargando"
msgstr "%p% Carregat"
#: src/mainwindow.cpp:253
msgid "La p&aacute;gina no se puede cargar."
msgstr ""
#: src/mainwindow.cpp:255
msgid "Recargar"
msgstr "Recarregar"
#: src/mainwindow.cpp:256
msgid "Abortar"
msgstr "Avortar"
#: src/mainwindow.cpp:333 src/mainwindow.cpp:345
msgid "Fin del proceso. Valor de retorno: "
msgstr ""
#: src/mainwindow.cpp:338
msgid "El proceso ha fallado inesperadamente. Salida: "
msgstr ""
#: src/mainwindow.cpp:347
msgid "AVISO: Pulsar el botón superior derecho para cerrar"
msgstr ""
#: src/mainwindow.cpp:353
msgid "Código de salida: "
msgstr ""
#: src/mainwindow.cpp:364
msgid "Imposible lanzar el proceso."
msgstr ""
#: src/mainwindow.cpp:367
msgid "Error de escritura en el proceso."
msgstr ""
#: src/mainwindow.cpp:370
msgid "Error de lectura del proceso."
msgstr ""
#: src/mainwindow.cpp:378
msgid "Error desconocido."
msgstr ""
#: src/mainwindow.cpp:530 src/mainwindow.cpp:535
msgid "Lanzando el comando: "
msgstr ""
#: src/mainwindow.cpp:563
msgid "ERROR"
msgstr "ERROR"

120
po/en.po
View File

@ -1,120 +0,0 @@
# OpenGnsys Client Browser messeages file.
# Copyright (C) 2016
# This file is distributed under the same license as the browser package.
# Ramón M. Gómez <ramongomez@us.es>, 2016.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: OpenGnsys Client Browser 1.1.0\n"
"Report-Msgid-Bugs-To: https://opengnsys.es/\n"
"POT-Creation-Date: 2019-09-11 15:48+0000\n"
"PO-Revision-Date: 2016-05-03 10:16+0200\n"
"Last-Translator: Ramón M. Gómez <ramongomez@us.es>\n"
"Language-Team: ENGLISH <LL@li.org>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/main.cpp:20
#, c-format
msgid "Uso: %s -qws http://sitioweb.com/\n"
msgstr "Usage: %s -qws http://website.com/\n"
#: src/mainwindow.cpp:47
msgid "El fichero de log no ha podido ser abierto: "
msgstr "Log file could not be opened: "
#: src/mainwindow.cpp:68
msgid "&Nueva Terminal"
msgstr "&New Terminal"
#: src/mainwindow.cpp:72
msgid "Salida"
msgstr "Output"
#: src/mainwindow.cpp:104
msgid "Proyecto OpenGnsys"
msgstr "OpenGnsys Project"
#: src/mainwindow.cpp:167
msgid "Hay otro proceso en ejecución. Por favor espere."
msgstr "There is another process running. Please wait."
#: src/mainwindow.cpp:183 src/mainwindow.cpp:250
msgid "AVISO"
msgstr "WARNING"
#: src/mainwindow.cpp:186
msgid ""
"La siguiente acci&oacute;n puede modificar datos o tardar varios minutos. El "
"equipo no podr&aacute; ser utilizado durante su ejecuci&oacute;n."
msgstr ""
"Following action can modify some data or take several minutes. This computer "
"may not be used during execution."
#: src/mainwindow.cpp:187
msgid "Ejecutar"
msgstr "Run"
#: src/mainwindow.cpp:188
msgid "Cancelar"
msgstr "Cancel"
#: src/mainwindow.cpp:233
#, c-format
msgid "%p% Cargando"
msgstr "%p% Loaded"
#: src/mainwindow.cpp:253
msgid "La p&aacute;gina no se puede cargar."
msgstr "Page can not be loaded."
#: src/mainwindow.cpp:255
msgid "Recargar"
msgstr "Reload"
#: src/mainwindow.cpp:256
msgid "Abortar"
msgstr "Abort"
#: src/mainwindow.cpp:333 src/mainwindow.cpp:345
msgid "Fin del proceso. Valor de retorno: "
msgstr "End of process. Return value: "
#: src/mainwindow.cpp:338
msgid "El proceso ha fallado inesperadamente. Salida: "
msgstr "The process crashed unexpectedly. Return value: "
#: src/mainwindow.cpp:347
msgid "AVISO: Pulsar el botón superior derecho para cerrar"
msgstr "WARNING: Press the upper right button to close"
#: src/mainwindow.cpp:353
msgid "Código de salida: "
msgstr "Exit code: "
#: src/mainwindow.cpp:364
msgid "Imposible lanzar el proceso."
msgstr "Unable to launch the process."
#: src/mainwindow.cpp:367
msgid "Error de escritura en el proceso."
msgstr "Error writing to the process."
#: src/mainwindow.cpp:370
msgid "Error de lectura del proceso."
msgstr "Error reading from the process."
#: src/mainwindow.cpp:378
msgid "Error desconocido."
msgstr "Unknown error."
#: src/mainwindow.cpp:530 src/mainwindow.cpp:535
msgid "Lanzando el comando: "
msgstr "Launching command: "
#: src/mainwindow.cpp:563
msgid "ERROR"
msgstr "ERROR"

View File

@ -286,7 +286,7 @@ install(EXPORT
)
install(FILES
${HDRS_DISTRIB} "${CMAKE_CURRENT_BINARY_DIR}/lib/qtermwidget_export.h" "${CMAKE_CURRENT_BINARY_DIR}/lib/qtermwidget_version.h"
${HDRS_DISTRIB} "${CMAKE_CURRENT_BINARY_DIR}/lib/qtermwidget_export.h" "${CMAKE_BINARY_DIR}/lib/qtermwidget_version.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTERMWIDGET_LIBRARY_NAME}"
COMPONENT Devel
)

View File

@ -19,10 +19,17 @@ set(SOURCES
main.cpp
mainwindow.cpp
ogurlhandler.cpp
)
)
file(GLOB TRANSLATIONS "${PROJECT_SOURCE_DIR}/i18n/*.ts")
message(STATUS "Translations: ${TRANSLATIONS}")
add_executable(OGBrowser ${SOURCES} )
add_executable(OGBrowser ${SOURCES})
qt6_add_translations(OGBrowser TS_FILES ${TRANSLATIONS} QM_FILES_OUTPUT_VARIABLE qm_files)
set_property(TARGET OGBrowser PROPERTY CXX_STANDARD 17)
set_property(TARGET OGBrowser PROPERTY CXX_STANDARD_REQUIRED ON)
@ -35,4 +42,6 @@ target_include_directories(OGBrowser PRIVATE ${qtermwidget_INCLUDE_DIRS} ${Digit
target_link_directories(OGBrowser PRIVATE ${qtermwidget_LIB_DIRS} ${DigitalClock_LIB_DIRS})
install(TARGETS OGBrowser DESTINATION bin )
install(FILES ${qm_files} DESTINATION "translations")

View File

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ca_ES">
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="37"/>
<source>OpenGnsys Browser</source>
<translation>Projecte OpenGnsys</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="51"/>
<source>El fichero de log no ha podido ser abierto: %1.</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">El fitxer de log no ha pogut ser obert: %1.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="72"/>
<source>&amp;Nueva Terminal</source>
<translation>&amp;Nova Terminal</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="76"/>
<source>Salida</source>
<translation>Sortida</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="209"/>
<source>AVISO</source>
<translation>AVIS</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="212"/>
<source>La siguiente acción puede modificar datos o tardar varios minutos. El equipo no podrá ser utilizado durante su ejecución.</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">La següent acció pot modificar dades o trigar uns quants minuts. L&apos;equip no es pot utilitzar durant la seva execució.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="213"/>
<source>Ejecutar</source>
<translation>Executar</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="214"/>
<source>Cancelar</source>
<translation>Cancel-lar</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="257"/>
<location filename="../mainwindow.cpp" line="260"/>
<source>Lanzando el comando: %1</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">Llançant l&apos;ordre: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="271"/>
<source>%p% Cargando</source>
<translation>%p% Carregat</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="360"/>
<location filename="../mainwindow.cpp" line="372"/>
<source>Fin del proceso. Valor de retorno: %1</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">Fi del procés. Valor de tornada: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="365"/>
<source>El proceso ha fallado inesperadamente. Salida: %1</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">El procés ha fallat inesperadament. Sortida: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="374"/>
<source>AVISO: Pulsar el botón superior derecho para cerrar ()</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">AVÍS: Polsar el botó superior dret per tancar ()</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="380"/>
<source>Código de salida: %1</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">Codi de sortida: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="435"/>
<source>Term %1</source>
<translation>Term %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="316"/>
<source>Proc. stdout: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="108"/>
<source>Proyecto OpenGnsys
https://opengnsys.es</source>
<translation>Projecte OpenGnsys\nhttps://opengnsys.es</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="338"/>
<source>Proc. stderr: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="393"/>
<source>Imposible lanzar el proceso.</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">Impossible llençar el procés.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="396"/>
<source>Error de escritura en el proceso.</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">Error d&apos;escriptura al procés.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="399"/>
<source>Error de lectura del proceso.</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">Error de lectura del procés.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="407"/>
<source>Error desconocido.</source>
<translatorcomment>Google Translate</translatorcomment>
<translation type="unfinished">Error desconegut.</translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="37"/>
<source>OpenGnsys Browser</source>
<translation>OpenGnsys Browser</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="72"/>
<source>&amp;Nueva Terminal</source>
<translation>&amp;New Terminal</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="76"/>
<source>Salida</source>
<translation>Output</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="209"/>
<source>AVISO</source>
<translation>WARNING</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="212"/>
<source>La siguiente acción puede modificar datos o tardar varios minutos. El equipo no podrá ser utilizado durante su ejecución.</source>
<translation>The following action can modify data or take several minutes. This computer may not be usable during execution.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="213"/>
<source>Ejecutar</source>
<translation>Run</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="214"/>
<source>Cancelar</source>
<translation>Cancel</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="316"/>
<source>Proc. stdout: </source>
<translation>Process output: </translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="338"/>
<source>Proc. stderr: </source>
<translation>Process error: </translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="51"/>
<source>El fichero de log no ha podido ser abierto: %1.</source>
<translation>The log file couldn&apos;t be opened: %1.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="108"/>
<source>Proyecto OpenGnsys
https://opengnsys.es</source>
<translation>OpenGnsys Project\nhttps://opengnsys.es</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="257"/>
<location filename="../mainwindow.cpp" line="260"/>
<source>Lanzando el comando: %1</source>
<translation>Running command: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="271"/>
<source>%p% Cargando</source>
<translation>%p% Loaded</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="360"/>
<location filename="../mainwindow.cpp" line="372"/>
<source>Fin del proceso. Valor de retorno: %1</source>
<translation>Process finished. Return value: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="365"/>
<source>El proceso ha fallado inesperadamente. Salida: %1</source>
<translation>The process crashed. Return value: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="374"/>
<source>AVISO: Pulsar el botón superior derecho para cerrar ()</source>
<translation>WARNING: Press the upper right button to close ()</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="380"/>
<source>Código de salida: %1</source>
<translation>Return value: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="393"/>
<source>Imposible lanzar el proceso.</source>
<translation>Unable to launch the process.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="396"/>
<source>Error de escritura en el proceso.</source>
<translation>Error writing to the process.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="399"/>
<source>Error de lectura del proceso.</source>
<translation>Error reading from the process.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="407"/>
<source>Error desconocido.</source>
<translation>Unknown error.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="435"/>
<source>Term %1</source>
<translation>Term %1</translation>
</message>
</context>
</TS>

View File

@ -1,30 +1,35 @@
#include <QApplication>
#include <stdio.h>
#include <QTranslator>
#include <QDebug>
#include "mainwindow.h"
// Internacionalización con GNU Gettext.
#include <libintl.h>
#define TEXTDOMAIN "browser"
#define LOCALEDIR "/opt/opengnsys/lib/locale"
#define CHARSET "UTF-8"
int main(int argc, char *argv[])
{
// Preparar internacionalización.
setlocale (LC_ALL, "");
bindtextdomain (TEXTDOMAIN, LOCALEDIR);
textdomain (TEXTDOMAIN);
if(argc<=1)
{
printf(gettext("Uso: %s -qws http://sitioweb.com/\n"),argv[0]);
return -1;
}
// Codificación de caracteres.
//QTextCodec::setCodecForTr(QTextCodec::codecForName(CHARSET));
// QTextCodec::setCodecForCStrings(QTextCodec::codecForName(CHARSET));
//QTextCodec::setCodecForLocale(QTextCodec::codecForName(CHARSET));
QApplication a(argc, argv);
QCoreApplication::setApplicationName("OGBrowser");
QCoreApplication::setOrganizationName("OpenGnsys");
QCoreApplication::setOrganizationDomain("opengnsys.es");
QTranslator translator;
QStringList translationDirs{QCoreApplication::applicationDirPath(), "", "."};
bool translationsOk = false;
for(const QString &dir : translationDirs) {
qDebug() << "Trying to find translations in" << dir;
if (translator.load(QLocale(), "OGBrowser_", "", dir)) {
qDebug() << "Translations loaded";
QCoreApplication::installTranslator(&translator);
translationsOk = true;
break;
}
}
if (!translationsOk) {
qWarning() << "Failed to load translations. Tried looking in:" << translationDirs;
}
MainWindow w;
w.show();
return a.exec();

View File

@ -20,9 +20,6 @@
#include <QStringList>
#include <QString>
#include <libintl.h>
#include "qtermwidget.h"
#include "digitalclock.h"
#include "ogurlhandler.h"
@ -42,6 +39,7 @@ MainWindow::MainWindow(QWidget *parent)
readEnvironmentValues();
m_is_admin = qgetenv("ogactiveadmin") == "true";
m_kiosk_mode = qgetenv("OGKIOSKMODE") == "true";
// Open the log file for append
if(m_env.contains("OGLOGFILE") && m_env["OGLOGFILE"]!="")
@ -50,7 +48,7 @@ MainWindow::MainWindow(QWidget *parent)
if(!m_logfile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
{
delete m_logfile;
print(tr(gettext("El fichero de log no ha podido ser abierto: "))+m_env["OGLOGFILE"]+".");
print(tr("El fichero de log no ha podido ser abierto: %1.").arg(m_env["OGLOGFILE"]));
}
else
{
@ -71,11 +69,11 @@ MainWindow::MainWindow(QWidget *parent)
// TabWidget
m_tabs=new QTabWidget(dock);
QPushButton *button=new QPushButton(tr(gettext("&Nueva Terminal")));
QPushButton *button=new QPushButton(tr("&Nueva Terminal"));
button->setFocusPolicy(Qt::TabFocus);
m_tabs->setCornerWidget(button);
m_tabs->setFocusPolicy(Qt::NoFocus);
m_tabs->addTab(m_output,tr(gettext("Salida")));
m_tabs->addTab(m_output,tr("Salida"));
slotCreateTerminal();
// Assign tabs to dock
dock->setWidget(m_tabs);
@ -107,7 +105,7 @@ MainWindow::MainWindow(QWidget *parent)
m_logo->setPixmap(logo);
else
m_logo->setText("OG");
m_logo->setToolTip(tr(gettext("Proyecto OpenGnsys"))+"\nhttps://opengnsys.es");
m_logo->setToolTip(tr("Proyecto OpenGnsys\nhttps://opengnsys.es"));
// Progress bar
m_progressBar=new QProgressBar(this);
m_progressBar->setRange(0,100);
@ -164,6 +162,14 @@ MainWindow::MainWindow(QWidget *parent)
showFullScreen();
}
void MainWindow::closeEvent(QCloseEvent *event) {
if (isKioskMode()) {
qInfo() << "Modo quiosco activado, ignorando intento de cerrar ventana";
event->ignore();
}
}
MainWindow::~MainWindow()
{
if(m_logfile)
@ -200,12 +206,12 @@ void MainWindow::commandQueued(const QString &command, bool confirm, bool return
if (confirm) {
QMessageBox msgBox;
msgBox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
msgBox.setWindowTitle(tr(gettext("AVISO")));
msgBox.setWindowTitle(tr("AVISO"));
msgBox.setIcon(QMessageBox::Question);
msgBox.setTextFormat(Qt::RichText);
msgBox.setText(tr(gettext("La siguiente acci&oacute;n puede modificar datos o tardar varios minutos. El equipo no podr&aacute; ser utilizado durante su ejecuci&oacute;n.")));
QPushButton *execButton = msgBox.addButton(tr(gettext("Ejecutar")), QMessageBox::ActionRole);
msgBox.addButton(tr(gettext("Cancelar")), QMessageBox::RejectRole);
msgBox.setText(tr("La siguiente acción puede modificar datos o tardar varios minutos. El equipo no podrá ser utilizado durante su ejecución."));
QPushButton *execButton = msgBox.addButton(tr("Ejecutar"), QMessageBox::ActionRole);
msgBox.addButton(tr("Cancelar"), QMessageBox::RejectRole);
msgBox.setDefaultButton(execButton);
msgBox.exec();
@ -248,10 +254,10 @@ void MainWindow::commandQueued(const QString &command, bool confirm, bool return
if(isAdmin()) {
m_output->setTextColor(QColor(Qt::darkGreen));
print(tr(gettext("Lanzando el comando: "))+command);
print(tr("Lanzando el comando: %1").arg(command));
m_output->setTextColor(QColor(Qt::black));
} else {
write(tr(gettext("Lanzando el comando: "))+command);
write(tr("Lanzando el comando: %1").arg(command));
}
m_command.process->start(program,list);
@ -262,7 +268,7 @@ void MainWindow::commandQueued(const QString &command, bool confirm, bool return
void MainWindow::slotWebLoadStarted()
{
startProgressBar();
m_progressBar->setFormat(gettext("%p% Cargando"));
m_progressBar->setFormat(tr("%p% Cargando"));
}
void MainWindow::slotWebLoadProgress(int progress)
@ -351,27 +357,27 @@ void MainWindow::slotProcessFinished(int code, QProcess::ExitStatus status)
{
m_output->setTextColor(QColor(Qt::darkRed));
}
print("\n"+tr(gettext("Fin del proceso. Valor de retorno: "))+QString::number(code));
print("\n"+tr("Fin del proceso. Valor de retorno: %1").arg(code));
}
else
{
m_output->setTextColor(QColor(Qt::darkRed));
print("\n"+tr(gettext("El proceso ha fallado inesperadamente. Salida: ")+code));
print("\n"+tr("El proceso ha fallado inesperadamente. Salida: %1").arg(code));
}
m_output->setTextColor(QColor(Qt::black));
}
else
{
// Non-admin user: show instruction to close the popup window
write(tr(gettext("Fin del proceso. Valor de retorno: "))+QString::number(code));
write(tr("Fin del proceso. Valor de retorno: %1").arg(code));
m_output->setFontUnderline(true);
print("\n\n"+tr(gettext("AVISO: Pulsar el botón superior derecho para cerrar"))+" [X]");
print("\n\n"+tr("AVISO: Pulsar el botón superior derecho para cerrar (✖)"));
m_output->setFontUnderline(false);
}
// On error, show a message box
if(code > 0 && ! m_output->isActiveWindow())
{
showErrorMessage(gettext("Código de salida: ")+QString::number(code));
showErrorMessage(tr("Código de salida: %1").arg(code));
}
finishProgressBar();
}
@ -384,13 +390,13 @@ void MainWindow::slotProcessError(QProcess::ProcessError error)
switch(error)
{
case QProcess::FailedToStart:
errorMsg=tr(gettext("Imposible lanzar el proceso."));
errorMsg=tr("Imposible lanzar el proceso.");
break;
case QProcess::WriteError:
errorMsg=tr(gettext("Error de escritura en el proceso."));
errorMsg=tr("Error de escritura en el proceso.");
break;
case QProcess::ReadError:
errorMsg=tr(gettext("Error de lectura del proceso."));
errorMsg=tr("Error de lectura del proceso.");
break;
// No capturo crashed porque la pillo por finished
case QProcess::Crashed:
@ -398,7 +404,7 @@ void MainWindow::slotProcessError(QProcess::ProcessError error)
break;
case QProcess::UnknownError:
default:
errorMsg=tr(gettext("Error desconocido."));
errorMsg=tr("Error desconocido.");
break;
}
// Print error and show message box with timeout.
@ -426,7 +432,7 @@ void MainWindow::slotCreateTerminal()
connect(console,SIGNAL(finished()),this,SLOT(slotDeleteTerminal()));
QString name=tr("Term ")+QString::number(m_numberTerminal);
QString name=tr("Term %1").arg(m_numberTerminal);
m_tabs->addTab(console,name);
}
@ -556,7 +562,7 @@ void MainWindow::showErrorMessage(QString text)
{
QMessageBox* msgBox=new QMessageBox();
msgBox->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
msgBox->setWindowTitle(gettext("ERROR"));
msgBox->setWindowTitle("ERROR");
msgBox->setIcon(QMessageBox::Warning);
msgBox->setText(text);
msgBox->show();

View File

@ -48,6 +48,8 @@ class MainWindow : public QMainWindow
public:
MainWindow(QWidget *parent = 0);
void closeEvent(QCloseEvent *event) override;
~MainWindow();
public slots:
@ -76,10 +78,12 @@ class MainWindow : public QMainWindow
private:
bool isAdmin() const { return m_is_admin; }
bool isKioskMode() const { return m_kiosk_mode; }
void registerScheme(const QString &name);
void registerHandler(const QString &name, bool confirm, bool output);
bool m_is_admin{false};
bool m_kiosk_mode{false};
//Functions

View File

@ -0,0 +1,5 @@
#!/bin/bash
for ts in i18n/*.ts ; do
lupdate-qt6 *.cpp -ts $ts
done