i changed the controller configuration in strapi using this function :
module.exports = ({ strapi }) => ({
async find(ctx) {
if (ctx.query.locale === 'all') {
const localesArray = await strapi.plugins.i18n.services.locales.find()
const locales = localesArray.map(locale => locale.code);
let data = [];
for (let locale of locales) {
ctx.query.locale = locale;
const response = await super.find(ctx);
if (response) data.push(response.data);
};
const meta = {};
return { data, meta };
}
return await super.find(ctx);
}
});
so i can get all the locales. It is kind of working but only for two pages. For the rest of the pages it either returns only the default locale or i can no longer see it in the Graphql schema. The problem with the data missing from graphql happens when i add
pluginOptions: {
i18n: {
locale: 'all',
},
},
to the singleType configuration, which is needed, so i can get all locales.
{
singularName: 'privacy-policy',
queryParams: {
populate: '*',
},
pluginOptions: {
i18n: {
locale: 'all',
},
},
},
{
singularName: 'about',
queryParams: {
populate: '*',
},
pluginOptions: {
i18n: {
locale: 'all',
},
},
},
{
singularName: 'landing-page',
queryParams: {
populate: {
background_image: {
populate: '*',
locale: 'all',
},
partners_logos: {
populate: '*',
locale: 'all',
},
integrations_logos: {
populate: '*',
locale: 'all',
},
benefits: {
populate: '*',
locale: 'all',
},
services: {
populate: '*',
locale: 'all',
},
news_details: {
populate: '*',
locale: 'all',
},
testimonials: {
populate: '*',
locale: 'all',
},
},
pluginOptions: {
i18n: {
locale: 'all',
},
},
},
Those are three examples for one that is working, one that is only returning the default locale and, one that is not appearing in graphql after this configuration (landing-page)
i changed the controller configuration in strapi using this function :
module.exports = ({ strapi }) => ({
async find(ctx) {
if (ctx.query.locale === 'all') {
const localesArray = await strapi.plugins.i18n.services.locales.find()
const locales = localesArray.map(locale => locale.code);
}
});
so i can get all the locales. It is kind of working but only for two pages. For the rest of the pages it either returns only the default locale or i can no longer see it in the Graphql schema. The problem with the data missing from graphql happens when i add
to the singleType configuration, which is needed, so i can get all locales.
Those are three examples for one that is working, one that is only returning the default locale and, one that is not appearing in graphql after this configuration (landing-page)