Skip to content

Commit aaf4110

Browse files
committed
Merge branch 'main' of https://github.com/lobehub/lobe-chat
2 parents 66f322a + 69600da commit aaf4110

File tree

5 files changed

+91
-55
lines changed

5 files changed

+91
-55
lines changed

.github/ISSUE_TEMPLATE/1_bug_report.yml

+20-23
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ description: 'Report an bug'
33
title: '[Bug] '
44
labels: ['🐛 Bug']
55
body:
6-
- type: dropdown
6+
- type: checkboxes
77
attributes:
88
label: '📦 Environment'
99
options:
10-
- Unselected
11-
- Official
12-
- Official Preview
13-
- Vercel / Zeabur / Sealos
14-
- Docker
15-
- Other
10+
- label: 'Official'
11+
- label: 'Official Preview'
12+
- label: 'Vercel / Zeabur / Sealos'
13+
- label: 'Docker'
14+
- label: 'Other'
1615
validations:
1716
required: true
1817
- type: input
@@ -21,30 +20,28 @@ body:
2120
validations:
2221
required: true
2322

24-
- type: dropdown
23+
- type: checkboxes
2524
attributes:
2625
label: '💻 Operating System'
2726
options:
28-
- Unselected
29-
- Windows
30-
- macOS
31-
- Ubuntu
32-
- Other Linux
33-
- iOS
34-
- Android
35-
- Other
27+
- label: 'Windows'
28+
- label: 'macOS'
29+
- label: 'Ubuntu'
30+
- label: 'Other Linux'
31+
- label: 'iOS'
32+
- label: 'Android'
33+
- label: 'Other'
3634
validations:
3735
required: true
38-
- type: dropdown
36+
- type: checkboxes
3937
attributes:
4038
label: '🌐 Browser'
4139
options:
42-
- Unselected
43-
- Chrome
44-
- Edge
45-
- Safari
46-
- Firefox
47-
- Other
40+
- label: 'Chrome'
41+
- label: 'Edge'
42+
- label: 'Safari'
43+
- label: 'Firefox'
44+
- label: 'Other'
4845
validations:
4946
required: true
5047
- type: textarea

.github/ISSUE_TEMPLATE/1_bug_report_cn.yml

+20-23
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ description: '反馈一个问题缺陷'
33
title: '[Bug] '
44
labels: ['🐛 Bug']
55
body:
6-
- type: dropdown
6+
- type: checkboxes
77
attributes:
88
label: '📦 部署环境'
99
options:
10-
- 待选择
11-
- Official
12-
- Official Preview
13-
- Vercel / Zeabur / Sealos
14-
- Docker
15-
- Other
10+
- label: 'Official'
11+
- label: 'Official Preview'
12+
- label: 'Vercel / Zeabur / Sealos'
13+
- label: 'Docker'
14+
- label: 'Other'
1615
validations:
1716
required: true
1817
- type: input
@@ -21,30 +20,28 @@ body:
2120
validations:
2221
required: true
2322

24-
- type: dropdown
23+
- type: checkboxes
2524
attributes:
2625
label: '💻 系统环境'
2726
options:
28-
- 待选择
29-
- Windows
30-
- macOS
31-
- Ubuntu
32-
- Other Linux
33-
- iOS
34-
- Android
35-
- Other
27+
- label: 'Windows'
28+
- label: 'macOS'
29+
- label: 'Ubuntu'
30+
- label: 'Other Linux'
31+
- label: 'iOS'
32+
- label: 'Android'
33+
- label: 'Other'
3634
validations:
3735
required: true
38-
- type: dropdown
36+
- type: checkboxes
3937
attributes:
4038
label: '🌐 浏览器'
4139
options:
42-
- 待选择
43-
- Chrome
44-
- Edge
45-
- Safari
46-
- Firefox
47-
- Other
40+
- label: 'Chrome'
41+
- label: 'Edge'
42+
- label: 'Safari'
43+
- label: 'Firefox'
44+
- label: 'Other'
4845
validations:
4946
required: true
5047
- type: textarea

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
# Changelog
44

5+
### [Version 0.161.13](https://github.com/lobehub/lobe-chat/compare/v0.161.12...v0.161.13)
6+
7+
<sup>Released on **2024-05-24**</sup>
8+
9+
<br/>
10+
11+
<details>
12+
<summary><kbd>Improvements and Fixes</kbd></summary>
13+
14+
</details>
15+
16+
<div align="right">
17+
18+
[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
19+
20+
</div>
21+
522
### [Version 0.161.12](https://github.com/lobehub/lobe-chat/compare/v0.161.11...v0.161.12)
623

724
<sup>Released on **2024-05-23**</sup>

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lobehub/chat",
3-
"version": "0.161.12",
3+
"version": "0.161.13",
44
"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.",
55
"keywords": [
66
"framework",
@@ -158,6 +158,7 @@
158158
"remark": "^14.0.3",
159159
"remark-gfm": "^3.0.1",
160160
"remark-html": "^15.0.2",
161+
"resolve-accept-language": "^3.1.4",
161162
"rtl-detect": "^1.1.2",
162163
"semver": "^7.6.2",
163164
"sharp": "^0.33.4",

src/layout/GlobalProvider/index.tsx

+32-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import dynamic from 'next/dynamic';
2-
import { cookies } from 'next/headers';
3-
import { FC, ReactNode } from 'react';
2+
import { cookies, headers } from 'next/headers';
3+
import { FC, PropsWithChildren } from 'react';
4+
import { resolveAcceptLanguage } from 'resolve-accept-language';
45

56
import { getDebugConfig } from '@/config/debug';
67
import { getServerFeatureFlagsValue } from '@/config/featureFlags';
@@ -10,6 +11,7 @@ import {
1011
LOBE_THEME_NEUTRAL_COLOR,
1112
LOBE_THEME_PRIMARY_COLOR,
1213
} from '@/const/theme';
14+
import { locales } from '@/locales/resources';
1315
import { getServerGlobalConfig } from '@/server/globalConfig';
1416
import { ServerConfigStoreProvider } from '@/store/serverConfig';
1517
import { getAntdLocale } from '@/utils/locale';
@@ -31,11 +33,27 @@ if (process.env.NODE_ENV === 'development') {
3133
}
3234
}
3335

34-
interface GlobalLayoutProps {
35-
children: ReactNode;
36-
}
36+
const parserFallbackLang = () => {
37+
/**
38+
* The arguments are as follows:
39+
*
40+
* 1) The HTTP accept-language header.
41+
* 2) The available locales (they must contain the default locale).
42+
* 3) The default locale.
43+
*/
44+
let fallbackLang: string = resolveAcceptLanguage(
45+
headers().get('accept-language') || '',
46+
// Invalid locale identifier 'ar'. A valid locale should follow the BCP 47 'language-country' format.
47+
locales.map((locale) => (locale === 'ar' ? 'ar-EG' : locale)),
48+
'en-US',
49+
);
50+
// if match the ar-EG then fallback to ar
51+
if (fallbackLang === 'ar-EG') fallbackLang = 'ar';
52+
53+
return fallbackLang;
54+
};
3755

38-
const GlobalLayout = async ({ children }: GlobalLayoutProps) => {
56+
const GlobalLayout = async ({ children }: PropsWithChildren) => {
3957
// get default theme config to use with ssr
4058
const cookieStore = cookies();
4159
const appearance = cookieStore.get(LOBE_THEME_APPEARANCE);
@@ -44,15 +62,21 @@ const GlobalLayout = async ({ children }: GlobalLayoutProps) => {
4462

4563
// get default locale config to use with ssr
4664
const defaultLang = cookieStore.get(LOBE_LOCALE_COOKIE);
47-
const antdLocale = await getAntdLocale(defaultLang?.value);
65+
const fallbackLang = parserFallbackLang();
66+
67+
// if it's a new user, there's no cookie
68+
// So we need to use the fallback language parsed by accept-language
69+
const userLocale = defaultLang?.value || fallbackLang;
70+
71+
const antdLocale = await getAntdLocale(userLocale);
4872

4973
// get default feature flags to use with ssr
5074
const serverFeatureFlags = getServerFeatureFlagsValue();
5175
const serverConfig = getServerGlobalConfig();
5276
const isMobile = isMobileDevice();
5377
return (
5478
<StyleRegistry>
55-
<Locale antdLocale={antdLocale} defaultLang={defaultLang?.value}>
79+
<Locale antdLocale={antdLocale} defaultLang={userLocale}>
5680
<AppTheme
5781
defaultAppearance={appearance?.value}
5882
defaultNeutralColor={neutralColor?.value as any}

0 commit comments

Comments
 (0)