Fix Chinese language (#2050)

* fix chinese

* remove console.log
This commit is contained in:
Utku 2024-02-04 23:52:26 +03:00 committed by GitHub
parent d475153544
commit 2ff1ffcb9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 6 deletions

4
Cargo.lock generated
View file

@ -7558,7 +7558,7 @@ dependencies = [
[[package]]
name = "sd-core"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"aovec",
"async-channel",
@ -7697,7 +7697,7 @@ dependencies = [
[[package]]
name = "sd-desktop"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"axum",
"directories 5.0.1",

View file

@ -28,8 +28,8 @@ const LANGUAGE_OPTIONS = [
{ value: 'es', label: 'Español' },
{ value: 'fr', label: 'Français' },
{ value: 'tr', label: 'Türkçe' },
{ value: 'zh-CN', label: '中文(简体)' },
{ value: 'zh-TW', label: '中文(繁體)' }
{ value: 'zh_CN', label: '中文(简体)' },
{ value: 'zh_TW', label: '中文(繁體)' }
];
export const Component = () => {
@ -201,8 +201,8 @@ export const Component = () => {
<Select
value={i18n.language}
onChange={(e) => {
// add "i18nextLng" key to localStorage and set it to the selected language
i18n.changeLanguage(e);
// add "i18nextLng" key to localStorage and set it to the selected language
localStorage.setItem('i18nextLng', e);
}}
containerClassName="h-[30px] whitespace-nowrap"

View file

@ -13,8 +13,14 @@ i18n
// for all options read: https://www.i18next.com/overview/configuration-options
.init({
resources,
load: 'languageOnly',
detection: {
// We need to convert due to ES syntactical rules (e.g. ch-TW -> ch_TW) and vite's virtual module stuff -_-
// NOTE: This whole issue sounds very error-prone...
convertDetectedLanguage: (lng) => lng.replace('-', '_')
},
// debug: true,
fallbackLng: 'en',
nonExplicitSupportedLngs: true,
ns: ['common'],
fallbackNS: 'common',
defaultNS: 'common'