1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00

Fixed: Improve translation loading

(cherry picked from commit 73c5ec1da4dd00301e1b0dddbcea37590a99b045)
This commit is contained in:
Mark McDowall
2023-07-18 20:20:27 -07:00
committed by Bogdan
parent e691253419
commit ed5c063127
16 changed files with 315 additions and 99 deletions
+4 -4
View File
@@ -7,7 +7,7 @@ function ErrorPage(props) {
const {
version,
isLocalStorageSupported,
hasTranslationsError,
translationsError,
moviesError,
customFiltersError,
tagsError,
@@ -21,8 +21,8 @@ function ErrorPage(props) {
if (!isLocalStorageSupported) {
errorMessage = 'Local Storage is not supported or disabled. A plugin or private browsing may have disabled it.';
} else if (hasTranslationsError) {
errorMessage = 'Failed to load translations from API';
} else if (translationsError) {
errorMessage = getErrorMessage(translationsError, 'Failed to load translations from API');
} else if (moviesError) {
errorMessage = getErrorMessage(moviesError, 'Failed to load movie from API');
} else if (customFiltersError) {
@@ -55,7 +55,7 @@ function ErrorPage(props) {
ErrorPage.propTypes = {
version: PropTypes.string.isRequired,
isLocalStorageSupported: PropTypes.bool.isRequired,
hasTranslationsError: PropTypes.bool.isRequired,
translationsError: PropTypes.object,
moviesError: PropTypes.object,
customFiltersError: PropTypes.object,
tagsError: PropTypes.object,
+20 -10
View File
@@ -3,7 +3,7 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { createSelector } from 'reselect';
import { saveDimensions, setIsSidebarVisible } from 'Store/Actions/appActions';
import { fetchTranslations, saveDimensions, setIsSidebarVisible } from 'Store/Actions/appActions';
import { fetchCustomFilters } from 'Store/Actions/customFilterActions';
import { fetchMovies } from 'Store/Actions/movieActions';
import { fetchMovieCollections } from 'Store/Actions/movieCollectionActions';
@@ -53,6 +53,7 @@ const selectIsPopulated = createSelector(
(state) => state.settings.importLists.isPopulated,
(state) => state.system.status.isPopulated,
(state) => state.movieCollections.isPopulated,
(state) => state.app.translations.isPopulated,
(
customFiltersIsPopulated,
tagsIsPopulated,
@@ -62,7 +63,8 @@ const selectIsPopulated = createSelector(
indexerFlagsIsPopulated,
importListsIsPopulated,
systemStatusIsPopulated,
movieCollectionsIsPopulated
movieCollectionsIsPopulated,
translationsIsPopulated
) => {
return (
customFiltersIsPopulated &&
@@ -73,7 +75,8 @@ const selectIsPopulated = createSelector(
indexerFlagsIsPopulated &&
importListsIsPopulated &&
systemStatusIsPopulated &&
movieCollectionsIsPopulated
movieCollectionsIsPopulated &&
translationsIsPopulated
);
}
);
@@ -88,6 +91,7 @@ const selectErrors = createSelector(
(state) => state.settings.importLists.error,
(state) => state.system.status.error,
(state) => state.movieCollections.error,
(state) => state.app.translations.error,
(
customFiltersError,
tagsError,
@@ -97,7 +101,8 @@ const selectErrors = createSelector(
indexerFlagsError,
importListsError,
systemStatusError,
movieCollectionsError
movieCollectionsError,
translationsError
) => {
const hasError = !!(
customFiltersError ||
@@ -108,7 +113,8 @@ const selectErrors = createSelector(
indexerFlagsError ||
importListsError ||
systemStatusError ||
movieCollectionsError
movieCollectionsError ||
translationsError
);
return {
@@ -121,7 +127,8 @@ const selectErrors = createSelector(
indexerFlagsError,
importListsError,
systemStatusError,
movieCollectionsError
movieCollectionsError,
translationsError
};
}
);
@@ -183,6 +190,9 @@ function createMapDispatchToProps(dispatch, props) {
dispatchFetchStatus() {
dispatch(fetchStatus());
},
dispatchFetchTranslations() {
dispatch(fetchTranslations());
},
onResize(dimensions) {
dispatch(saveDimensions(dimensions));
},
@@ -217,6 +227,7 @@ class PageConnector extends Component {
this.props.dispatchFetchImportLists();
this.props.dispatchFetchUISettings();
this.props.dispatchFetchStatus();
this.props.dispatchFetchTranslations();
}
}
@@ -232,7 +243,6 @@ class PageConnector extends Component {
render() {
const {
hasTranslationsError,
isPopulated,
hasError,
dispatchFetchMovies,
@@ -244,15 +254,15 @@ class PageConnector extends Component {
dispatchFetchImportLists,
dispatchFetchUISettings,
dispatchFetchStatus,
dispatchFetchTranslations,
...otherProps
} = this.props;
if (hasTranslationsError || hasError || !this.state.isLocalStorageSupported) {
if (hasError || !this.state.isLocalStorageSupported) {
return (
<ErrorPage
{...this.state}
{...otherProps}
hasTranslationsError={hasTranslationsError}
/>
);
}
@@ -273,7 +283,6 @@ class PageConnector extends Component {
}
PageConnector.propTypes = {
hasTranslationsError: PropTypes.bool.isRequired,
isPopulated: PropTypes.bool.isRequired,
hasError: PropTypes.bool.isRequired,
isSidebarVisible: PropTypes.bool.isRequired,
@@ -287,6 +296,7 @@ PageConnector.propTypes = {
dispatchFetchImportLists: PropTypes.func.isRequired,
dispatchFetchUISettings: PropTypes.func.isRequired,
dispatchFetchStatus: PropTypes.func.isRequired,
dispatchFetchTranslations: PropTypes.func.isRequired,
onSidebarVisibleChange: PropTypes.func.isRequired
};
@@ -21,24 +21,34 @@ const SIDEBAR_WIDTH = parseInt(dimensions.sidebarWidth);
const links = [
{
iconName: icons.MOVIE_CONTINUING,
title: translate('Movies'),
get title() {
return translate('Movies');
},
to: '/',
alias: '/movies',
children: [
{
title: translate('AddNew'),
get title() {
return translate('AddNew');
},
to: '/add/new'
},
{
title: translate('ImportLibrary'),
get title() {
return translate('ImportLibrary');
},
to: '/add/import'
},
{
title: translate('Collections'),
get title() {
return translate('Collections');
},
to: '/collections'
},
{
title: translate('Discover'),
get title() {
return translate('Discover');
},
to: '/add/discover'
}
]
@@ -46,26 +56,36 @@ const links = [
{
iconName: icons.CALENDAR,
title: translate('Calendar'),
get title() {
return translate('Calendar');
},
to: '/calendar'
},
{
iconName: icons.ACTIVITY,
title: translate('Activity'),
get title() {
return translate('Activity');
},
to: '/activity/queue',
children: [
{
title: translate('Queue'),
get title() {
return translate('Queue');
},
to: '/activity/queue',
statusComponent: QueueStatusConnector
},
{
title: translate('History'),
get title() {
return translate('History');
},
to: '/activity/history'
},
{
title: translate('Blocklist'),
get title() {
return translate('Blocklist');
},
to: '/activity/blocklist'
}
]
@@ -73,55 +93,81 @@ const links = [
{
iconName: icons.SETTINGS,
title: translate('Settings'),
get title() {
return translate('Settings');
},
to: '/settings',
children: [
{
title: translate('MediaManagement'),
get title() {
return translate('MediaManagement');
},
to: '/settings/mediamanagement'
},
{
title: translate('Profiles'),
get title() {
return translate('Profiles');
},
to: '/settings/profiles'
},
{
title: translate('Quality'),
get title() {
return translate('Quality');
},
to: '/settings/quality'
},
{
title: translate('CustomFormats'),
get title() {
return translate('CustomFormats');
},
to: '/settings/customformats'
},
{
title: translate('Indexers'),
get title() {
return translate('Indexers');
},
to: '/settings/indexers'
},
{
title: translate('DownloadClients'),
get title() {
return translate('DownloadClients');
},
to: '/settings/downloadclients'
},
{
title: translate('Lists'),
get title() {
return translate('Lists');
},
to: '/settings/importlists'
},
{
title: translate('Connect'),
get title() {
return translate('Connect');
},
to: '/settings/connect'
},
{
title: translate('Metadata'),
get title() {
return translate('Metadata');
},
to: '/settings/metadata'
},
{
title: translate('Tags'),
get title() {
return translate('Tags');
},
to: '/settings/tags'
},
{
title: translate('General'),
get title() {
return translate('General');
},
to: '/settings/general'
},
{
title: translate('UI'),
get title() {
return translate('UI');
},
to: '/settings/ui'
}
]
@@ -129,32 +175,46 @@ const links = [
{
iconName: icons.SYSTEM,
title: translate('System'),
get title() {
return translate('System');
},
to: '/system/status',
children: [
{
title: translate('Status'),
get title() {
return translate('Status');
},
to: '/system/status',
statusComponent: HealthStatusConnector
},
{
title: translate('Tasks'),
get title() {
return translate('Tasks');
},
to: '/system/tasks'
},
{
title: translate('Backup'),
get title() {
return translate('Backup');
},
to: '/system/backup'
},
{
title: translate('Updates'),
get title() {
return translate('Updates');
},
to: '/system/updates'
},
{
title: translate('Events'),
get title() {
return translate('Events');
},
to: '/system/events'
},
{
title: translate('LogFiles'),
get title() {
return translate('LogFiles');
},
to: '/system/logs/files'
}
]