简体   繁体   中英

Generate i18n static HTML using Parcel bundler

I'm using Parceljs to bundle html and js. It works really well with less configuration.

Now, I'm facing i18n issue. Google recommends using different URLs for each language version of a page. https://support.google.com/webmasters/answer/182192

So, I want to generate language specific static html from one template like below.

.
├── dist
│   ├── ja
│   │   └── index.html
│   ├── app.c328ef1a.js
│   └── index.html
├── i18n
│   ├── default.json
│   └── ja.json
└── source
    ├── app.js
    └── index.html

source/index.html

<html>

<body>
  <h1>__TITLE__</h1>
  <script src="/app.js"></script>
</body>

</html>

i18n/default.json

{
  "__TITLE__": "Hello world!"
}

i18n/ja.json

{
  "__TITLE__": "こんにちは 世界!"
}

Is there a way to deal with this issue using 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. This tool isn't a plugin of parceljs, but it seems to be able to generate expected results.

Welcome yet another answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM