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
5ee7da54
Commit
5ee7da54
authored
Jun 29, 2024
by
Timothy J. Baek
Browse files
refac: language detection
parent
4b0c422e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
src/lib/utils/index.ts
src/lib/utils/index.ts
+6
-1
No files found.
src/lib/utils/index.ts
View file @
5ee7da54
...
@@ -750,6 +750,11 @@ export const extractFrontmatter = (content) => {
...
@@ -750,6 +750,11 @@ export const extractFrontmatter = (content) => {
// Function to determine the best matching language
// Function to determine the best matching language
export
const
bestMatchingLanguage
=
(
supportedLanguages
,
preferredLanguages
,
defaultLocale
)
=>
{
export
const
bestMatchingLanguage
=
(
supportedLanguages
,
preferredLanguages
,
defaultLocale
)
=>
{
const
languages
=
supportedLanguages
.
map
((
lang
)
=>
lang
.
code
);
const
languages
=
supportedLanguages
.
map
((
lang
)
=>
lang
.
code
);
const
match
=
preferredLanguages
.
find
((
lang
)
=>
languages
.
includes
(
lang
));
const
match
=
preferredLanguages
.
map
((
prefLang
)
=>
languages
.
find
((
lang
)
=>
lang
.
startsWith
(
prefLang
)))
.
find
(
Boolean
);
console
.
log
(
languages
,
preferredLanguages
,
match
,
defaultLocale
);
return
match
||
defaultLocale
;
return
match
||
defaultLocale
;
};
};
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