'use strict'; const { getService } = require('../../utils'); module.exports = async () => { const { decorator } = getService('entity-service-decorator'); const { initDefaultLocale } = getService('locales'); const { sectionsBuilder, actions, conditions, engine } = getService('permissions'); // Entity Service strapi.entityService.decorate(decorator); // Data await initDefaultLocale(); // Sections Builder sectionsBuilder.registerLocalesPropertyHandler(); // Actions await actions.registerI18nActions(); actions.registerI18nActionsHooks(); actions.updateActionsProperties(); // Conditions await conditions.registerI18nConditions(); // Engine/Permissions engine.registerI18nPermissionsHandlers(); // Hooks & Models registerModelsHooks(); }; const registerModelsHooks = () => { Object.values(strapi.models) .filter(model => getService('content-types').isLocalized(model)) .forEach(model => { strapi.db.lifecycles.register({ model: model.uid, async beforeCreate(data) { await getService('localizations').assignDefaultLocale(data); }, }); }); };