Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(gatsby-source-strapi): SingleType internationalization bug #376

Open
NevenaKirova opened this issue Feb 22, 2023 · 3 comments
Open

bug(gatsby-source-strapi): SingleType internationalization bug #376

NevenaKirova opened this issue Feb 22, 2023 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@NevenaKirova
Copy link

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)

@NevenaKirova NevenaKirova added the bug Something isn't working label Feb 22, 2023
@moonmeister
Copy link
Contributor

Hey Nevena, sorry for the delay. I'm not familiar with this plugin personally. @laurenskling Helps maintain this one. Hopefully, he can jump in and help. If not feel free to open up a PR and I'll do my best to review but will trust you on much of it.

@laurenskling
Copy link
Contributor

I don't use i18n myself, so I have no clue how it works. Hopefully someone else in the community can shine light on this?

@moonmeister moonmeister changed the title gatsby-source-strapi: SingleType internationalization bug bug(gatsby-source-strapi): SingleType internationalization bug Mar 5, 2023
@laurenskling laurenskling added the help wanted Extra attention is needed label Mar 6, 2023
@SylvainGibert
Copy link

SylvainGibert commented Sep 28, 2023

hello there, is this still an issue ? i am currently on the same use case and it doesn't works too !

Please let me know if you have a solution,

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants