How to handle internationalization/localization with Gatsby JS?

ぐ巨炮叔叔 提交于 2019-12-10 01:33:04

问题


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 or pages/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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!