mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 07:33:17 +00:00
[i18n] don't add locale in settings when it already exists (#9776)
This commit is contained in:
parent
92c98cdc2a
commit
7d46206d9b
@ -1,6 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { request } from 'strapi-helper-plugin';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import get from 'lodash/get';
|
||||
import { getTrad } from '../../utils';
|
||||
import { ADD_LOCALE } from '../constants';
|
||||
|
||||
@ -22,12 +23,21 @@ const addLocale = async ({ code, name, isDefault }) => {
|
||||
|
||||
return data;
|
||||
} catch (e) {
|
||||
strapi.notification.toggle({
|
||||
type: 'warning',
|
||||
message: { id: 'notification.error' },
|
||||
});
|
||||
const message = get(e, 'response.payload.message', null);
|
||||
|
||||
return e;
|
||||
if (message && message.includes('already exists')) {
|
||||
strapi.notification.toggle({
|
||||
type: 'warning',
|
||||
message: { id: getTrad('Settings.locales.modal.create.alreadyExist') },
|
||||
});
|
||||
} else {
|
||||
strapi.notification.toggle({
|
||||
type: 'warning',
|
||||
message: { id: 'notification.error' },
|
||||
});
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
"Settings.locales.modal.create.defaultLocales.loading": "Loading the available locales...",
|
||||
"Settings.locales.modal.create.confirmation": "Add locale",
|
||||
"Settings.locales.modal.create.success": "Locale successfully added",
|
||||
"Settings.locales.modal.create.alreadyExist": "This locale already exists",
|
||||
"Settings.locales.modal.locales.label": "Locales",
|
||||
"Settings.locales.modal.edit.locales.label": "Locales",
|
||||
"Settings.locales.modal.locales.displayName": "Locale display name",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user