mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-26 22:56:23 -04:00
Fixed: Improve translation loading
This commit is contained in:
@@ -4,6 +4,7 @@ import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||
import getSectionState from 'Utilities/State/getSectionState';
|
||||
import updateSectionState from 'Utilities/State/updateSectionState';
|
||||
import { fetchTranslations as fetchAppTranslations } from 'Utilities/String/translate';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
|
||||
function getDimensions(width, height) {
|
||||
@@ -41,7 +42,12 @@ export const defaultState = {
|
||||
isReconnecting: false,
|
||||
isDisconnected: false,
|
||||
isRestarting: false,
|
||||
isSidebarVisible: !getDimensions(window.innerWidth, window.innerHeight).isSmallScreen
|
||||
isSidebarVisible: !getDimensions(window.innerWidth, window.innerHeight).isSmallScreen,
|
||||
translations: {
|
||||
isFetching: true,
|
||||
isPopulated: false,
|
||||
error: null
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
@@ -53,6 +59,7 @@ export const SAVE_DIMENSIONS = 'app/saveDimensions';
|
||||
export const SET_VERSION = 'app/setVersion';
|
||||
export const SET_APP_VALUE = 'app/setAppValue';
|
||||
export const SET_IS_SIDEBAR_VISIBLE = 'app/setIsSidebarVisible';
|
||||
export const FETCH_TRANSLATIONS = 'app/fetchTranslations';
|
||||
|
||||
export const PING_SERVER = 'app/pingServer';
|
||||
|
||||
@@ -66,6 +73,7 @@ export const setAppValue = createAction(SET_APP_VALUE);
|
||||
export const showMessage = createAction(SHOW_MESSAGE);
|
||||
export const hideMessage = createAction(HIDE_MESSAGE);
|
||||
export const pingServer = createThunk(PING_SERVER);
|
||||
export const fetchTranslations = createThunk(FETCH_TRANSLATIONS);
|
||||
|
||||
//
|
||||
// Helpers
|
||||
@@ -127,6 +135,17 @@ function pingServerAfterTimeout(getState, dispatch) {
|
||||
export const actionHandlers = handleThunks({
|
||||
[PING_SERVER]: function(getState, payload, dispatch) {
|
||||
pingServerAfterTimeout(getState, dispatch);
|
||||
},
|
||||
[FETCH_TRANSLATIONS]: async function(getState, payload, dispatch) {
|
||||
const isFetchingComplete = await fetchAppTranslations();
|
||||
|
||||
dispatch(setAppValue({
|
||||
translations: {
|
||||
isFetching: false,
|
||||
isPopulated: isFetchingComplete,
|
||||
error: isFetchingComplete ? null : 'Failed to load translations from API'
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -114,10 +114,14 @@ export const defaultState = {
|
||||
},
|
||||
{
|
||||
name: 'customFormatScore',
|
||||
columnLabel: translate('CustomFormatScore'),
|
||||
get columnLabel() {
|
||||
return translate('CustomFormatScore');
|
||||
},
|
||||
label: React.createElement(Icon, {
|
||||
name: icons.SCORE,
|
||||
title: translate('CustomFormatScore')
|
||||
get title() {
|
||||
return translate('CustomFormatScore');
|
||||
}
|
||||
}),
|
||||
isVisible: false
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user