-
Notifications
You must be signed in to change notification settings - Fork 339
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
Support for More Specific Locale Codes (e.g., en-US, zh-TW) #2417
Comments
I've prepared a patch that might help solve this issue as below. Please let me know if you would like to take a look, and maybe I can submit a pull request for review? diff --git a/assets/modules/i18n.ts b/assets/modules/i18n.ts
index 2d2cb1b..52ea64a 100644
--- a/assets/modules/i18n.ts
+++ b/assets/modules/i18n.ts
@@ -10,9 +10,15 @@ export const install = (app: App) => {
},
),
);
+
+ const userLang = navigator.language;
+ const shortLang = userLang.slice(0, 2);
+
+ const locale = messages.hasOwnProperty(userLang) ? userLang : (messages.hasOwnProperty(shortLang) ? shortLang : 'en');
+
const i18n = createI18n({
legacy: false,
- locale: navigator.language.slice(0, 2),
+ locale: locale,
fallbackLocale: "en",
messages,
}); |
Yes please send a PR. You don't need to provide EN. It's already set as fallback. I am away this week will check Monday. Thanks! |
Also try reading https://kazupon.github.io/vue-i18n/guide/fallback.html#explicit-fallback-with-decision-maps. It might be better solution. |
Sent here: #2418, thanks. |
Is your feature request related to a problem? Please describe.
The current locale support only includes two-letter language codes like
en
andzh
. This doesn't account for more specific locale codes such asen-US
,zh-CN
, orzh-TW
.Describe the solution you'd like
I would like the project to extend its locale support to include more specific locale codes. This would make the application more versatile and better suited for international audiences.
Additional context
I am looking forward to this feature being implemented and would be happy to provide a
zh-TW
translation to supplement the existingzh
(which is actuallyzh-CN
).The text was updated successfully, but these errors were encountered: