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

Update Chinese & Cantonese localization #7174

Closed
wants to merge 6 commits into from

Conversation

auroursa
Copy link
Contributor

@auroursa auroursa commented Dec 19, 2024

This PR includes the latest translations from Crowdin, and cleans up outdated strings.

Update: We are attempting to convert the language codes for Chinese and Cantonese from RFC-1766 to RFC-4646, to resolve language-related compatibility issues.

The following are the changes:

  • zh-CN -> zh-Hans-CN
  • zh-TW -> zh-Hant-TW
  • zh-HK -> yue

Similar to ast #6774, yue has been proven to be a valid language code for application languages. Tests have shown that zh-Hans-CN and zh-Hant-TW can also be correctly used by Lingui and the application.

Note the impact of changing the language code is limited to the app display language, Cantonese still cannot be used as post language.

This will be an attempt to fix #6728 without introducing a polyfills.

Co-maintained by @cirx1e @hakadao @VentusUta

Copy link
Contributor Author

@auroursa auroursa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me explain some of the related changes to deviceLocales.ts, which are made to compatibility for both Web and Native platforms.

// Simplified Chinese to zh-CN
locale.languageTag = 'zh-CN'
if (
locale.languageTag === 'zh-CN' ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure browser compatibility, as browsers still widely use RFC-1766.

locale.languageTag = 'zh-CN'
if (
locale.languageTag === 'zh-CN' ||
locale.languageTag.startsWith('zh-Hans')
Copy link
Contributor Author

@auroursa auroursa Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple zh-Hans / zh-Hant variants on iOS and Android, such as zh-Hans-SG. We want to match as many of these language variants as possible.

// Traditional Chinese to zh-TW
locale.languageTag = 'zh-TW'
if (
locale.languageTag === 'zh-TW' ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the same reason as above—browser compatibility.

locale.languageTag = 'zh-TW'
if (
locale.languageTag === 'zh-TW' ||
locale.languageTag.startsWith('zh-Hant')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

// Cantonese (Yue) to zh-HK
locale.languageTag = 'zh-HK'
// Cantonese (Yue) to yue
locale.languageTag = 'yue'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the two variants on Android and iOS:
yue-Hans and yue-Hant.

Not using yue-Hant directly due to poor browser compatibility.

@auroursa
Copy link
Contributor Author

By converting the language tag from RFC-1766 to RFC-4646, it successfully fixed the post time issue. It’s still not perfect, at least it is on the same level as Japanese display without polyfill.

Android iOS

@auroursa auroursa closed this Dec 21, 2024
@auroursa auroursa reopened this Dec 21, 2024
@auroursa auroursa closed this Dec 21, 2024
@auroursa auroursa deleted the main branch December 21, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Post time in Chinese cannot be localized on Android
1 participant