Skip to content

Commit

Permalink
Fix Chinese language (spacedriveapp#2050)
Browse files Browse the repository at this point in the history
* fix chinese

* remove console.log
  • Loading branch information
utkubakir committed Feb 4, 2024
1 parent d475153 commit 2ff1ffc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions interface/app/$libraryId/settings/client/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion interface/app/I18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 2ff1ffc

Please sign in to comment.