问题
I would like to publish my static site in various locals around the world with localized content.
How does one accomplish this?
回答1:
There's a community plugin gatsby-plugin-i18n that you could "use […] with react-intl, i18next, or any other i18n library. This plugin do not translate messages, it just creates routes for each language, and you can use different layouts for each language if you want to." (quoting the plugin README).
Its first release is dated 30th of August 2017, so maybe you already stumbled upon it in the meantime?!
回答2:
I recently added a default Gatsby starter with features of multi-language url routes and browser language detection. (demo)
gatsby-starter-default-intl
Features:
Localization (Multilanguage) provided by react-intl.
Automatic redirection based on user's preferred language in browser provided by browser-lang.
Support multi-language url routes within a single page component. That means you don't have to create separate pages such as
pages/en/index.js
orpages/ko/index.js
.Based on gatsby-starter-default with least modification.
回答3:
fyi: there is a blog post describing step by step how to use that community plugin gatsby-plugin-i18n in combination with i18next (react-i18next)
来源:https://stackoverflow.com/questions/45489980/how-to-handle-internationalization-localization-with-gatsby-js