Skip to content

Commit

Permalink
Merge pull request #685 from RockefellerArchiveCenter/development
Browse files Browse the repository at this point in the history
Toggle on automatic language detection
  • Loading branch information
p-galligan authored Mar 18, 2024
2 parents 99f577d + 5ec445f commit 1d399f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
17 changes: 8 additions & 9 deletions src/components/i18n/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import { detect, fromNavigator } from "@lingui/detect-locale";
import { detect, fromNavigator } from "@lingui/detect-locale";
import { I18nProvider } from '@lingui/react'
import { i18n } from '@lingui/core'
import { messages as deMessages } from '../../locales/de/messages'
Expand Down Expand Up @@ -26,14 +26,13 @@ i18n.load({
});

// Set language from browser.
// const DEFAULT_FALLBACK = () => "en";
// const MESSAGES_LOADED = Object.keys(i18n._messages)
// let result = detect(fromNavigator(), DEFAULT_FALLBACK).split('-')[0]
// if (!MESSAGES_LOADED.includes(result)) {
// result = DEFAULT_FALLBACK()
//}
// i18n.activate(result, '')
i18n.activate('en')
const DEFAULT_FALLBACK = () => "en";
const MESSAGES_LOADED = Object.keys(i18n._messages)
let result = detect(fromNavigator(), DEFAULT_FALLBACK).split('-')[0]
if (!MESSAGES_LOADED.includes(result)) {
result = DEFAULT_FALLBACK()
}
i18n.activate(result, '')

export const I18nApp = ({ReactComponent}) => {
return (
Expand Down
Loading

0 comments on commit 1d399f5

Please sign in to comment.