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

Investigate Converting TemplateWrapper to Component that extends React.Component #3

Closed
mccrodp opened this issue Feb 20, 2018 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@mccrodp
Copy link
Owner

mccrodp commented Feb 20, 2018

From Gatsby i18n plugin I've brought over the TemplateWrapper to this repo from here.

Whereas the "Using Contentful" repo uses a React.Component as shown here.

I've used the TemplateWrapper from the i18n plugin as I need to pass those arguments for the i18n strings. There's probably a way I can do this with the Component method?

Also, this method has issue as it's designed to work with the static pages, not dynamic content from a CMS that uses templates, so in that way, our dynamic content: Products and Categories that use templates do not pass the i18n strings, so I need to do a hack for them here: https://github.com/mccrodp/gatsby-contentful-i18n/blob/master/src/layouts/index.js#L21

if (i18nMessages === undefined) {
    if (langKey === 'de') {
      i18nMessages = messagesDe
    } else {
      i18nMessages = messagesEn
    }
  }
@mccrodp mccrodp added the help wanted Extra attention is needed label Feb 20, 2018
@romeboards
Copy link
Contributor

Seeing the issue with dynamically created pages not getting the i18n strings - this seems like an issue where gatsby-plugin-i18n isn't applying the specialized layout (e.g. src/layouts/en-US.js) to a dynamically created path?

Should that be something accounted for by the plugin, then?

@mccrodp
Copy link
Owner Author

mccrodp commented Feb 22, 2018

Hey @romeboards, thanks a lot for chipping in here. Yes, I think you're right. I think it is related to what I mention on this issue on the plugin, but I don't know so much about it other than that at the moment. Would be great if you had anything to share on that, would love to address it. angeloocana/gatsby-plugin-i18n#12 (comment) Cheers

@mccrodp mccrodp changed the title Improve current usage of TemplateWrapper or convert to Component Investigate Converting TemplateWrapper to Component that extends React.Component Mar 28, 2018
@mccrodp
Copy link
Owner Author

mccrodp commented Jan 21, 2019

Completed this for Gatsby v2 when adding a custom Layout component: b861f86

@mccrodp mccrodp closed this as completed Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants