diff --git a/src/components/OpenFileDialog/utils.js b/src/components/OpenFileDialog/utils.js index 43726a99e..40941724e 100644 --- a/src/components/OpenFileDialog/utils.js +++ b/src/components/OpenFileDialog/utils.js @@ -18,66 +18,65 @@ export const AOTypeMap = { const NO_TYPE = 'NO_TYPE' -export const getTranslatedString = (type, key) => { - const texts = { - [NO_TYPE]: { - modalTitle: i18n.t('Open'), - loadingText: i18n.t('Loading'), - errorTitle: i18n.t("Couldn't load items"), - errorText: i18n.t( - 'There was a problem loading items. Try again or contact your system administrator.' - ), - noDataText: i18n.t('No items found. Create a new to get started.'), - noFilteredDataText: i18n.t( - "No items found. Try adjusting your search or filter options to find what you're looking for." - ), - newButtonLabel: i18n.t('Create new'), - }, - - [AO_TYPE_VISUALIZATION]: { - modalTitle: i18n.t('Open a visualization'), - loadingText: i18n.t('Loading visualizations'), - errorTitle: i18n.t("Couldn't load visualizations"), - errorText: i18n.t( - 'There was a problem loading visualizations. Try again or contact your system administrator.' - ), - noDataText: i18n.t( - 'No visualizations found. Click New visualization to get started.' - ), - noFilteredDataText: i18n.t( - "No visualizations found. Try adjusting your search or filter options to find what you're looking for." - ), - newButtonLabel: i18n.t('New visualization'), - }, - [AO_TYPE_MAP]: { - modalTitle: i18n.t('Open a map'), - loadingText: i18n.t('Loading maps'), - errorTitle: i18n.t("Couldn't load maps"), - errorText: i18n.t( - 'There was a problem loading maps. Try again or contact your system administrator.' - ), - noDataText: i18n.t('No maps found. Click New map to get started.'), - noFilteredDataText: i18n.t( - "No maps found. Try adjusting your search or filter options to find what you're looking for." - ), - newButtonLabel: i18n.t('New map'), - }, - [AO_TYPE_EVENT_VISUALIZATION]: { - modalTitle: i18n.t('Open a line list'), - loadingText: i18n.t('Loading line lists'), - errorTitle: i18n.t("Couldn't load line lists"), - errorText: i18n.t( - 'There was a problem loading line lists. Try again or contact your system administrator.' - ), - noDataText: i18n.t( - 'No line lists found. Click New line list to get started.' - ), - noFilteredDataText: i18n.t( - "No line lists found. Try adjusting your search or filter options to find what you're looking for." - ), - newButtonLabel: i18n.t('New line list'), - }, - } +const texts = { + [NO_TYPE]: { + modalTitle: i18n.t('Open'), + loadingText: i18n.t('Loading'), + errorTitle: i18n.t("Couldn't load items"), + errorText: i18n.t( + 'There was a problem loading items. Try again or contact your system administrator.' + ), + noDataText: i18n.t('No items found. Create a new to get started.'), + noFilteredDataText: i18n.t( + "No items found. Try adjusting your search or filter options to find what you're looking for." + ), + newButtonLabel: i18n.t('Create new'), + }, - return (texts[type] || texts[NO_TYPE])[key] + [AO_TYPE_VISUALIZATION]: { + modalTitle: i18n.t('Open a visualization'), + loadingText: i18n.t('Loading visualizations'), + errorTitle: i18n.t("Couldn't load visualizations"), + errorText: i18n.t( + 'There was a problem loading visualizations. Try again or contact your system administrator.' + ), + noDataText: i18n.t( + 'No visualizations found. Click New visualization to get started.' + ), + noFilteredDataText: i18n.t( + "No visualizations found. Try adjusting your search or filter options to find what you're looking for." + ), + newButtonLabel: i18n.t('New visualization'), + }, + [AO_TYPE_MAP]: { + modalTitle: i18n.t('Open a map'), + loadingText: i18n.t('Loading maps'), + errorTitle: i18n.t("Couldn't load maps"), + errorText: i18n.t( + 'There was a problem loading maps. Try again or contact your system administrator.' + ), + noDataText: i18n.t('No maps found. Click New map to get started.'), + noFilteredDataText: i18n.t( + "No maps found. Try adjusting your search or filter options to find what you're looking for." + ), + newButtonLabel: i18n.t('New map'), + }, + [AO_TYPE_EVENT_VISUALIZATION]: { + modalTitle: i18n.t('Open a line list'), + loadingText: i18n.t('Loading line lists'), + errorTitle: i18n.t("Couldn't load line lists"), + errorText: i18n.t( + 'There was a problem loading line lists. Try again or contact your system administrator.' + ), + noDataText: i18n.t( + 'No line lists found. Click New line list to get started.' + ), + noFilteredDataText: i18n.t( + "No line lists found. Try adjusting your search or filter options to find what you're looking for." + ), + newButtonLabel: i18n.t('New line list'), + }, } + +export const getTranslatedString = (type, key) => + (texts[type] || texts[NO_TYPE])[key]