[英]Generate i18n static HTML using Parcel bundler
I'm using Parceljs to bundle html and js.我正在使用 Parceljs 捆绑 html 和 js。 It works really well with less configuration.
它在配置较少的情况下工作得非常好。
Now, I'm facing i18n issue.现在,我面临 i18n 问题。 Google recommends using different URLs for each language version of a page.
Google 建议为页面的每种语言版本使用不同的 URL。 https://support.google.com/webmasters/answer/182192
https://support.google.com/webmasters/answer/182192
So, I want to generate language specific static html from one template like below.所以,我想从一个模板生成语言特定的 static html ,如下所示。
.
├── dist
│ ├── ja
│ │ └── index.html
│ ├── app.c328ef1a.js
│ └── index.html
├── i18n
│ ├── default.json
│ └── ja.json
└── source
├── app.js
└── index.html
source/index.html来源/索引.html
<html>
<body>
<h1>__TITLE__</h1>
<script src="/app.js"></script>
</body>
</html>
i18n/default.json i18n/default.json
{
"__TITLE__": "Hello world!"
}
i18n/ja.json i18n/ja.json
{
"__TITLE__": "こんにちは 世界!"
}
Is there a way to deal with this issue using parceljs?有没有办法使用 parceljs 处理这个问题? Or, should I write a code for prebuild?
或者,我应该为预构建编写代码吗?
Thank you.谢谢你。
Self answer:自我回答:
I found a great answer here .我在这里找到了一个很好的答案。 It mentions node-static-i18n package that generates i18n static HTML.
它提到了 node-static-i18n package 生成 i18n static HTML。 This tool isn't a plugin of parceljs, but it seems to be able to generate expected results.
这个工具不是parceljs的插件,但似乎能产生预期的结果。
Welcome yet another answer.欢迎另一个答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.