Remove HTML from translations

Fixes #260
This commit is contained in:
Jonas Kvinge 2019-12-29 23:37:48 +01:00
parent a603dc5227
commit 9b688a5179
9 changed files with 79 additions and 44 deletions

View File

@ -61,9 +61,28 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent)
ui_->setupUi(this);
// Add the available fields to the tooltip here instead of the ui file to prevent that they get translated by mistake.
QString available_fields = Song::kFtsColumns.join(", ").replace(QRegExp("\\bfts"), "");
ui_->filter->setToolTip(ui_->filter->toolTip().arg(available_fields));
ui_->filter->setToolTip(
"<html><head/><body><p>" +
tr("Prefix a word with a field name to limit the search to that field, e.g.:") +
" " +
"<span style=\"font-weight:600;\">" +
tr("artist") +
":" +
"</span><span style=\"font-style:italic;\">Strawbs</span>" +
" " +
tr("searches the collection for all artists that contain the word") +
"Strawbs" +
"." +
"</p><p><span style=\"font-weight:600;\">" +
tr("Available fields") +
": " +
"</span><span style=\"font-style:italic;\">" +
available_fields +
"</span>." +
"</p></body></html>"
);
connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed()));
connect(filter_delay_, SIGNAL(timeout()), SLOT(FilterDelayTimeout()));

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Collection Filter</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
@ -31,9 +31,6 @@
</property>
<item>
<widget class="QSearchField" name="filter" native="true">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Prefix a word with a field name to limit the search to that field, e.g. &lt;span style=&quot; font-weight:600;&quot;&gt;artist:&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Bode&lt;/span&gt; searches the collection for all artists that contain the word Bode.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Available fields: &lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;%1&lt;/span&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="placeholderText" stdset="0">
<string>Enter search terms here</string>
</property>

View File

@ -246,15 +246,18 @@ void ContextView::NoSong() {
ui_->label_stop_top->setText(tr("No song playing"));
QString html = tr(
"%1 songs<br />\n"
"%2 artists<br />\n"
"%3 albums<br />\n"
)
.arg(collectionview_->TotalSongs())
.arg(collectionview_->TotalArtists())
.arg(collectionview_->TotalAlbums())
;
QString html;
if (collectionview_->TotalSongs() == 1) html += tr("%1 song").arg(collectionview_->TotalSongs());
else html += tr("%1 songs").arg(collectionview_->TotalSongs());
html += "<br />";
if (collectionview_->TotalArtists() == 1) html += tr("%1 artist").arg(collectionview_->TotalArtists());
else html += tr("%1 artists").arg(collectionview_->TotalArtists());
html += "<br />";
if (collectionview_->TotalAlbums() == 1) html += tr("%1 album").arg(collectionview_->TotalAlbums());
else html += tr("%1 albums").arg(collectionview_->TotalAlbums());
html += "<br />";
ui_->label_stop_summary->setStyleSheet(
"font: 12pt;"
@ -416,7 +419,7 @@ void ContextView::SetSong(const Song &song) {
if (albumlist.count() > 1) {
ui_->label_play_albums->setVisible(true);
ui_->label_play_albums->setMinimumSize(0, 20);
ui_->label_play_albums->setText(tr("<b>Albums by %1</b>").arg( song.artist().toHtmlEscaped()));
ui_->label_play_albums->setText("<b>" + tr("Albums by %1").arg( song.artist().toHtmlEscaped()) + "</b>");
ui_->label_play_albums->setStyleSheet("background-color: #3DADE8; color: rgb(255, 255, 255); font: 11pt;");
for (CollectionBackend::Album album : albumlist) {
SongList songs = app_->collection_backend()->GetSongs(song.artist(), album.album_name, opt);

View File

@ -108,26 +108,19 @@ QString About::MainHtml() const {
QString ret;
ret = tr("<p>Version %1</p>").arg(QCoreApplication::applicationVersion());
ret += "<p>";
ret += tr("Version %1").arg(QCoreApplication::applicationVersion());
ret += "</p>";
ret += "<p>";
ret += tr("Strawberry is a music player and music collection organizer.<br />");
ret += tr("It is a fork of Clementine released in 2018 aimed at music collectors, audio enthusiasts and audiophiles.<br />");
ret += tr("Strawberry is a music player and music collection organizer.");
ret += "<br />";
ret += tr("It is a fork of Clementine released in 2018 aimed at music collectors, audio enthusiasts and audiophiles.");
ret += "<br />";
ret += tr("The name is inspired by the band Strawbs. It's based on a heavily modified version of Clementine created in 2012-2013. It's written in C++ and Qt 5.");
ret += "</p>";
ret += "<p>";
ret += tr("Strawberry is free software: you can redistribute it and/or modify<br />");
ret += tr("it under the terms of the GNU General Public License as published by<br />");
ret += tr("the Free Software Foundation, either version 3 of the License, or<br />");
ret += tr("(at your option) any later version.<br />");
ret += "<br />";
ret += tr("Strawberry is distributed in the hope that it will be useful,<br />");
ret += tr("but WITHOUT ANY WARRANTY; without even the implied warranty of<br />");
ret += tr("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br />");
ret += tr("GNU General Public License for more details.<br />");
ret += "<br />";
ret += tr("You should have received a copy of the GNU General Public License<br />");
ret += tr("along with Strawberry. If not, see <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a>.");
ret += tr("Strawberry is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.");
ret += "</p>";
return ret;
@ -138,31 +131,46 @@ QString About::ContributorsHtml() const {
QString ret;
ret += tr("<p><b>Strawberry authors</b>");
ret += "<p>";
ret += "<b>";
ret += tr("Maintainer");
ret += "</b>";
for (const Person &person : strawberry_authors_) {
ret += "<br />" + PersonToHtml(person);
}
ret += "</p>";
ret += tr("<p><b>Strawberry contributors</b>");
ret += "<p>";
ret += "<b>";
ret += tr("Contributors");
ret += "</b>";
for (const Person &person : strawberry_contributors_) {
ret += "<br />" + PersonToHtml(person);
}
ret += "</p>";
ret += tr("<p><b>Thanks to</b>");
ret += "<p>";
ret += "<b>";
ret += tr("Thanks to");
ret += "</b>";
for (const Person &person : strawberry_thanks_) {
ret += "<br />" + PersonToHtml(person);
}
ret += "</p>";
ret += tr("<p><b>Clementine authors</b>");
ret += "<p>";
ret += "<b>";
ret += tr("Clementine authors");
ret += "</b>";
for (const Person &person : clementine_authors_) {
ret += "<br />" + PersonToHtml(person);
}
ret += "</p>";
ret += tr("<p><b>Clementine contributors</b>");
ret += "<p>";
ret += "<b>";
ret += tr("Clementine contributors");
ret += "</b>";
for (const Person &person : clementine_contributors_) {
ret += "<br />" + PersonToHtml(person);
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>700</height>
<width>500</width>
<height>600</height>
</rect>
</property>
<property name="maximumSize">
@ -139,6 +139,12 @@
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>

View File

@ -149,7 +149,7 @@ void ListenBrainzScrobbler::Authenticate(const bool https) {
bool result = QDesktopServices::openUrl(url);
if (!result) {
QMessageBox messagebox(QMessageBox::Information, tr("ListenBrainz Authentication"), tr("Please open this URL in your browser:<br /><a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
QMessageBox messagebox(QMessageBox::Information, tr("ListenBrainz Authentication"), tr("Please open this URL in your browser") + QString(":<br /><a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
messagebox.setTextFormat(Qt::RichText);
messagebox.exec();
}

View File

@ -156,7 +156,7 @@ void ScrobblingAPI20::Authenticate(const bool https) {
if (openurl_result) {
break;
}
QMessageBox messagebox_error(QMessageBox::Warning, tr("%1 Scrobbler Authentication").arg(name_), tr("Could not open URL. Please open this URL in your browser:<br /><a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
QMessageBox messagebox_error(QMessageBox::Warning, tr("%1 Scrobbler Authentication").arg(name_), tr("Could not open URL. Please open this URL in your browser") + QString(":<br /><a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
messagebox_error.setTextFormat(Qt::RichText);
messagebox_error.exec();
}

View File

@ -71,6 +71,8 @@ ScrobblerSettingsPage::ScrobblerSettingsPage(SettingsDialog *parent)
connect(ui_->widget_listenbrainz_login_state, SIGNAL(LogoutClicked()), SLOT(ListenBrainz_Logout()));
ui_->widget_listenbrainz_login_state->AddCredentialGroup(ui_->widget_listenbrainz_login);
ui_->label_listenbrainz_token->setText("<html><head/><body><p>" + tr("Enter your user token from") + " " + "<a href=\"https://listenbrainz.org/profile/\"><span style=\"text-decoration: underline; color:#0000ff;\">https://listenbrainz.org/profile/</span></a></p></body></html>");
resize(sizeHint());
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>769</width>
<height>749</height>
<width>600</width>
<height>800</height>
</rect>
</property>
<property name="windowTitle">
@ -248,9 +248,9 @@
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="label_listenbrainz_token">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter your user token found on: &lt;a href=&quot;https://listenbrainz.org/profile/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://listenbrainz.org/profile/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string/>
</property>
</widget>
</item>