Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
2aecd7d0
Commit
2aecd7d0
authored
Jul 01, 2024
by
Jonathan Rohde
Browse files
Merge branch 'refs/heads/dev' into feat/sqlalchemy-instead-of-peewee
# Conflicts: # backend/requirements.txt
parents
5391f4c1
f3c1ff9e
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
11 deletions
+28
-11
src/lib/i18n/locales/zh-CN/translation.json
src/lib/i18n/locales/zh-CN/translation.json
+3
-3
src/lib/utils/index.ts
src/lib/utils/index.ts
+13
-1
src/routes/+layout.svelte
src/routes/+layout.svelte
+12
-7
No files found.
src/lib/i18n/locales/zh-CN/translation.json
View file @
2aecd7d0
...
...
@@ -261,8 +261,8 @@
"File"
:
"文件"
,
"File Mode"
:
"文件模式"
,
"File not found."
:
"文件未找到。"
,
"Filter is now globally disabled"
:
""
,
"Filter is now globally enabled"
:
""
,
"Filter is now globally disabled"
:
"
过滤器已全局禁用
"
,
"Filter is now globally enabled"
:
"
过滤器已全局启用
"
,
"Filters"
:
"过滤器"
,
"Fingerprint spoofing detected: Unable to use initials as avatar. Defaulting to default profile image."
:
"检测到指纹伪造:无法使用姓名缩写作为头像。默认使用默认个人形象。"
,
"Fluidly stream large external response chunks"
:
"流畅地传输外部大型响应块数据"
,
...
...
@@ -281,7 +281,7 @@
"Generate Image"
:
"生成图像"
,
"Generating search query"
:
"生成搜索查询"
,
"Generation Info"
:
"生成信息"
,
"Global"
:
""
,
"Global"
:
"
全局
"
,
"Good Response"
:
"点赞此回答"
,
"Google PSE API Key"
:
"Google PSE API 密钥"
,
"Google PSE Engine Id"
:
"Google PSE 引擎 ID"
,
...
...
src/lib/utils/index.ts
View file @
2aecd7d0
...
...
@@ -525,7 +525,7 @@ export const extractSentences = (text) => {
});
// Split the modified text into sentences based on common punctuation marks, avoiding these blocks
let
sentences
=
text
.
split
(
/
(?<
=
[
.!?
])\s
+/
);
let
sentences
=
text
.
match
(
/
[^
.?!
]
+
[
.!?
]
+
[\]
)'"`’”
]
*|.
+/
g
);
// Restore code blocks and process sentences
sentences
=
sentences
.
map
((
sentence
)
=>
{
...
...
@@ -746,3 +746,15 @@ export const extractFrontmatter = (content) => {
return
frontmatter
;
};
// Function to determine the best matching language
export
const
bestMatchingLanguage
=
(
supportedLanguages
,
preferredLanguages
,
defaultLocale
)
=>
{
const
languages
=
supportedLanguages
.
map
((
lang
)
=>
lang
.
code
);
const
match
=
preferredLanguages
.
map
((
prefLang
)
=>
languages
.
find
((
lang
)
=>
lang
.
startsWith
(
prefLang
)))
.
find
(
Boolean
);
console
.
log
(
languages
,
preferredLanguages
,
match
,
defaultLocale
);
return
match
||
defaultLocale
;
};
src/routes/+layout.svelte
View file @
2aecd7d0
...
...
@@ -31,6 +31,7 @@
import { WEBUI_BASE_URL, WEBUI_HOSTNAME } from '$lib/constants';
import i18n, { initI18n, getLanguages } from '$lib/i18n';
import { bestMatchingLanguage } from '$lib/utils';
setContext('i18n', i18n);
...
...
@@ -91,13 +92,17 @@
// Initialize i18n even if we didn't get a backend config,
// so `/error` can show something that's not `undefined`.
const languages = await getLanguages();
const browserLanguage = navigator.languages
? navigator.languages[0]
: navigator.language || navigator.userLanguage;
initI18n(languages.includes(browserLanguage) ? browserLanguage : backendConfig?.default_locale);
initI18n();
if (!localStorage.locale) {
const languages = await getLanguages();
const browserLanguages = navigator.languages
? navigator.languages
: [navigator.language || navigator.userLanguage];
const lang = backendConfig.default_locale
? backendConfig.default_locale
: bestMatchingLanguage(languages, browserLanguages, 'en-US');
$i18n.changeLanguage(lang);
}
if (backendConfig) {
// Save Backend Status to Store
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment