Skip to content

Commit

Permalink
bit ugly
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Nov 6, 2024
1 parent 856cda6 commit 7de6218
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import { getSystemLanguage } from '/app/redux/shell'
import type { DropdownOption } from '@opentrons/components'
import type { Dispatch } from '/app/redux/types'

type ArrayElement<
ArrayType extends readonly unknown[]
> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never

Check failure on line 32 in app/src/organisms/Desktop/SystemLanguagePreferenceModal/index.tsx

View workflow job for this annotation

GitHub Actions / js checks

Array type using 'readonly T[]' is forbidden for non-simple types. Use 'ReadonlyArray<T>' instead

Check failure on line 32 in app/src/organisms/Desktop/SystemLanguagePreferenceModal/index.tsx

View workflow job for this annotation

GitHub Actions / js checks

Array type using 'readonly T[]' is forbidden for non-simple types. Use 'ReadonlyArray<T>' instead

export function SystemLanguagePreferenceModal(): JSX.Element | null {
const { i18n, t } = useTranslation(['app_settings', 'shared', 'branded'])
const enableLocalization = useFeatureFlag('enableLocalization')
Expand Down Expand Up @@ -83,15 +87,18 @@ export function SystemLanguagePreferenceModal(): JSX.Element | null {
useEffect(() => {
if (systemLanguage != null) {
// prefer match entire locale, then match just language e.g. zh-Hant and zh-CN
const matchSystemLanguage: () => string | null = () => {
const matchSystemLanguage: () => ArrayElement<
typeof LANGUAGES
> | null = () => {
try {
return (
LANGUAGES.find(lng => lng.value === systemLanguage) ??
LANGUAGES.find(
lng =>
new Intl.Locale(lng.value).language ===
new Intl.Locale(systemLanguage).language
)
) ??
null
)
} catch (error: unknown) {
// Sometimes the language that we get from the shell will not be something
Expand Down

0 comments on commit 7de6218

Please sign in to comment.