@lobehub/chat 0.117.1 → 0.117.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.117.2](https://github.com/lobehub/lobe-chat/compare/v0.117.1...v0.117.2)
6
+
7
+ <sup>Released on **2023-12-28**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix market locale missing.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix market locale missing, closes [#851](https://github.com/lobehub/lobe-chat/issues/851) ([e23ec66](https://github.com/lobehub/lobe-chat/commit/e23ec66))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 0.117.1](https://github.com/lobehub/lobe-chat/compare/v0.117.0...v0.117.1)
6
31
 
7
32
  <sup>Released on **2023-12-27**</sup>
package/README.md CHANGED
@@ -211,11 +211,11 @@ Our marketplace is not just a showcase platform but also a collaborative space.
211
211
  | Recent Submits | Description |
212
212
  | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
213
213
  | [Deployment Specialist Agent](https://chat-preview.lobehub.com/market?agent=deployment-agent)<br/><sup>By **[amitalokbera](https://github.com/amitalokbera)** on **2023-12-27**</sup> | An AI Deployment Specialist is an expert in managing the full deployment lifecycle of software applications, particularly web applications.<br/>`code` `deployment` `software` |
214
+ | [Overview of Art Thesis Experts](https://chat-preview.lobehub.com/market?agent=thesis-overview)<br/><sup>By **[caoyang2002](https://github.com/caoyang2002)** on **2023-12-27**</sup> | Specializing in brief thesis and art criticism<br/>`art` `thesis` `critique` |
214
215
  | [American English Transcreation Expert](https://chat-preview.lobehub.com/market?agent=to-local-english)<br/><sup>By **[doresu](https://github.com/doresu)** on **2023-12-27**</sup> | Rough old editor, seasoned writer, and translator, proficient in translating English directly and transforming it into authentic American English<br/>`translation` `editing` `writing` `translator` |
215
216
  | [Academic Proofreading Expert](https://chat-preview.lobehub.com/market?agent=academic-paragraph-refiner)<br/><sup>By **[Feliks151450](https://github.com/Feliks151450)** on **2023-12-26**</sup> | Highly skilled in advanced research proofreading and language editing, specializing in multiple research fields and proficient in academic English.<br/>`proofreading` `writing` `research` |
216
- | [Flutter Maestro](https://chat-preview.lobehub.com/market?agent=flutter-dev)<br/><sup>By **[kamaravichow](https://github.com/kamaravichow)** on **2023-12-25**</sup> | A developer expert in Flutter framework and Dart programming language.<br/>`flutter` `development` `dart` `programming` `widgets` |
217
217
 
218
- > 📊 Total agents: [<kbd>**81**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
218
+ > 📊 Total agents: [<kbd>**82**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
219
219
 
220
220
  <!-- AGENT LIST -->
221
221
 
package/README.zh-CN.md CHANGED
@@ -184,14 +184,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
184
184
 
185
185
  <!-- AGENT LIST -->
186
186
 
187
- | 最近新增 | 助手说明 |
188
- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
189
- | [部署专家代理](https://chat-preview.lobehub.com/market?agent=deployment-agent)<br/><sup>By **[amitalokbera](https://github.com/amitalokbera)** on **2023-12-27**</sup> | AI 部署专家是管理软件应用的完整部署生命周期的专家,特别是 Web 应用。<br/>`代码` `部署` `容器化` |
190
- | [美式英语转译专家](https://chat-preview.lobehub.com/market?agent=to-local-english)<br/><sup>By **[doresu](https://github.com/doresu)** on **2023-12-27**</sup> | 粗鲁老编辑、资深作家和翻译家,擅长直译英文并转化为地道的美式英语<br/>`翻译` `编辑` `写作` `翻译家` |
191
- | [学术润色专家](https://chat-preview.lobehub.com/market?agent=academic-paragraph-refiner)<br/><sup>By **[Feliks151450](https://github.com/Feliks151450)** on **2023-12-26**</sup> | 高级研究校对及语言编辑,专业于多个研究领域,精通学术英语。<br/>`校对` `写作` `研究` |
192
- | [Flutter 开发专家](https://chat-preview.lobehub.com/market?agent=flutter-dev)<br/><sup>By **[kamaravichow](https://github.com/kamaravichow)** on **2023-12-25**</sup> | 一位精通 Flutter 框架和 Dart 编程语言的开发者<br/>`flutter` `development` `dart` `programming` `widgets` |
193
-
194
- > 📊 Total agents: [<kbd>**81**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
187
+ | 最近新增 | 助手说明 |
188
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
189
+ | [部署专家代理](https://chat-preview.lobehub.com/market?agent=deployment-agent)<br/><sup>By **[amitalokbera](https://github.com/amitalokbera)** on **2023-12-27**</sup> | AI 部署专家是管理软件应用的完整部署生命周期的专家,特别是 Web 应用。<br/>`代码` `部署` `容器化` |
190
+ | [美术论文概述专家](https://chat-preview.lobehub.com/market?agent=thesis-overview)<br/><sup>By **[caoyang2002](https://github.com/caoyang2002)** on **2023-12-27**</sup> | 擅长论文简述与美术评论<br/>`美术` `论文` `评论` |
191
+ | [美式英语转译专家](https://chat-preview.lobehub.com/market?agent=to-local-english)<br/><sup>By **[doresu](https://github.com/doresu)** on **2023-12-27**</sup> | 粗鲁老编辑、资深作家和翻译家,擅长直译英文并转化为地道的美式英语<br/>`翻译` `编辑` `写作` `翻译家` |
192
+ | [学术润色专家](https://chat-preview.lobehub.com/market?agent=academic-paragraph-refiner)<br/><sup>By **[Feliks151450](https://github.com/Feliks151450)** on **2023-12-26**</sup> | 高级研究校对及语言编辑,专业于多个研究领域,精通学术英语。<br/>`校对` `写作` `研究` |
193
+
194
+ > 📊 Total agents: [<kbd>**82**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
195
195
 
196
196
  <!-- AGENT LIST -->
197
197
 
@@ -16,7 +16,7 @@ LobeChat provides additional configuration options during deployment, which can
16
16
  - [`AZURE_API_VERSION`](#azure_api_version)
17
17
  - [Plugin Service](#plugin-service)
18
18
  - [`PLUGINS_INDEX_URL`](#plugins_index_url)
19
- - [`PLUGINS_SETTINGS`](#plugins_settings)
19
+ - [`PLUGIN_SETTINGS`](#plugin_settings)
20
20
  - [Agent Service](#agent-service)
21
21
  - [`AGENTS_INDEX_URL`](#agents_index_url)
22
22
  - [Data Analytics](#data-analytics)
@@ -94,7 +94,7 @@ If you need to use Azure OpenAI to provide model services, you can refer to the
94
94
  - Description: The index address of the LobeChat plugin market. If you have deployed the plugin market service yourself, you can use this variable to override the default plugin market address
95
95
  - Default: `https://chat-plugins.lobehub.com`
96
96
 
97
- ### `PLUGINS_SETTINGS`
97
+ ### `PLUGIN_SETTINGS`
98
98
 
99
99
  - Type: Optional
100
100
  - Description: Used to set the plugin settings, the format is `plugin-identifier:key1=value1;key2=value2`, multiple settings fields are separated by semicolons `;`, multiple plugin settings are separated by commas `,`.
@@ -16,7 +16,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
16
16
  - [`AZURE_API_VERSION`](#azure_api_version)
17
17
  - [插件服务](#插件服务)
18
18
  - [`PLUGINS_INDEX_URL`](#plugins_index_url)
19
- - [`PLUGINS_SETTINGS`](#plugins_settings)
19
+ - [`PLUGIN_SETTINGS`](#plugin_settings)
20
20
  - [角色服务](#角色服务)
21
21
  - [`AGENTS_INDEX_URL`](#agents_index_url)
22
22
  - [数据统计](#数据统计)
@@ -92,7 +92,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
92
92
  - 描述:LobeChat 插件市场的索引地址,如果你自行部署了插件市场的服务,可以使用该变量来覆盖默认的插件市场地址
93
93
  - 默认值:`https://chat-plugins.lobehub.com`
94
94
 
95
- ### `PLUGINS_SETTINGS`
95
+ ### `PLUGIN_SETTINGS`
96
96
 
97
97
  - 类型:可选
98
98
  - 描述:用于配置插件的设置,使用 `插件名:设置字段=设置值` 的格式来配置插件的设置,多个设置字段用英文分号 `;` 隔开,多个插件设置使用英文逗号`,`隔开。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.117.1",
3
+ "version": "0.117.2",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -0,0 +1,54 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { AgentMarket } from './AgentMarket';
4
+
5
+ const baseURL = 'https://chat-agents.lobehub.com';
6
+ describe('AgentMarket', () => {
7
+ it('should return the default index URL when no language is provided', () => {
8
+ const agentMarket = new AgentMarket();
9
+ const url = agentMarket.getAgentIndexUrl();
10
+ expect(url).toBe(baseURL);
11
+ });
12
+
13
+ it('should return the index URL for a supported language', () => {
14
+ const agentMarket = new AgentMarket();
15
+ const url = agentMarket.getAgentIndexUrl('ko-KR');
16
+ expect(url).toBe('https://chat-agents.lobehub.com/index.ko-KR.json');
17
+ });
18
+
19
+ it('should return the zh-CN URL for zh locale', () => {
20
+ const agentMarket = new AgentMarket();
21
+ const url = agentMarket.getAgentIndexUrl('zh' as any);
22
+ expect(url).toBe('https://chat-agents.lobehub.com/index.zh-CN.json');
23
+ });
24
+
25
+ it('should return the default URL for en locale', () => {
26
+ const agentMarket = new AgentMarket();
27
+ const url = agentMarket.getAgentIndexUrl('en' as any);
28
+ expect(url).toBe('https://chat-agents.lobehub.com');
29
+ });
30
+
31
+ it('should return the base URL if the provided language is not supported', () => {
32
+ const agentMarket = new AgentMarket();
33
+ const url = agentMarket.getAgentIndexUrl('fr' as any);
34
+ expect(url).toBe(baseURL);
35
+ });
36
+
37
+ it('should return the agent URL with default language when no language is provided', () => {
38
+ const agentMarket = new AgentMarket();
39
+ const url = agentMarket.getAgentUrl('agent-123');
40
+ expect(url).toBe(`${baseURL}/agent-123.json`);
41
+ });
42
+
43
+ it('should return the agent URL for a supported language', () => {
44
+ const agentMarket = new AgentMarket();
45
+ const url = agentMarket.getAgentUrl('agent-123', 'es-ES');
46
+ expect(url).toBe(`${baseURL}/agent-123.es-ES.json`);
47
+ });
48
+
49
+ it('should return the agent URL without language suffix if the provided language is not supported', () => {
50
+ const agentMarket = new AgentMarket();
51
+ const url = agentMarket.getAgentUrl('agent-123', 'fr' as any);
52
+ expect(url).toBe(`${baseURL}/agent-123.json`);
53
+ });
54
+ });
@@ -1,8 +1,8 @@
1
1
  import urlJoin from 'url-join';
2
2
 
3
3
  import { getServerConfig } from '@/config/server';
4
- import { DEFAULT_LANG, checkLang } from '@/const/locale';
5
- import { Locales } from '@/locales/resources';
4
+ import { DEFAULT_LANG, isLocaleNotSupport } from '@/const/locale';
5
+ import { Locales, normalizeLocale } from '@/locales/resources';
6
6
 
7
7
  export class AgentMarket {
8
8
  private readonly baseUrl: string;
@@ -12,14 +12,14 @@ export class AgentMarket {
12
12
  }
13
13
 
14
14
  getAgentIndexUrl = (lang: Locales = DEFAULT_LANG) => {
15
- if (checkLang(lang)) return this.baseUrl;
15
+ if (isLocaleNotSupport(lang)) return this.baseUrl;
16
16
 
17
- return urlJoin(this.baseUrl, `index.${lang}.json`);
17
+ return urlJoin(this.baseUrl, `index.${normalizeLocale(lang)}.json`);
18
18
  };
19
19
 
20
20
  getAgentUrl = (identifier: string, lang: Locales = DEFAULT_LANG) => {
21
- if (checkLang(lang)) return urlJoin(this.baseUrl, `${identifier}.json`);
21
+ if (isLocaleNotSupport(lang)) return urlJoin(this.baseUrl, `${identifier}.json`);
22
22
 
23
- return urlJoin(this.baseUrl, `${identifier}.${lang}.json`);
23
+ return urlJoin(this.baseUrl, `${identifier}.${normalizeLocale(lang)}.json`);
24
24
  };
25
25
  }
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+
3
+ import { isLocaleNotSupport } from '@/const/locale';
4
+
5
+ import { PluginStore } from './Store';
6
+
7
+ const baseURL = 'https://chat-plugins.lobehub.com';
8
+
9
+ describe('PluginStore', () => {
10
+ it('should return the default index URL when no language is provided', () => {
11
+ const pluginStore = new PluginStore();
12
+ const url = pluginStore.getPluginIndexUrl();
13
+ expect(url).toBe(baseURL);
14
+ });
15
+
16
+ it('should return the index URL for a supported language', () => {
17
+ const pluginStore = new PluginStore();
18
+ const url = pluginStore.getPluginIndexUrl('en-US');
19
+ expect(url).toBe(baseURL);
20
+ });
21
+
22
+ it('should return the base URL if the provided language is not supported', () => {
23
+ const pluginStore = new PluginStore();
24
+ const url = pluginStore.getPluginIndexUrl('fr-FR');
25
+ expect(url).toBe(`${baseURL}/index.fr-FR.json`);
26
+ });
27
+ });
@@ -1,8 +1,8 @@
1
1
  import urlJoin from 'url-join';
2
2
 
3
3
  import { getServerConfig } from '@/config/server';
4
- import { DEFAULT_LANG, checkLang } from '@/const/locale';
5
- import { Locales } from '@/locales/resources';
4
+ import { DEFAULT_LANG, isLocaleNotSupport } from '@/const/locale';
5
+ import { Locales, normalizeLocale } from '@/locales/resources';
6
6
 
7
7
  export class PluginStore {
8
8
  private readonly baseUrl: string;
@@ -12,8 +12,8 @@ export class PluginStore {
12
12
  }
13
13
 
14
14
  getPluginIndexUrl = (lang: Locales = DEFAULT_LANG) => {
15
- if (checkLang(lang)) return this.baseUrl;
15
+ if (isLocaleNotSupport(lang)) return this.baseUrl;
16
16
 
17
- return urlJoin(this.baseUrl, `index.${lang}.json`);
17
+ return urlJoin(this.baseUrl, `index.${normalizeLocale(lang)}.json`);
18
18
  };
19
19
  }
@@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next';
9
9
  import { FORM_STYLE } from '@/const/layoutTokens';
10
10
  import { DEFAULT_SETTINGS } from '@/const/settings';
11
11
  import AvatarWithUpload from '@/features/AvatarWithUpload';
12
- import { localeOptions } from '@/locales/options';
12
+ import { localeOptions } from '@/locales/resources';
13
13
  import { useChatStore } from '@/store/chat';
14
14
  import { useFileStore } from '@/store/file';
15
15
  import { useGlobalStore } from '@/store/global';
@@ -1,9 +1,12 @@
1
- import { localeOptions } from '@/locales/options';
2
- import { Locales } from '@/locales/resources';
1
+ import { Locales, normalizeLocale, supportLocales } from '@/locales/resources';
3
2
 
4
3
  export const DEFAULT_LANG = 'en-US';
5
4
  export const LOBE_LOCALE_COOKIE = 'LOBE_LOCALE';
6
5
 
7
- export const checkLang = (lang: Locales) => {
8
- return lang === DEFAULT_LANG || !localeOptions.map((o) => o.value).includes(lang);
6
+ /**
7
+ * Check if the language is supported
8
+ * @param locale
9
+ */
10
+ export const isLocaleNotSupport = (locale: Locales) => {
11
+ return normalizeLocale(locale) === DEFAULT_LANG || !supportLocales.includes(locale);
9
12
  };
@@ -2,7 +2,7 @@ import { ActionIconGroupItems } from '@lobehub/ui/es/ActionIconGroup';
2
2
  import { LanguagesIcon, Play } from 'lucide-react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
 
5
- import { localeOptions } from '@/locales/options';
5
+ import { localeOptions } from '@/locales/resources';
6
6
 
7
7
  export const useCustomActions = () => {
8
8
  const { t } = useTranslation('chat');
@@ -6,6 +6,7 @@ import { initReactI18next } from 'react-i18next';
6
6
  import { getClientConfig } from '@/config/client';
7
7
  import { DEFAULT_LANG, LOBE_LOCALE_COOKIE } from '@/const/locale';
8
8
  import { COOKIE_CACHE_DAYS } from '@/const/settings';
9
+ import { normalizeLocale } from '@/locales/resources';
9
10
  import { isDev, isOnServerSide } from '@/utils/env';
10
11
 
11
12
  const { I18N_DEBUG, I18N_DEBUG_BROWSER, I18N_DEBUG_SERVER } = getClientConfig();
@@ -17,22 +18,9 @@ export const createI18nNext = (lang?: string) => {
17
18
  .use(LanguageDetector)
18
19
  .use(
19
20
  resourcesToBackend(async (lng: string, ns: string) => {
20
- switch (lng) {
21
- case 'zh-CN':
22
- case 'zh': {
23
- if (isDev) return import(`./default/${ns}`);
21
+ if (isDev && lng === 'zh-CN') return import(`./default/${ns}`);
24
22
 
25
- return import(`@/../locales/zh-CN/${ns}.json`);
26
- }
27
-
28
- case 'en': {
29
- return import(`@/../locales/en-US/${ns}.json`);
30
- }
31
-
32
- default: {
33
- return import(`@/../locales/${lng}/${ns}.json`);
34
- }
35
- }
23
+ return import(`@/../locales/${normalizeLocale(lng)}/${ns}.json`);
36
24
  }),
37
25
  );
38
26
 
@@ -16,3 +16,86 @@ export const locales = [
16
16
 
17
17
  export type DefaultResources = typeof resources;
18
18
  export type Locales = (typeof locales)[number];
19
+
20
+ export const normalizeLocale = (locale: string) => {
21
+ switch (locale) {
22
+ case 'zh-CN':
23
+ case 'zh': {
24
+ return 'zh-CN';
25
+ }
26
+
27
+ case 'en': {
28
+ return 'en-US';
29
+ }
30
+
31
+ default: {
32
+ return locale;
33
+ }
34
+ }
35
+ };
36
+
37
+ type LocaleOptions = {
38
+ label: string;
39
+ value: Locales;
40
+ }[];
41
+
42
+ export const localeOptions: LocaleOptions = [
43
+ {
44
+ label: '简体中文',
45
+ value: 'zh-CN',
46
+ },
47
+ {
48
+ label: '繁體中文',
49
+ value: 'zh-TW',
50
+ },
51
+ {
52
+ label: 'English',
53
+ value: 'en-US',
54
+ },
55
+ {
56
+ label: '日本語',
57
+ value: 'ja-JP',
58
+ },
59
+ {
60
+ label: '한국어',
61
+ value: 'ko-KR',
62
+ },
63
+ {
64
+ label: 'Deutsch',
65
+ value: 'de-DE',
66
+ },
67
+ {
68
+ label: 'Español',
69
+ value: 'es-ES',
70
+ },
71
+ {
72
+ label: 'Français',
73
+ value: 'fr-FR',
74
+ },
75
+ {
76
+ label: 'Português',
77
+ value: 'pt-BR',
78
+ },
79
+ {
80
+ label: 'Русский',
81
+ value: 'ru-RU',
82
+ },
83
+ {
84
+ label: 'Türkçe',
85
+ value: 'tr-TR',
86
+ },
87
+ {
88
+ label: 'Polski',
89
+ value: 'pl-PL',
90
+ },
91
+ {
92
+ label: 'Nederlands',
93
+ value: 'nl-NL',
94
+ },
95
+ {
96
+ label: 'Italiano',
97
+ value: 'it-IT',
98
+ },
99
+ ] as LocaleOptions;
100
+
101
+ export const supportLocales: string[] = [...locales, 'en', 'zh'];
@@ -4,7 +4,7 @@ import { StateCreator } from 'zustand/vanilla';
4
4
 
5
5
  import { chainLangDetect } from '@/chains/langDetect';
6
6
  import { chainTranslate } from '@/chains/translate';
7
- import { supportLocales } from '@/locales/options';
7
+ import { supportLocales } from '@/locales/resources';
8
8
  import { chatService } from '@/services/chat';
9
9
  import { fileService } from '@/services/file';
10
10
  import { imageGenerationService } from '@/services/imageGeneration';
@@ -1,69 +0,0 @@
1
- import type { Locales } from '@/types/locale';
2
-
3
- import { locales } from './resources';
4
-
5
- type LocaleOptions = {
6
- label: string;
7
- value: Locales;
8
- }[];
9
-
10
- export const localeOptions: LocaleOptions = [
11
- {
12
- label: '简体中文',
13
- value: 'zh-CN',
14
- },
15
- {
16
- label: '繁體中文',
17
- value: 'zh-TW',
18
- },
19
- {
20
- label: 'English',
21
- value: 'en-US',
22
- },
23
- {
24
- label: '日本語',
25
- value: 'ja-JP',
26
- },
27
- {
28
- label: '한국어',
29
- value: 'ko-KR',
30
- },
31
- {
32
- label: 'Deutsch',
33
- value: 'de-DE',
34
- },
35
- {
36
- label: 'Español',
37
- value: 'es-ES',
38
- },
39
- {
40
- label: 'Français',
41
- value: 'fr-FR',
42
- },
43
- {
44
- label: 'Português',
45
- value: 'pt-BR',
46
- },
47
- {
48
- label: 'Русский',
49
- value: 'ru-RU',
50
- },
51
- {
52
- label: 'Türkçe',
53
- value: 'tr-TR',
54
- },
55
- {
56
- label: 'Polski',
57
- value: 'pl-PL',
58
- },
59
- {
60
- label: 'Nederlands',
61
- value: 'nl-NL',
62
- },
63
- {
64
- label: 'Italiano',
65
- value: 'it-IT',
66
- },
67
- ] as LocaleOptions;
68
-
69
- export const supportLocales: string[] = [...locales, 'en', 'zh'];