Skip to content

Commit

Permalink
Merge pull request #3546 from open-webui/dev
Browse files Browse the repository at this point in the history
refac: language detection
  • Loading branch information
tjbck committed Jun 30, 2024
2 parents 4900ac5 5ee7da5 commit 66182ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 66182ba

Please sign in to comment.