Merge pull request #451 from trezor/fix/fetch-locales

Fix/error handling in fetching locales
pull/453/head
Vladimir Volek 5 years ago committed by GitHub
commit 31a9a19385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -86,13 +86,21 @@ export const toggleSidebar = (): WalletAction => ({
export const fetchLocale = (locale: string): ThunkAction => (dispatch: Dispatch): void => {
fetch(`./l10n/${locale}.json`)
.then(response => response.json())
.then(response => {
if (response.ok) {
return response.json();
}
throw Error(response.statusText);
})
.then(messages => {
dispatch({
type: WALLET.SET_LANGUAGE,
locale,
messages,
});
})
.catch(error => {
console.error(error);
});
};

Loading…
Cancel
Save