Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Rendering react-intl strings to static html #879

Closed
cedricdelpoux opened this issue Nov 17, 2016 · 10 comments
Closed

Rendering react-intl strings to static html #879

cedricdelpoux opened this issue Nov 17, 2016 · 10 comments
Labels

Comments

@cedricdelpoux
Copy link
Contributor

The generated html has untranslated keys instead generated ones.

<span>footer.subscribe_newsletter</span>

So if javascript is disabled, there is no text on my website.
It's very problematic for the seo.

@MoOx
Copy link
Owner

MoOx commented Nov 17, 2016

Pretty sure it's due to your react-intl configuration and default locale used. I don't see how Phenomic can be responsible this kind of issue (but I may miss something).

@dab
Copy link

dab commented Nov 17, 2016

I think we need to rename this issue 😄
Rendering react-intl strings to static html
If I understand it correctly.

@cedricdelpoux cedricdelpoux changed the title react-intl and seo incompatible Rendering react-intl strings to static html Nov 17, 2016
@cedricdelpoux
Copy link
Contributor Author

Ok thank you. I did. I will take a look around react-intl configuration. But it mean that I can generate only one language right ?

@MoOx
Copy link
Owner

MoOx commented Nov 17, 2016

Obviously yes. That's why I recommended you to use distinct page for each languages.

Eg: / is the same as /en/ (you can use a link canonical or something for seo) and /fr/ is french homepage.

@MoOx
Copy link
Owner

MoOx commented Nov 17, 2016

*Yes for HTML. But for JS you can adjust like you want. That said, I won't play with that as sharing an url that can change the content is not a good idea to me.

@cedricdelpoux
Copy link
Contributor Author

The problem is in initialState.

https://github.com/MoOx/phenomic/blob/master/docs/content/docs/usage/intl.md#create-intl-reducer

If I replace it with some data

const initialState = {
  locale: "en",
  messages: {
    "footer.subscribe_newsletter": "Newsletter",
  },
  formats: null,
  defaultLocale: "en",
}

Then my generated html have translated content.

So :

  • I have differents url,
  • I have differents markdowns files with locale metadata.

My question is how can I generate some pages with fr translations and some other pages with en translations ?

Should I use two webpack configs and define a variable with the webpack DefinePlugin to use it in my javascript to set initialState ?

Do you recommend other options ?

I don't see how to handle this using one webpack config.

@MoOx
Copy link
Owner

MoOx commented Nov 17, 2016

On putaindecode.io, we initilize locale by first looking in the url. You should keep a simple solution like that.

@cedricdelpoux
Copy link
Contributor Author

Thank you. I succeed to generate right translations for my /fr/ and /nl/ routes. I kept react-intl and I remove redux things so I could update the documentation.

@MoOx
Copy link
Owner

MoOx commented Nov 18, 2016

Be my guest!

@cedricdelpoux
Copy link
Contributor Author

PR opened

@MoOx MoOx closed this as completed in #887 Dec 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants