Skip to content

Commit f3a30b5

Browse files
authored
feat: changed minimum of 2 locales to minimum of 1 (#6406)
* feat: changed minimum of 2 locales to minimum of 1 * feat: only show i18n editor toggle if there are multiple locales
1 parent 514984a commit f3a30b5

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

packages/decap-cms-core/src/components/Editor/EditorInterface.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ class EditorInterface extends Component {
238238

239239
const previewEnabled = isPreviewEnabled(collection, entry);
240240

241-
const collectionI18nEnabled = hasI18n(collection);
242241
const { locales, defaultLocale } = getI18nInfo(this.props.collection);
242+
const collectionI18nEnabled = hasI18n(collection) && locales.length > 1;
243243
const editorProps = {
244244
collection,
245245
entry,

packages/decap-cms-core/src/constants/__tests__/configSchema.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,19 @@ describe('config', () => {
494494
}).toThrowError(`'i18n.locales[1]' must NOT have more than 10 characters`);
495495
});
496496

497+
it('should throw error when locales is less than 1 items', () => {
498+
expect(() => {
499+
validateConfig(
500+
merge({}, validConfig, {
501+
i18n: {
502+
structure: 'multiple_folders',
503+
locales: [],
504+
},
505+
}),
506+
);
507+
}).toThrowError(`'i18n.locales' must NOT have fewer than 1 items`);
508+
});
509+
497510
it('should allow valid locales strings', () => {
498511
expect(() => {
499512
validateConfig(

packages/decap-cms-core/src/constants/configSchema.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const i18n = {
2020
structure: { type: 'string', enum: Object.values(I18N_STRUCTURE) },
2121
locales: {
2222
type: 'array',
23-
minItems: 2,
23+
minItems: 1,
2424
items: localeType,
2525
uniqueItems: true,
2626
},

0 commit comments

Comments
 (0)