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
66182bac
Unverified
Commit
66182bac
authored
Jun 29, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Jun 29, 2024
Browse files
Merge pull request #3546 from open-webui/dev
refac: language detection
parents
4900ac51
5ee7da54
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
CHANGELOG.md
CHANGELOG.md
+0
-1
src/lib/utils/index.ts
src/lib/utils/index.ts
+6
-1
No files found.
CHANGELOG.md
View file @
66182bac
...
...
@@ -5,7 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on
[
Keep a Changelog
](
https://keepachangelog.com/en/1.1.0/
)
,
and this project adheres to
[
Semantic Versioning
](
https://semver.org/spec/v2.0.0.html
)
.
## [0.3.7] - 2024-06-29
### Added
...
...
src/lib/utils/index.ts
View file @
66182bac
...
...
@@ -750,6 +750,11 @@ export const extractFrontmatter = (content) => {
// Function to determine the best matching language
export
const
bestMatchingLanguage
=
(
supportedLanguages
,
preferredLanguages
,
defaultLocale
)
=>
{
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
;
};
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