diff --git a/cms/src/api/article/content-types/article/schema.json b/cms/src/api/article/content-types/article/schema.json index 488a18e..8dbee17 100644 --- a/cms/src/api/article/content-types/article/schema.json +++ b/cms/src/api/article/content-types/article/schema.json @@ -11,31 +11,41 @@ "draftAndPublish": true, "populateCreatorFields": true }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, "attributes": { "title": { "type": "string", "required": true, - "maxLength": 160 + "maxLength": 160, + "pluginOptions": { "i18n": { "localized": true } } }, "slug": { "type": "uid", "targetField": "title", - "required": true + "required": true, + "pluginOptions": { "i18n": { "localized": false } } }, "content": { "type": "richtext", - "required": true + "required": true, + "pluginOptions": { "i18n": { "localized": true } } }, "cover": { "type": "media", "multiple": false, - "allowedTypes": ["images"] + "allowedTypes": ["images"], + "pluginOptions": { "i18n": { "localized": false } } }, "category": { "type": "relation", "relation": "manyToOne", "target": "api::category.category", - "inversedBy": "articles" + "inversedBy": "articles", + "pluginOptions": { "i18n": { "localized": false } } } } } diff --git a/cms/src/api/category/content-types/category/schema.json b/cms/src/api/category/content-types/category/schema.json index 2dd1e14..023ad5b 100644 --- a/cms/src/api/category/content-types/category/schema.json +++ b/cms/src/api/category/content-types/category/schema.json @@ -10,22 +10,30 @@ "options": { "draftAndPublish": false }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, "attributes": { "name": { "type": "string", "required": true, - "unique": true + "unique": true, + "pluginOptions": { "i18n": { "localized": true } } }, "slug": { "type": "uid", "targetField": "name", - "required": true + "required": true, + "pluginOptions": { "i18n": { "localized": false } } }, "articles": { "type": "relation", "relation": "oneToMany", "target": "api::article.article", - "mappedBy": "category" + "mappedBy": "category", + "pluginOptions": { "i18n": { "localized": false } } } } } diff --git a/cms/src/index.ts b/cms/src/index.ts index 0e2ff50..a7f3d99 100644 --- a/cms/src/index.ts +++ b/cms/src/index.ts @@ -45,11 +45,25 @@ async function disablePublicSignUp(strapi: Core.Strapi) { } } +/** + * The site content is authored in Italian and English. Strapi ships with only + * the default `it` locale, so the `en` locale is created here if missing. + */ +async function ensureEnglishLocale(strapi: Core.Strapi) { + const locales = strapi.plugin('i18n').service('locales'); + const existing = await locales.find({ where: { code: 'en' } }); + + if (existing.length === 0) { + await locales.create({ code: 'en', name: 'English (en)', isDefault: false }); + } +} + export default { register() {}, async bootstrap({ strapi }: { strapi: Core.Strapi }) { await grantPublicReadAccess(strapi); await disablePublicSignUp(strapi); + await ensureEnglishLocale(strapi); }, }; diff --git a/frontend/app/app.vue b/frontend/app/app.vue index ed9e94c..18056d2 100644 --- a/frontend/app/app.vue +++ b/frontend/app/app.vue @@ -1,3 +1,8 @@ + +