Implement interface translation

This commit is contained in:
Carmina16 2021-03-06 22:32:26 +07:00 committed by Felix Queißner
parent cdc3888b58
commit 4e89d5d805
13 changed files with 4260 additions and 129 deletions

View File

@ -174,13 +174,13 @@ void BrowserTab::navigateTo(const QUrl &url, PushToHistory mode, RequestFlags fl
{
if (kristall::protocols.isSchemeSupported(url.scheme()) != ProtocolSetup::Enabled)
{
QMessageBox::warning(this, "Kristall", "URI scheme not supported or disabled: " + url.scheme());
QMessageBox::warning(this, tr("Kristall"), tr("URI scheme not supported or disabled: ") + url.scheme());
return;
}
if ((this->current_handler != nullptr) and not this->current_handler->cancelRequest())
{
QMessageBox::warning(this, "Kristall", "Failed to cancel running request!");
QMessageBox::warning(this, tr("Kristall"), tr("Failed to cancel running request!"));
return;
}
@ -288,13 +288,13 @@ void BrowserTab::openSourceView()
monospace_font.setStyleHint(QFont::Monospace);
auto dialog = std::make_unique<QDialog>(this);
dialog->setWindowTitle(QString("Source of %0").arg(this->current_location.toString()));
dialog->setWindowTitle(QString(tr("Source of %0")).arg(this->current_location.toString()));
auto layout = new QVBoxLayout(dialog.get());
dialog->setLayout(layout);
auto hint = new QLabel(dialog.get());
hint->setText(QString("Mime type: %0").arg(current_mime.toString()));
hint->setText(QString(tr("Mime type: %0")).arg(current_mime.toString()));
layout->addWidget(hint);
auto text = new QPlainTextEdit(dialog.get());
@ -343,10 +343,10 @@ void BrowserTab::on_url_bar_returnPressed()
!kristall::options.search_engine.contains("%1"))
{
QMessageBox::warning(this,
"Kristall",
"No search engine is configured.\n"
tr("Kristall"),
tr("No search engine is configured.\n"
"Please configure one in the settings to allow searching via the URL bar.\n\n"
"See the Help menu for additional information."
"See the Help menu for additional information.")
);
return;
}
@ -436,7 +436,7 @@ void BrowserTab::on_networkTimeout()
if(this->current_handler != nullptr) {
this->current_handler->cancelRequest();
}
on_networkError(ProtocolHandler::Timeout, "The server didn't respond in time.");
on_networkError(ProtocolHandler::Timeout, tr("The server didn't respond in time."));
}
void BrowserTab::on_focusSearchbar()
@ -450,7 +450,7 @@ void BrowserTab::on_certificateRequired(const QString &reason)
if (not trySetClientCertificate(reason))
{
setErrorMessage(QString("The page requested a authorized client certificate, but none was provided.\r\nOriginal query was: %1").arg(reason));
setErrorMessage(QString(tr("The page requested a authorized client certificate, but none was provided.\r\nOriginal query was: %1")).arg(reason));
}
else
{
@ -557,12 +557,12 @@ void BrowserTab::on_requestComplete(const QByteArray &ref_data, const MimeType &
} else {
auto response = QMessageBox::question(
this,
"Kristall",
QString("Failed to convert input charset %1 to UTF-8. Cannot display the file.\r\nDo you want to display unconverted data anyways?").arg(charset)
tr("Kristall"),
QString(tr("Failed to convert input charset %1 to UTF-8. Cannot display the file.\r\nDo you want to display unconverted data anyways?")).arg(charset)
);
if(response != QMessageBox::Yes) {
setErrorMessage(QString("Failed to convert input charset %1 to UTF-8.").arg(charset));
setErrorMessage(QString(tr("Failed to convert input charset %1 to UTF-8.")).arg(charset));
return;
}
}
@ -725,7 +725,7 @@ void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime)
}
else
{
this->graphics_scene.addText(QString("Failed to load picture:\r\n%1").arg(reader.errorString()));
this->graphics_scene.addText(QString(tr("Failed to load picture:\r\n%1")).arg(reader.errorString()));
}
this->ui->graphics_browser->setScene(&graphics_scene);
@ -754,13 +754,13 @@ void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime)
document->setDefaultStyleSheet(doc_style.toStyleSheet());
QString plain_data = QString(
"Unsupported Media Type!\n"
tr("Unsupported Media Type!\n"
"\n"
"Kristall cannot display the requested document\n"
"To view this media, use the File menu to save it to your local drive, then open the saved file in another program that can display the document for you.\n\n"
"Details:\n"
"- MIME type: %1/%2\n"
"- Size: %3\n"
"- Size: %3\n")
).arg(mime.type, mime.subtype, IoUtil::size_human(data.size()));
document->setPlainText(plain_data);
@ -770,7 +770,7 @@ void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime)
else
{
QString page_data = QString(
"# Unsupported Media Type!\n"
tr("# Unsupported Media Type!\n"
"\n"
"Kristall cannot display the requested document.\n"
"\n"
@ -780,7 +780,7 @@ void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime)
"Details:\n"
"- MIME type: %1/%2\n"
"- Size: %3\n"
"```\n"
"```\n")
).arg(mime.type, mime.subtype, IoUtil::size_human(data.size()));
document = GeminiRenderer::render(
@ -874,7 +874,7 @@ void BrowserTab::on_inputRequired(const QString &query, const bool is_sensitive)
{
if (dialog.exec() != QDialog::Accepted)
{
setErrorMessage(QString("Site requires input:\n%1").arg(query));
setErrorMessage(QString(tr("Site requires input:\n%1")).arg(query));
return;
}
@ -885,7 +885,7 @@ void BrowserTab::on_inputRequired(const QString &query, const bool is_sensitive)
if(len >= 1020) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("Your input message is too long. Your input is %1 bytes, but a maximum of %2 bytes are allowed.\r\nPlease cancel or shorten your input.").arg(len).arg(1020)
);
} else {
@ -910,7 +910,7 @@ void BrowserTab::on_redirected(QUrl uri, bool is_permanent)
if (redirection_count >= kristall::options.max_redirections)
{
setErrorMessage(QString("Too many consecutive redirections. The last redirection would have redirected you to:\r\n%1").arg(uri.toString(QUrl::FullyEncoded)));
setErrorMessage(QString(tr("Too many consecutive redirections. The last redirection would have redirected you to:\r\n%1")).arg(uri.toString(QUrl::FullyEncoded)));
return;
}
else
@ -922,34 +922,34 @@ void BrowserTab::on_redirected(QUrl uri, bool is_permanent)
if(kristall::options.redirection_policy == GenericSettings::WarnAlways)
{
question = QString(
"The location you visited wants to redirect you to another location:\r\n"
tr("The location you visited wants to redirect you to another location:\r\n"
"%1\r\n"
"Do you want to allow the redirection?"
"Do you want to allow the redirection?")
).arg(uri.toString(QUrl::FullyEncoded));
}
else if((kristall::options.redirection_policy & (GenericSettings::WarnOnHostChange | GenericSettings::WarnOnSchemeChange)) and is_cross_protocol and is_cross_host)
{
question = QString(
"The location you visited wants to redirect you to another host and switch the protocol.\r\n"
tr("The location you visited wants to redirect you to another host and switch the protocol.\r\n"
"Protocol: %1\r\n"
"New Host: %2\r\n"
"Do you want to allow the redirection?"
"Do you want to allow the redirection?")
).arg(uri.scheme()).arg(uri.host());
}
else if((kristall::options.redirection_policy & GenericSettings::WarnOnSchemeChange) and is_cross_protocol)
{
question = QString(
"The location you visited wants to switch the protocol.\r\n"
tr("The location you visited wants to switch the protocol.\r\n"
"Protocol: %1\r\n"
"Do you want to allow the redirection?"
"Do you want to allow the redirection?")
).arg(uri.scheme());
}
else if((kristall::options.redirection_policy & GenericSettings::WarnOnHostChange) and is_cross_host)
{
question = QString(
"The location you visited wants to redirect you to another host.\r\n"
tr("The location you visited wants to redirect you to another host.\r\n"
"New Host: %1\r\n"
"Do you want to allow the redirection?"
"Do you want to allow the redirection?")
).arg(uri.host());
}
@ -957,11 +957,11 @@ void BrowserTab::on_redirected(QUrl uri, bool is_permanent)
{
auto answer = QMessageBox::question(
this,
"Kristall",
tr("Kristall"),
question
);
if(answer != QMessageBox::Yes) {
setErrorMessage(QString("Redirection to %1 cancelled by user").arg(uri.toString()));
setErrorMessage(QString(tr("Redirection to %1 cancelled by user")).arg(uri.toString()));
return;
}
}
@ -975,7 +975,7 @@ void BrowserTab::on_redirected(QUrl uri, bool is_permanent)
}
else
{
setErrorMessage(QString("Redirection to %1 failed").arg(uri.toString()));
setErrorMessage(QString(tr("Redirection to %1 failed")).arg(uri.toString()));
}
}
}
@ -984,7 +984,7 @@ void BrowserTab::setErrorMessage(const QString &msg)
{
this->is_internal_location = true;
this->on_requestComplete(
QString("An error happened:\r\n%0").arg(msg).toUtf8(),
QString(tr("An error happened:\r\n%0")).arg(msg).toUtf8(),
"text/plain charset=utf-8");
this->updateUI();
@ -1062,7 +1062,7 @@ void BrowserTab::on_text_browser_anchorClicked(const QUrl &url, bool open_in_new
if(not is_theme_preview and opt == "ignore-tls") {
auto response = QMessageBox::question(
this,
"Kristall",
tr("Kristall"),
tr("This sites certificate could not be verified! This may be a man-in-the-middle attack on the server to send you malicious content (or the server admin made a configuration mistake).\r\nAre you sure you want to continue?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No
@ -1079,7 +1079,7 @@ void BrowserTab::on_text_browser_anchorClicked(const QUrl &url, bool open_in_new
else if(not is_theme_preview and opt == "add-fingerprint") {
auto answer = QMessageBox::question(
this,
"Kristall",
tr("Kristall"),
tr("Do you really want to add the server certificate to your list of trusted hosts?\r\nHost: %1")
.arg(this->current_location.host()),
QMessageBox::Yes | QMessageBox::No,
@ -1138,7 +1138,7 @@ void BrowserTab::on_text_browser_anchorClicked(const QUrl &url, bool open_in_new
auto answer = QMessageBox::question(
this,
"Kristall",
tr("Kristall"),
tr("Do you want to add the style %1 to your collection?").arg(name)
);
if(answer != QMessageBox::Yes)
@ -1169,7 +1169,7 @@ void BrowserTab::on_text_browser_anchorClicked(const QUrl &url, bool open_in_new
QMessageBox::information(
this,
"Kristall",
tr("Kristall"),
tr("The theme %1 was successfully added to your theme collection!").arg(name)
);
}
@ -1181,7 +1181,7 @@ void BrowserTab::on_text_browser_anchorClicked(const QUrl &url, bool open_in_new
} else {
QMessageBox::critical(
this,
"Kristall",
tr("Kristall"),
tr("Malicious site detected! This site tries to use the Kristall control scheme!\r\nA trustworthy site does not do this!").arg(this->current_location.host())
);
}
@ -1208,16 +1208,16 @@ void BrowserTab::on_text_browser_anchorClicked(const QUrl &url, bool open_in_new
{
if (not QDesktopServices::openUrl(url))
{
QMessageBox::warning(this, "Kristall", QString("Failed to start system URL handler for\r\n%1").arg(real_url.toString()));
QMessageBox::warning(this, "Kristall", QString(tr("Failed to start system URL handler for\r\n%1")).arg(real_url.toString()));
}
}
else if (support == ProtocolSetup::Disabled)
{
QMessageBox::warning(this, "Kristall", QString("The requested url uses a scheme that has been disabled in the settings:\r\n%1").arg(real_url.toString()));
QMessageBox::warning(this, "Kristall", QString(tr("The requested url uses a scheme that has been disabled in the settings:\r\n%1")).arg(real_url.toString()));
}
else
{
QMessageBox::warning(this, "Kristall", QString("The requested url cannot be processed by Kristall:\r\n%1").arg(real_url.toString()));
QMessageBox::warning(this, "Kristall", QString(tr("The requested url cannot be processed by Kristall:\r\n%1")).arg(real_url.toString()));
}
}
}
@ -1470,7 +1470,7 @@ void BrowserTab::resetClientCertificate()
{
if (this->current_identity.isValid() and not this->current_identity.is_persistent)
{
auto respo = QMessageBox::question(this, "Kristall", "You currently have a transient session active!\r\nIf you disable the session, you will not be able to restore it. Continue?");
auto respo = QMessageBox::question(this, "Kristall", tr("You currently have a transient session active!\r\nIf you disable the session, you will not be able to restore it. Continue?"));
if (respo != QMessageBox::Yes)
{
this->ui->enable_client_cert_button->setChecked(true);
@ -1644,7 +1644,7 @@ bool BrowserTab::enableClientCertificate(const CryptoIdentity &ident)
{
if (not ident.isValid())
{
QMessageBox::warning(this, "Kristall", "Failed to generate temporary crypto-identitiy");
QMessageBox::warning(this, "Kristall", tr("Failed to generate temporary crypto-identitiy"));
this->disableClientCertificate();
return false;
}
@ -1697,26 +1697,26 @@ void BrowserTab::on_text_browser_customContextMenuRequested(const QPoint pos)
if (real_url.isRelative())
real_url = this->current_location.resolved(real_url);
connect(menu.addAction("Open in new tab"), &QAction::triggered, [this, real_url]() {
connect(menu.addAction(tr("Open in new tab")), &QAction::triggered, [this, real_url]() {
mainWindow->addNewTab(false, real_url);
});
// "open in default browser" for HTTP/S links
if (real_url.scheme().startsWith("http", Qt::CaseInsensitive)) {
connect(menu.addAction("Open with external web browser"), &QAction::triggered, [this, real_url]() {
connect(menu.addAction(tr("Open with external web browser")), &QAction::triggered, [this, real_url]() {
if (!QDesktopServices::openUrl(real_url))
{
QMessageBox::warning(this, "Kristall",
QString("Failed to start system URL handler for\r\n%1").arg(real_url.toString()));
QString(tr("Failed to start system URL handler for\r\n%1")).arg(real_url.toString()));
}
});
}
connect(menu.addAction("Follow link"), &QAction::triggered, [this, real_url]() {
connect(menu.addAction(tr("Follow link")), &QAction::triggered, [this, real_url]() {
this->navigateTo(real_url, PushImmediate);
});
connect(menu.addAction("Copy link"), &QAction::triggered, [real_url]() {
connect(menu.addAction(tr("Copy link")), &QAction::triggered, [real_url]() {
kristall::clipboard->setText(real_url.toString(QUrl::FullyEncoded));
});
@ -1746,18 +1746,18 @@ void BrowserTab::on_text_browser_customContextMenuRequested(const QPoint pos)
menu.addSeparator();
} else {
menu.addAction("Copy to clipboard", [this]() {
menu.addAction(tr("Copy to clipboard"), [this]() {
this->ui->text_browser->betterCopy();
}, QKeySequence("Ctrl+C"));
}
connect(menu.addAction("Select all"), &QAction::triggered, [this]() {
connect(menu.addAction(tr("Select all")), &QAction::triggered, [this]() {
this->ui->text_browser->selectAll();
});
menu.addSeparator();
QAction * viewsrc = menu.addAction("View document source");
QAction * viewsrc = menu.addAction(tr("View document source"));
viewsrc->setShortcut(QKeySequence("Ctrl+U"));
connect(viewsrc, &QAction::triggered, [this]() {
mainWindow->viewPageSource();

View File

@ -65,7 +65,7 @@ void CertificateIoDialog::on_select_certificate_file_button_clicked()
{
QFileDialog dialog { this };
dialog.setNameFilter("Certificate File(*.pem *.der)");
dialog.setNameFilter(tr("Certificate File(*.pem *.der)"));
dialog.setAcceptMode((this->current_mode == Export) ? QFileDialog::AcceptSave : QFileDialog::AcceptOpen);
dialog.selectFile(this->ui->certificate_file_name->text());
@ -81,7 +81,7 @@ void CertificateIoDialog::on_select_key_file_button_clicked()
{
QFileDialog dialog { this };
dialog.setNameFilter("Certificate File(*.pem *.der)");
dialog.setNameFilter(tr("Certificate File(*.pem *.der)"));
dialog.setAcceptMode((this->current_mode == Export) ? QFileDialog::AcceptSave : QFileDialog::AcceptOpen);
dialog.selectFile(this->ui->key_file_name->text());

View File

@ -61,7 +61,8 @@ void CertificateManagementDialog::on_certificates_selected(QModelIndex const& in
this->ui->cert_display_name->setText(cert.display_name);
this->ui->cert_common_name->setText(cert.certificate.subjectInfo(QSslCertificate::CommonName).join(", "));
this->ui->cert_expiration_date->setDateTime(cert.certificate.expiryDate());
this->ui->cert_livetime->setText(QString("%1 days").arg(QDateTime::currentDateTime().daysTo(cert.certificate.expiryDate())));
auto days = QDateTime::currentDateTime().daysTo(cert.certificate.expiryDate());
this->ui->cert_livetime->setText(QString(tr("%1 day","%1 days",days)).arg(days));
this->ui->cert_fingerprint->setPlainText(toFingerprintString(cert.certificate));
this->ui->cert_notes->setPlainText(cert.user_notes);
@ -113,29 +114,29 @@ void CertificateManagementDialog::on_delete_cert_button_clicked()
{
auto answer = QMessageBox::question(
this,
"Kristall",
"Do you really want to delete this certificate?\r\n\r\nYou will not be able to restore the identity after this!",
tr("Kristall"),
tr("Do you really want to delete this certificate?\r\n\r\nYou will not be able to restore the identity after this!"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No
);
if(answer != QMessageBox::Yes)
return;
if(not identity_set.destroyIdentity(index)) {
QMessageBox::warning(this, "Kristall", "Could not destroy identity!");
QMessageBox::warning(this, tr("Kristall"), tr("Could not destroy identity!"));
}
}
else if(auto group_name = identity_set.group(index); not group_name.isEmpty()) {
auto answer = QMessageBox::question(
this,
"Kristall",
QString("Do you want to delete the group '%1'").arg(group_name)
tr("Kristall"),
QString(tr("Do you want to delete the group '%1'")).arg(group_name)
);
if(answer != QMessageBox::Yes)
return;
if(not identity_set.deleteGroup(group_name)) {
QMessageBox::warning(this, "Kristall", "Could not delete group!");
QMessageBox::warning(this, tr("Kristall"), tr("Could not delete group!"));
}
}
}
@ -157,7 +158,7 @@ void CertificateManagementDialog::on_export_cert_button_clicked()
if(not cert_file.open(QFile::WriteOnly)) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("The file %1 could not be found!").arg(dialog.certificateFileName())
);
return;
@ -173,7 +174,7 @@ void CertificateManagementDialog::on_export_cert_button_clicked()
if(not IoUtil::writeAll(cert_file, cert_blob)) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("The file %1 could not be created found!").arg(dialog.certificateFileName())
);
return;
@ -185,7 +186,7 @@ void CertificateManagementDialog::on_export_cert_button_clicked()
if(not key_file.open(QFile::WriteOnly)) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("The file %1 could not be found!").arg(dialog.keyFileName())
);
return;
@ -201,8 +202,8 @@ void CertificateManagementDialog::on_export_cert_button_clicked()
if(not IoUtil::writeAll(key_file, key_blob)) {
QMessageBox::warning(
this,
"Kristall",
tr("The file %1 could not be created found!").arg(dialog.keyFileName())
tr("Kristall"),
tr("The file %1 could not be created!").arg(dialog.keyFileName())
);
return;
}
@ -222,7 +223,7 @@ void CertificateManagementDialog::on_import_cert_button_clicked()
if(not cert_file.open(QFile::ReadOnly)) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("The file %1 could not be found!").arg(dialog.certificateFileName())
);
return;
@ -232,7 +233,7 @@ void CertificateManagementDialog::on_import_cert_button_clicked()
if(not key_file.open(QFile::ReadOnly)) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("The file %1 could not be found!").arg(dialog.keyFileName())
);
return;
@ -250,7 +251,8 @@ void CertificateManagementDialog::on_import_cert_button_clicked()
dialog.keyFileName().endsWith(".der") ? QSsl::Der : QSsl::Pem,
};
ident.user_notes = tr("Imported from:\r\nkey: %1\r\n:cert: %2").arg(dialog.keyFileName(), dialog.certificateFileName());
ident.display_name = "Imported Certificate";
//: Default name
ident.display_name = tr("Imported Certificate");
ident.auto_enable = false;
ident.host_filter = "";
ident.is_persistent = true;
@ -258,7 +260,7 @@ void CertificateManagementDialog::on_import_cert_button_clicked()
if(ident.private_key.isNull()) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("The key file %1 could not be loaded. Please verify your key file.").arg(dialog.keyFileName())
);
return;
@ -267,7 +269,7 @@ void CertificateManagementDialog::on_import_cert_button_clicked()
if(ident.certificate.isNull()) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("The certificate file %1 could not be loaded. Please verify your certificate.").arg(dialog.keyFileName())
);
return;
@ -276,7 +278,7 @@ void CertificateManagementDialog::on_import_cert_button_clicked()
if(not identity_set.addCertificate(tr("Imported Certificates"), ident)) {
QMessageBox::warning(
this,
"Kristall",
tr("Kristall"),
tr("Failed to import the certificate.")
);
}

View File

@ -45,9 +45,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
this->ui->ui_density->addItem(tr("Classic"), QVariant::fromValue<int>(int(UIDensity::classic)));
this->ui->list_symbol->clear();
this->ui->list_symbol->addItem("Filled circle", QVariant::fromValue<int>(int(QTextListFormat::Style::ListDisc)));
this->ui->list_symbol->addItem("Circle", QVariant::fromValue<int>(int(QTextListFormat::Style::ListCircle)));
this->ui->list_symbol->addItem("Square", QVariant::fromValue<int>(int(QTextListFormat::Style::ListSquare)));
this->ui->list_symbol->addItem(tr("Filled circle"), QVariant::fromValue<int>(int(QTextListFormat::Style::ListDisc)));
this->ui->list_symbol->addItem(tr("Circle"), QVariant::fromValue<int>(int(QTextListFormat::Style::ListCircle)));
this->ui->list_symbol->addItem(tr("Square"), QVariant::fromValue<int>(int(QTextListFormat::Style::ListSquare)));
setGeminiStyle(DocumentStyle { });
@ -80,11 +80,11 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
}
this->ui->redirection_mode->clear();
this->ui->redirection_mode->addItem("Ask for cross-scheme or cross-host redirection", int(GenericSettings::WarnOnHostChange | GenericSettings::WarnOnSchemeChange));
this->ui->redirection_mode->addItem("Ask for cross-scheme redirection", int(GenericSettings::WarnOnSchemeChange));
this->ui->redirection_mode->addItem("Ask for cross-host redirection", int(GenericSettings::WarnOnHostChange));
this->ui->redirection_mode->addItem("Ask for all redirection", int(GenericSettings::WarnAlways));
this->ui->redirection_mode->addItem("Silently redirect everything", int(GenericSettings::WarnNever));
this->ui->redirection_mode->addItem(tr("Ask for cross-scheme or cross-host redirection"), int(GenericSettings::WarnOnHostChange | GenericSettings::WarnOnSchemeChange));
this->ui->redirection_mode->addItem(tr("Ask for cross-scheme redirection"), int(GenericSettings::WarnOnSchemeChange));
this->ui->redirection_mode->addItem(tr("Ask for cross-host redirection"), int(GenericSettings::WarnOnHostChange));
this->ui->redirection_mode->addItem(tr("Ask for all redirection"), int(GenericSettings::WarnAlways));
this->ui->redirection_mode->addItem(tr("Silently redirect everything"), int(GenericSettings::WarnNever));
connect(this->ui->tabWidget, &QTabWidget::currentChanged, this, [this] (int index) {
if (index != 1) /* Style tab */
@ -260,7 +260,7 @@ void SettingsDialog::setOptions(const GenericSettings &options)
this->ui->search_engine->clear();
QString search = this->current_options.search_engine;
this->ui->search_engine->lineEdit()->setPlaceholderText("URL with '%1' in place of query");
this->ui->search_engine->lineEdit()->setPlaceholderText(tr("URL with '%1' in place of query"));
this->ui->search_engine->addItem("gemini://geminispace.info/search?%1");
this->ui->search_engine->addItem("gemini://gus.guru/search?%1");
this->ui->search_engine->addItem("gemini://houston.coder.town/search?%1");
@ -317,7 +317,7 @@ void SettingsDialog::setOptions(const GenericSettings &options)
this->ui->emojis_on->setEnabled(false);
this->ui->emojis_off->setEnabled(false);
this->ui->emojis_label->setToolTip(
this->ui->emojis_label->toolTip() + " (not supported in this build)");
this->ui->emojis_label->toolTip() + tr(" (not supported in this build)"));
}
}
@ -615,9 +615,9 @@ void SettingsDialog::on_preset_new_clicked()
{
QInputDialog dlg { this };
dlg.setInputMode(QInputDialog::TextInput);
dlg.setOkButtonText("Save");
dlg.setCancelButtonText("Cancel");
dlg.setLabelText("Enter the name of your new preset:");
dlg.setOkButtonText(tr("Save"));
dlg.setCancelButtonText(tr("Cancel"));
dlg.setLabelText(tr("Enter the name of your new preset:"));
if(dlg.exec() != QInputDialog::Accepted)
return;
@ -626,7 +626,7 @@ void SettingsDialog::on_preset_new_clicked()
bool override = false;
if(this->predefined_styles.contains(name))
{
auto response = QMessageBox::question(this, "Kristall", QString("A style with the name '%1' already exists! Replace?").arg(name));
auto response = QMessageBox::question(this, "Kristall", QString(tr("A style with the name '%1' already exists! Replace?")).arg(name));
if(response != QMessageBox::Yes)
return;
override = true;
@ -646,7 +646,7 @@ void SettingsDialog::on_preset_save_clicked()
if(name.isEmpty())
return;
auto response = QMessageBox::question(this, "Kristall", QString("Do you want to override the style '%1'?").arg(name));
auto response = QMessageBox::question(this, "Kristall", QString(tr("Do you want to override the style '%1'?")).arg(name));
if(response != QMessageBox::Yes)
return;
@ -660,7 +660,7 @@ void SettingsDialog::on_preset_load_clicked()
if(name.isEmpty())
return;
auto response = QMessageBox::question(this, "Kristall", QString("Do you want to load the style '%1'?\r\nThis will discard all currently set up values!").arg(name));
auto response = QMessageBox::question(this, "Kristall", QString(tr("Do you want to load the style '%1'?\r\nThis will discard all currently set up values!")).arg(name));
if(response != QMessageBox::Yes)
return;
@ -698,7 +698,7 @@ void SettingsDialog::on_preset_import_clicked()
{
QFileDialog dialog { this };
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.selectNameFilter("Kristall Theme (*.kthm)");
dialog.selectNameFilter(tr("Kristall Theme (*.kthm)"));
if(dialog.exec() !=QFileDialog::Accepted)
return;
@ -715,9 +715,9 @@ void SettingsDialog::on_preset_import_clicked()
{
QInputDialog dlg { this };
dlg.setInputMode(QInputDialog::TextInput);
dlg.setOkButtonText("Save");
dlg.setCancelButtonText("Cancel");
dlg.setLabelText("Imported preset has no name.\r\nPlease enter a name for the preset:");
dlg.setOkButtonText(tr("Save"));
dlg.setCancelButtonText(tr("Cancel"));
dlg.setLabelText(tr("Imported preset has no name.\r\nPlease enter a name for the preset:"));
if(dlg.exec() != QDialog::Accepted)
return;
name = dlg.textValue();
@ -726,7 +726,7 @@ void SettingsDialog::on_preset_import_clicked()
bool override = false;
if(this->predefined_styles.contains(name))
{
auto response = QMessageBox::question(this, "Kristall", QString("Do you want to override the style '%1'?").arg(name));
auto response = QMessageBox::question(this, "Kristall", QString(tr("Do you want to override the style '%1'?")).arg(name));
if(response != QMessageBox::Yes)
return;
override = true;
@ -751,7 +751,7 @@ void SettingsDialog::on_preset_export_clicked()
QFileDialog dialog { this };
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.selectNameFilter("Kristall Theme (*.kthm)");
dialog.selectNameFilter(tr("Kristall Theme (*.kthm)"));
dialog.selectFile(QString("%1.kthm").arg(name));
if(dialog.exec() !=QFileDialog::Accepted)

View File

@ -18,14 +18,14 @@ bool IoUtil::writeAll(QIODevice &dst, QByteArray const & src)
QString IoUtil::size_human(qint64 size)
{
if(size < 1024)
return QString("%1 B").arg(size);
return QString(QObject::tr("%1 B")).arg(size);
float num = size;
QStringList list;
list << "KB" << "MB" << "GB" << "TB";
list << QObject::tr("KB") << QObject::tr("MB") << QObject::tr("GB") << QObject::tr("TB");
QStringListIterator i(list);
QString unit("B");
QString unit(QObject::tr("B"));
while(num >= 1024.0 && i.hasNext())
{

View File

@ -192,8 +192,11 @@ FORMS += \
widgets/mediaplayer.ui \
widgets/ssltrusteditor.ui
CONFIG += lrelease embed_translations
TRANSLATIONS += \
kristall_en_US.ts
../translations/kristall_en_US.ts \
../translations/kristall_ru.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin

View File

@ -2,6 +2,7 @@
#include "kristall.hpp"
#include <QApplication>
#include <QTranslator>
#include <QUrl>
#include <QSettings>
#include <QCommandLineParser>
@ -384,6 +385,12 @@ int main(int argc, char *argv[])
}
});
QTranslator trans, qttrans;
qttrans.load(QLocale(), QLatin1String("qt"), "_", "/usr/local/share/qt5/translations");
trans.load(QLocale(), QLatin1String("kristall"), QLatin1String("_"), QLatin1String(":/i18n"));
app.installTranslator(&qttrans);
app.installTranslator(&trans);
{
// Initialise default fonts
#ifdef Q_OS_WIN32
@ -406,12 +413,12 @@ int main(int argc, char *argv[])
QCommandLineOption newWindowOption {
{ "w", "new-window" },
app.tr("Opens the provided links in a new window instead of tabs."),
QApplication::tr("Opens the provided links in a new window instead of tabs."),
};
QCommandLineOption isolatedOption {
{ "i", "isolated" },
app.tr("Starts the instance of kristall as a isolated session that cannot communicate with other windows."),
QApplication::tr("Starts the instance of kristall as a isolated session that cannot communicate with other windows."),
};
cli_parser.addVersionOption();
@ -419,7 +426,7 @@ int main(int argc, char *argv[])
cli_parser.addOption(newWindowOption);
cli_parser.addOption(isolatedOption);
cli_parser.addPositionalArgument("urls", app.tr("The urls that should be opened instead of the start page"), "[urls...]");
cli_parser.addPositionalArgument("urls", QApplication::tr("The urls that should be opened instead of the start page"), "[urls...]");
cli_parser.process(app);

View File

@ -464,12 +464,12 @@ void MainWindow::on_actionQuit_triggered()
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this,
"Kristall",
R"about(Kristall, an OpenSource Gemini browser.
tr("Kristall"),
tr(R"about(Kristall, an OpenSource Gemini browser.
Made by Felix "xq" Queißner
This is free software. You can get the source code at
https://github.com/MasterQ32/Kristall)about"
https://github.com/MasterQ32/Kristall)about")
);
}
@ -530,9 +530,9 @@ void MainWindow::setFileStatus(const DocumentStats &stats)
{
if(stats.isValid()) {
this->file_size->setText(IoUtil::size_human(stats.file_size));
this->file_cached->setText(stats.loaded_from_cache ? "(cached)" : "");
this->file_cached->setText(stats.loaded_from_cache ? tr("(cached)") : "");
this->file_mime->setText(stats.mime_type.toString(false));
this->load_time->setText(QString("%1 ms").arg(stats.loading_time));
this->load_time->setText(QString(tr("%1 ms")).arg(stats.loading_time));
} else {
this->file_size->setText("");
this->file_cached->setText("");
@ -562,7 +562,7 @@ void MainWindow::on_actionSave_as_triggered()
}
else
{
QMessageBox::warning(this, "Kristall", QString("Could not save file:\r\n%1").arg(file.errorString()));
QMessageBox::warning(this, tr("Kristall"), QString("Could not save file:\r\n%1").arg(file.errorString()));
}
}
}
@ -629,12 +629,12 @@ void MainWindow::on_history_view_customContextMenuRequested(const QPoint pos)
if(QUrl url = tab->history.get(idx); url.isValid()) {
QMenu menu;
connect(menu.addAction("Open here"), &QAction::triggered, [tab, idx]() {
connect(menu.addAction(tr("Open here")), &QAction::triggered, [tab, idx]() {
// We do the same thing as a double click here
tab->navigateBack(idx);
});
connect(menu.addAction("Open in new tab"), &QAction::triggered, [this, url]() {
connect(menu.addAction(tr("Open in new tab")), &QAction::triggered, [this, url]() {
addNewTab(true, url);
});
@ -652,18 +652,18 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos)
BrowserTab * tab = this->curTab();
if(tab != nullptr) {
connect(menu.addAction("Open here"), &QAction::triggered, [tab, url]() {
connect(menu.addAction(tr("Open here")), &QAction::triggered, [tab, url]() {
tab->navigateTo(url, BrowserTab::PushImmediate);
});
}
connect(menu.addAction("Open in new tab"), &QAction::triggered, [this, url]() {
connect(menu.addAction(tr("Open in new tab")), &QAction::triggered, [this, url]() {
addNewTab(true, url);
});
menu.addSeparator();
connect(menu.addAction("Relocate"), &QAction::triggered, [this, idx]() {
connect(menu.addAction(tr("Relocate")), &QAction::triggered, [this, idx]() {
QInputDialog dialog { this };
dialog.setInputMode(QInputDialog::TextInput);
@ -676,7 +676,7 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos)
kristall::favourites.editFavouriteDest(idx, QUrl(dialog.textValue()));
});
connect(menu.addAction("Rename"), &QAction::triggered, [this, idx]() {
connect(menu.addAction(tr("Rename")), &QAction::triggered, [this, idx]() {
QInputDialog dialog { this };
dialog.setInputMode(QInputDialog::TextInput);
@ -691,7 +691,7 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos)
menu.addSeparator();
connect(menu.addAction("Delete"), &QAction::triggered, [idx]() {
connect(menu.addAction(tr("Delete")), &QAction::triggered, [idx]() {
kristall::favourites.destroyFavourite(idx);
});
@ -700,7 +700,7 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos)
else if(QString group = kristall::favourites.group(idx); not group.isEmpty()) {
QMenu menu;
connect(menu.addAction("Rename group"), &QAction::triggered, [this, group]() {
connect(menu.addAction(tr("Rename group")), &QAction::triggered, [this, group]() {
QInputDialog dialog { this };
dialog.setInputMode(QInputDialog::TextInput);
@ -711,18 +711,18 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos)
return;
if (!kristall::favourites.renameGroup(group, dialog.textValue()))
QMessageBox::information(this, "Kristall", "Rename failed: group name already in use.");
QMessageBox::information(this, tr("Kristall"), tr("Rename failed: group name already in use."));
});
menu.addSeparator();
connect(menu.addAction("Delete group"), &QAction::triggered, [this, idx]() {
connect(menu.addAction(tr("Delete group")), &QAction::triggered, [this, idx]() {
if (QMessageBox::question(
this,
"Kristall",
"Are you sure you want to delete this Favourite Group?\n"
tr("Kristall"),
tr("Are you sure you want to delete this Favourite Group?\n"
"All favourites in this group will be lost.\n\n"
"This action cannot be undone!"
"This action cannot be undone!")
) != QMessageBox::Yes)
{
return;
@ -736,7 +736,7 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos)
else {
QMenu menu;
connect(menu.addAction("Create new group..."), &QAction::triggered, [this]() {
connect(menu.addAction(tr("Create new group...")), &QAction::triggered, [this]() {
this->newGroupDialog();
});

View File

@ -26,7 +26,7 @@ bool AboutHandler::startRequest(const QUrl &url, ProtocolHandler::RequestOptions
{
QByteArray document;
document.append("# Favourites\n");
document.append(tr("# Favourites\n"));
QString current_group;

View File

@ -28,9 +28,9 @@ QVariant TrustedHostCollection::headerData(int section, Qt::Orientation orientat
{
switch(section)
{
case 0: return "Host Name";
case 1: return "First Seen";
case 2: return "Key Type";
case 0: return QObject::tr("Host Name");
case 1: return QObject::tr("First Seen");
case 2: return QObject::tr("Key Type");
}
}
return QVariant { };
@ -71,8 +71,8 @@ QVariant TrustedHostCollection::data(const QModelIndex &index, int role) const
case QSsl::Ec: return "EC";
// case QSsl::Dh: return "DH";
case QSsl::Dsa: return "DSA";
case QSsl::Opaque: return "Opaque";
default: return "Unforseen";
case QSsl::Opaque: return QObject::tr("Opaque");
default: return QObject::tr("Unforseen");
}
}
}

View File

@ -18,13 +18,13 @@ FavouritePopup::FavouritePopup(QToolButton *button, QWidget *parent)
auto layout = new QGridLayout();
// Title
auto title_lab = new QLabel("Title:");
auto title_lab = new QLabel(tr("Title:"));
this->fav_title = new QLineEdit();
layout->addWidget(title_lab, 0, 0);
layout->addWidget(this->fav_title, 0, 1);
// Group
auto group_lab = new QLabel("Group:");
auto group_lab = new QLabel(tr("Group:"));
layout->addWidget(group_lab);
{
this->fav_group = new QComboBox();
@ -42,7 +42,7 @@ FavouritePopup::FavouritePopup(QToolButton *button, QWidget *parent)
}
// Unfavourite
auto unfav_btn = new QPushButton("Unfavourite");
auto unfav_btn = new QPushButton(tr("Unfavourite"));
layout->addWidget(unfav_btn);
connect(unfav_btn, &QPushButton::clicked, this, [this]() {
this->setVisible(false);
@ -50,7 +50,7 @@ FavouritePopup::FavouritePopup(QToolButton *button, QWidget *parent)
});
// Confirm
this->confirm_btn = new QPushButton("Confirm");
this->confirm_btn = new QPushButton(tr("Confirm"));
layout->addWidget(this->confirm_btn);
connect(confirm_btn, &QPushButton::clicked, this, [this]() {
this->confirmPressed();

File diff suppressed because it is too large Load Diff

2079
translations/kristall_ru.ts Normal file

File diff suppressed because it is too large Load Diff