Localized all relevant numbers visible to end-user (#2488)

This commit is contained in:
Paweł 2021-03-06 15:03:33 +01:00 committed by GitHub
parent 346cd2b86d
commit 1eb6aa64db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 7 deletions

View file

@ -55,6 +55,7 @@
- Minor: Update emojis version to 13 (2020). (#1555) - Minor: Update emojis version to 13 (2020). (#1555)
- Minor: Remove EmojiOne 2 and 3 due to license restrictions. (#1555) - Minor: Remove EmojiOne 2 and 3 due to license restrictions. (#1555)
- Minor: Added `/streamlink` command. Usage: `/streamlink <channel>`. You can also use the command without arguments in any twitch channel to open it in streamlink. (#2443) - Minor: Added `/streamlink` command. Usage: `/streamlink <channel>`. You can also use the command without arguments in any twitch channel to open it in streamlink. (#2443)
- Minor: Humanized all numbers visible to end-users. (#2488)
- Bugfix: Fix crash occurring when pressing Escape in the Color Picker Dialog (#1843) - Bugfix: Fix crash occurring when pressing Escape in the Color Picker Dialog (#1843)
- Bugfix: Fix bug where the "check user follow state" event could trigger a network request requesting the user to follow or unfollow a user. By itself its quite harmless as it just repeats to Twitch the same follow state we had, so no follows should have been lost by this but it meant there was a rogue network request that was fired that could cause a crash (#1906) - Bugfix: Fix bug where the "check user follow state" event could trigger a network request requesting the user to follow or unfollow a user. By itself its quite harmless as it just repeats to Twitch the same follow state we had, so no follows should have been lost by this but it meant there was a rogue network request that was fired that could cause a crash (#1906)
- Bugfix: /usercard command will now respect the "Automatically close user popup" setting (#1918) - Bugfix: /usercard command will now respect the "Automatically close user popup" setting (#1918)

View file

@ -17,6 +17,7 @@
#include "singletons/WindowManager.hpp" #include "singletons/WindowManager.hpp"
#include "util/CombinePath.hpp" #include "util/CombinePath.hpp"
#include "util/FormatTime.hpp" #include "util/FormatTime.hpp"
#include "util/Helpers.hpp"
#include "util/StreamLink.hpp" #include "util/StreamLink.hpp"
#include "util/Twitch.hpp" #include "util/Twitch.hpp"
#include "widgets/Window.hpp" #include "widgets/Window.hpp"
@ -515,7 +516,7 @@ void CommandController::initialize(Settings &, Paths &paths)
channel->addMessage(makeSystemMessage( channel->addMessage(makeSystemMessage(
QString("Chatter count: %1") QString("Chatter count: %1")
.arg(QString::number(twitchChannel->chatterCount())))); .arg(localizeNumbers(twitchChannel->chatterCount()))));
return ""; return "";
}); });

View file

@ -1,5 +1,6 @@
#include "Helpers.hpp" #include "Helpers.hpp"
#include <QLocale>
#include <QUuid> #include <QUuid>
namespace chatterino { namespace chatterino {
@ -35,4 +36,10 @@ QString shortenString(const QString &str, unsigned maxWidth)
return shortened; return shortened;
} }
QString localizeNumbers(const int &number)
{
QLocale locale;
return locale.toString(number);
}
} // namespace chatterino } // namespace chatterino

View file

@ -13,4 +13,6 @@ QString formatRichNamedLink(const QString &url, const QString &name,
QString shortenString(const QString &str, unsigned maxWidth = 50); QString shortenString(const QString &str, unsigned maxWidth = 50);
QString localizeNumbers(const int &number);
} // namespace chatterino } // namespace chatterino

View file

@ -14,6 +14,7 @@
#include "singletons/Resources.hpp" #include "singletons/Resources.hpp"
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
#include "util/Clipboard.hpp" #include "util/Clipboard.hpp"
#include "util/Helpers.hpp"
#include "util/LayoutCreator.hpp" #include "util/LayoutCreator.hpp"
#include "util/PostToThread.hpp" #include "util/PostToThread.hpp"
#include "util/Shortcut.hpp" #include "util/Shortcut.hpp"
@ -611,7 +612,8 @@ void UserInfoPopup::updateUserData()
this->ui_.nameLabel->setText(user.displayName); this->ui_.nameLabel->setText(user.displayName);
this->setWindowTitle(TEXT_TITLE.arg(user.displayName)); this->setWindowTitle(TEXT_TITLE.arg(user.displayName));
this->ui_.viewCountLabel->setText(TEXT_VIEWS.arg(user.viewCount)); this->ui_.viewCountLabel->setText(
TEXT_VIEWS.arg(localizeNumbers(user.viewCount)));
this->ui_.createdDateLabel->setText( this->ui_.createdDateLabel->setText(
TEXT_CREATED.arg(user.createdAt.section("T", 0, 0))); TEXT_CREATED.arg(user.createdAt.section("T", 0, 0)));
this->ui_.userIDLabel->setText(TEXT_USER_ID + user.id); this->ui_.userIDLabel->setText(TEXT_USER_ID + user.id);
@ -635,7 +637,7 @@ void UserInfoPopup::updateUserData()
return; return;
} }
this->ui_.followerCountLabel->setText( this->ui_.followerCountLabel->setText(
TEXT_FOLLOWERS.arg(followers.total)); TEXT_FOLLOWERS.arg(localizeNumbers(followers.total)));
}, },
[] { [] {
// on failure // on failure

View file

@ -10,6 +10,7 @@
#include "singletons/Theme.hpp" #include "singletons/Theme.hpp"
#include "singletons/TooltipPreviewImage.hpp" #include "singletons/TooltipPreviewImage.hpp"
#include "singletons/WindowManager.hpp" #include "singletons/WindowManager.hpp"
#include "util/Helpers.hpp"
#include "util/LayoutCreator.hpp" #include "util/LayoutCreator.hpp"
#include "util/LayoutHelper.hpp" #include "util/LayoutHelper.hpp"
#include "util/StreamerMode.hpp" #include "util/StreamerMode.hpp"
@ -47,7 +48,7 @@ namespace {
text += "r9k, "; text += "r9k, ";
if (modes->slowMode) if (modes->slowMode)
text += text +=
QString("slow(%1), ").arg(QString::number(modes->slowMode)); QString("slow(%1), ").arg(localizeNumbers(modes->slowMode));
if (modes->emoteOnly) if (modes->emoteOnly)
text += "emote, "; text += "emote, ";
if (modes->submode) if (modes->submode)
@ -57,7 +58,7 @@ namespace {
if (modes->followerOnly != 0) if (modes->followerOnly != 0)
{ {
text += QString("follow(%1m), ") text += QString("follow(%1m), ")
.arg(QString::number(modes->followerOnly)); .arg(localizeNumbers(modes->followerOnly));
} }
else else
{ {
@ -131,7 +132,7 @@ namespace {
return QString("%1 for %2 with %3 viewers") return QString("%1 for %2 with %3 viewers")
.arg(s.rerun ? "Vod-casting" : "Live") .arg(s.rerun ? "Vod-casting" : "Live")
.arg(s.uptime) .arg(s.uptime)
.arg(QString::number(s.viewerCount)); .arg(localizeNumbers(s.viewerCount));
}(); }();
return QString("<p style=\"text-align: center;\">" + // return QString("<p style=\"text-align: center;\">" + //
@ -163,7 +164,7 @@ namespace {
if (settings.headerUptime) if (settings.headerUptime)
title += " - " + s.uptime; title += " - " + s.uptime;
if (settings.headerViewerCount) if (settings.headerViewerCount)
title += " - " + QString::number(s.viewerCount); title += " - " + localizeNumbers(s.viewerCount);
if (settings.headerGame && !s.game.isEmpty()) if (settings.headerGame && !s.game.isEmpty())
title += " - " + s.game; title += " - " + s.game;
if (settings.headerStreamTitle && !s.title.isEmpty()) if (settings.headerStreamTitle && !s.title.isEmpty())