-
-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10396 from DestinyItemManager/lang
Better handle language change
- Loading branch information
Showing
14 changed files
with
125 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { currentAccountSelector } from 'app/accounts/selectors'; | ||
import { getDefinitions as getDefinitionsD1 } from 'app/destiny1/d1-definitions'; | ||
import { getDefinitions } from 'app/destiny2/d2-definitions'; | ||
import { settingsSelector } from 'app/dim-api/selectors'; | ||
import { t } from 'app/i18next-t'; | ||
import { clearStores } from 'app/inventory/actions'; | ||
import { useThunkDispatch } from 'app/store/thunk-dispatch'; | ||
import i18next from 'i18next'; | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import Select, { mapToOptions } from './Select'; | ||
import { useSetSetting } from './hooks'; | ||
|
||
const languageOptions = mapToOptions({ | ||
de: 'Deutsch', | ||
en: 'English', | ||
es: 'Español (España)', | ||
'es-mx': 'Español (México)', | ||
fr: 'Français', | ||
it: 'Italiano', | ||
ko: '한국어', | ||
pl: 'Polski', | ||
'pt-br': 'Português (Brasil)', | ||
ru: 'Русский', | ||
ja: '日本語', | ||
'zh-cht': '繁體中文', // Chinese (Traditional) | ||
'zh-chs': '简体中文', // Chinese (Simplified) | ||
}); | ||
|
||
export default function LanguageSetting() { | ||
const dispatch = useThunkDispatch(); | ||
const settings = useSelector(settingsSelector); | ||
const currentAccount = useSelector(currentAccountSelector); | ||
const setSetting = useSetSetting(); | ||
|
||
const changeLanguage = async (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
const language = e.target.value; | ||
await i18next.changeLanguage(language); | ||
setSetting('language', language); | ||
if (currentAccount?.destinyVersion === 2) { | ||
await dispatch(getDefinitions(true)); | ||
} else if (currentAccount?.destinyVersion === 1) { | ||
await dispatch(getDefinitionsD1(false)); | ||
} | ||
dispatch(clearStores()); | ||
}; | ||
|
||
return ( | ||
<Select | ||
label={t('Settings.Language')} | ||
name="language" | ||
value={settings.language} | ||
options={languageOptions} | ||
onChange={changeLanguage} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!doctype html> | ||
<html lang=""> | ||
<html lang="en"> | ||
<!-- DIM v<%= version %>, built <%= date %> --> | ||
|
||
<head> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters