Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh-TW] Time string rendered into a wired "B"time #9902

Open
petercpg opened this issue Sep 23, 2024 · 6 comments
Open

[zh-TW] Time string rendered into a wired "B"time #9902

petercpg opened this issue Sep 23, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@petercpg
Copy link

Describe the bug
When the VPN App is in zh-TW locale, times in UI are prefixed with a "B" character.

VPN version:

  • Android: 2.25.0 (2.202409190619)
  • iOS: 2.23.0 (2.202406241838)
  • Windows: 2.23.1 (2.202406271914)

Affected Platforms:

  • Android, iOS, Windows

Prerequisites:
N/A

Steps to reproduce:

  1. Install VPN app
  2. Switch to zh-TW locale
  3. Observe time string on the Home or Message page

Expected result:

  1. The absolute time should be a time.

Actual result:

  1. The absolute time is prefixed with a B character, eg., Last Updated: B22:35.
  2. For relative times, e.g, "Yesterday" there is no redundant character.

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

@petercpg petercpg added the bug Something isn't working label Sep 23, 2024
@ValentinaPC
Copy link
Collaborator

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

@flodolo
Copy link
Collaborator

flodolo commented Sep 24, 2024

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.

@flodolo
Copy link
Collaborator

flodolo commented Sep 25, 2024

@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.

@petercpg
Copy link
Author

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?

@flodolo
Copy link
Collaborator

flodolo commented Sep 26, 2024

I would really prefer to avoid exposing strings for date/time formatting.

@flodolo
Copy link
Collaborator

flodolo commented Sep 26, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants