@3nvi/gatsby-starter-intl 中文文档教程

发布于 3年前 浏览 24 项目主页 更新于 3年前

gatsby-starter-intl

一个展示如何轻松处理网站内部化的 gatsby starter。 它利用 @3nvi/gatsby-theme-intl 在引擎盖下以自动化所有日常过程:

  • creating the necessary localized URLs
  • adding proper SEO support on all pages
  • handling translations
  • changing languages while retaining the page the user's at

此外,它:

  • utilizes the netlify plugin in order to create proper _headers and _redirects files.
  • utilizes the sitemap plugin in order to create a sitemap for the website.

有关引擎盖下发生的事情的更多信息,请查看 gatby-theme-intl, 以及这个项目的 gatsby-config.js

Installation

由于 starter 在 lerna monorepo 中(而不是在单独的独立 repo 中),安装需要运行额外的 npm run bootstrap 命令:

git clone https://github.com/3nvi/gatsby-intl intl-site
cd intl-site/packages/gatsby-starter-intl
npm i
npm run start

Known Issues

在撰写本文时,Netlify 有一个如果发送了多个 Accept-Language,则语言重定向将不起作用。 您可以在此处< /a>。

要验证在发送单个 Accept-Language 值时重定向有效,您可以仅使用一种语言发出请求:

curl -H 'Accept-Language: de' -L -v -s https://YOUR_SITE.netlify.com 1> /dev/null

并期望重定向有效

License

MIT

gatsby-starter-intl

A gatsby starter showcasing how to easily handle the internalization of a website. It utilizes @3nvi/gatsby-theme-intl under the hood in order to automate all mundane processes of:

  • creating the necessary localized URLs
  • adding proper SEO support on all pages
  • handling translations
  • changing languages while retaining the page the user's at

Moreover, it:

  • utilizes the netlify plugin in order to create proper _headers and _redirects files.
  • utilizes the sitemap plugin in order to create a sitemap for the website.

For more information on what happens under the hood check out gatby-theme-intl, as well as this project's gatsby-config.js

Installation

Due to the fact that the starter is in a lerna monorepo (and not in a separate standalone repo), installation requires running the additional npm run bootstrap command:

git clone https://github.com/3nvi/gatsby-intl intl-site
cd intl-site/packages/gatsby-starter-intl
npm i
npm run start

Known Issues

At the moment of writing, Netlify has a bug where if more than one Accept-Languages are sent, then the language redirects don’t work. You can track the related issue here.

To verify that redirects do work when a single Accept-Language value is sent, you can issue a request with just one language:

curl -H 'Accept-Language: de' -L -v -s https://YOUR_SITE.netlify.com 1> /dev/null

and expect the redirects to work

License

MIT

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文