mirror of
https://github.com/strapi/strapi.git
synced 2025-09-11 17:46:45 +00:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const _ = require('lodash');
|
|
const { PUBLISHED_AT_ATTRIBUTE } = require('strapi-utils').contentTypes.constants;
|
|
|
|
const { getService } = require('../../utils');
|
|
const fieldMigration = require('./migrations/field');
|
|
|
|
module.exports = () => {
|
|
const contentTypeService = getService('content-types');
|
|
const coreApiService = getService('core-api');
|
|
|
|
Object.values(strapi.contentTypes).forEach(contentType => {
|
|
if (contentTypeService.isLocalized(contentType)) {
|
|
const { attributes, modelName } = contentType;
|
|
|
|
_.set(attributes, 'localizations', {
|
|
writable: true,
|
|
private: false,
|
|
configurable: false,
|
|
visible: false,
|
|
collection: modelName,
|
|
populate: ['id', 'locale', PUBLISHED_AT_ATTRIBUTE],
|
|
});
|
|
|
|
_.set(attributes, 'locale', {
|
|
writable: true,
|
|
private: false,
|
|
configurable: false,
|
|
visible: false,
|
|
type: 'string',
|
|
});
|
|
|
|
coreApiService.addCreateLocalizationAction(contentType);
|
|
}
|
|
});
|
|
|
|
strapi.db.migrations.register(fieldMigration);
|
|
};
|