Open petercpg opened 1 month ago
Hello @petercpg ! Thank you for logging this. This was also tracked in the past, here - https://mozilla-hub.atlassian.net/browse/VPN-4488 . We should decide on the validity of this issue. CC: @albionx @flodolo
FYI, Peter is part of our community of volunteers and doesn't have access to internal Jira tickets. Clearly this is a valid issue, probably coming out of qt libraries.
@petercpg I forgot that this was originally reported for zh-CN (zh_Hans) and I did investigate, but I missed an important part.
Time for zh_Hant
is set as Bh:mm
in CLDR (link), across the board. But that B
needs to be localized as well, while here it stays as B
.
Examples from Firefox console
const today = new Date(Date.UTC(2024, 09, 25, 11, 51, 0, 0));
console.log(new Intl.DateTimeFormat('zh-TW', { timeStyle: 'short' }).format(today));
> 上午11:51
console.log(new Intl.DateTimeFormat('zh-Hant', { timeStyle: 'short' }).format(today));
> 上午11:51
https://cldr.unicode.org/translation/date-time/date-time-patterns#basic-time-formats
B to use day periods like “in the afternoon” instead of AM/PM.
That seems indeed like a bug in qt, or in the library they use to access CLDR-based functions.
Is it possible to expose date format strings to l10n, so localizers can override them, or for zh-TW, use HH:mm
forcibly as a workaround, until Qt fixes the problem?
I would really prefer to avoid exposing strings for date/time formatting.
At least Qt 6.7.2 seems to work correctly, so maybe the issue is in the VPN code
#include <QCoreApplication>
#include <QLocale>
#include <QTime>
#include <QDateTime>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTime currentTime = QTime::currentTime();
QLocale locale_en_US(QLocale("en-US"));
QLocale locale_zh_Hant(QLocale("zh-Hant"));
QLocale locale_zh_TW(QLocale("zh-TW"));
// Format time in different locales
QString time_en_US = locale_en_US.toString(currentTime, QLocale::ShortFormat);
QString time_zh_Hant = locale_zh_Hant.toString(currentTime, QLocale::ShortFormat);
QString time_zh_TW = locale_zh_TW.toString(currentTime, QLocale::ShortFormat);
// Output the formatted times
qDebug() << "Time for en-US (short format):" << time_en_US;
qDebug() << "Time for zh-Hant (short format):" << time_zh_Hant;
qDebug() << "Time for zh-TW:" << time_zh_TW;
return a.exec();
}
Time for en-US (short format): "10:49 AM" Time for zh-Hant (short format): "上午10:49" Time for zh-TW: "上午10:49"
Describe the bug When the VPN App is in zh-TW locale, times in UI are prefixed with a "B" character.
VPN version:
Affected Platforms:
Prerequisites: N/A
Steps to reproduce:
Expected result:
Actual result:
B
character, eg.,Last Updated: B22:35
.Additional notes:
The string in localization do not have redundant character either. https://github.com/mozilla-l10n/mozilla-vpn-client-l10n/blob/8bd871f5604ffcf26f89c60be1b66da7a650b5d7/zh_TW/mozillavpn.xliff#L1924