Skip to content

Commit

Permalink
🐛 fix: use en-US when no suit lang with plugin index
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Sep 10, 2023
1 parent 168ed20 commit 4e9668d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/const/url.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { localeOptions } from '@/locales/options';
import { Locales } from '@/locales/resources';

import pkg from '../../package.json';
Expand All @@ -13,7 +14,7 @@ export const PLUGINS_INDEX_URL =
process.env.PLUGINS_INDEX_URL ?? 'https://chat-plugins.lobehub.com/index';

export const getPluginIndexJSON = (lang: Locales = 'en-US', baseUrl = PLUGINS_INDEX_URL) => {
if (lang === 'en-US') return baseUrl;
if (lang === 'en-US' || !localeOptions.map((o) => o.value).includes(lang)) return baseUrl;

return `${baseUrl}.${lang}.json`;
};
Expand Down
2 changes: 1 addition & 1 deletion src/locales/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type LocaleOptions = SelectProps['options'] &
value: Locales;
}[];

export const options: LocaleOptions = [
export const localeOptions: LocaleOptions = [
{
label: '简体中文',
value: 'zh-CN',
Expand Down
4 changes: 2 additions & 2 deletions src/pages/settings/features/Settings/Common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SelectWithImg from '@/components/SelectWithImg';
import { FORM_STYLE } from '@/const/layoutTokens';
import { DEFAULT_SETTINGS } from '@/const/settings';
import AvatarWithUpload from '@/features/AvatarWithUpload';
import { options } from '@/locales/options';
import { localeOptions } from '@/locales/options';
import { globalSelectors, useGlobalStore } from '@/store/global';
import { useSessionStore } from '@/store/session';
import { ConfigKeys } from '@/types/settings';
Expand Down Expand Up @@ -113,7 +113,7 @@ const Common = memo(() => {
onChange={(e) => {
changeLanguage(e);
}}
options={options}
options={localeOptions}
/>
),
label: t('settingTheme.lang.title'),
Expand Down

0 comments on commit 4e9668d

Please sign in to comment.