Skip to content

Commit

Permalink
Bug 1924188: Update language selector dropdown
Browse files Browse the repository at this point in the history
Language selector dropdown should now pre-select the language in a wider range of cases. The selector previously only pre-selected English, Chinese, or Japanese if the browser language was set to en, zh, or ja exactly. The logic should now handle languages we don't support, as well as subsets of languages, such as en-us.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1924188
  • Loading branch information
rebeccaalpert committed Feb 2, 2021
1 parent b034265 commit 02c622f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { TFunction } from 'i18next';
import i18next, { TFunction } from 'i18next';

import { Dropdown } from '../utils';
import {
Expand All @@ -24,7 +24,8 @@ const LanguagePreferencesModal = (props: LanguagePreferencesModalProps) => {
}));
const initLang =
localStorage.getItem('bridge/language') ||
langOptions.find((lang) => lang.lang === i18n.language)?.lang;
// handles languages we support, languages we don't support, and subsets of languages we support (such as en-us, zh-cn, etc.)
i18next.languages.find((lang) => langOptions.some((langOption) => langOption.lang === lang));
const [language, setLanguage] = React.useState(initLang);
const { close } = props;
const submit: React.FormEventHandler<HTMLFormElement> = (e) => {
Expand Down

0 comments on commit 02c622f

Please sign in to comment.