Internationalization
From v1.2.0, H2O-ac supports internationalization, which can be controlled by site and page level.
Field data
All field data for internationalization are stored in /_data/locales/. The files are named with the common languages as follows:
| Filename | Language |
|---|---|
zh-Hans.yml | Simiplied Chinese |
zh-Hant.yml | Traditional Chinese |
en.yml | English |
ja.yml | Japanese |
The supported fields mainly includes cover, panel, footer, post, archives, categories and langs. Please refer to Source Code for more details.
Site config
It's recommended to enable all possible languages and set the most used language for posts to default language.
languages: ['zh-Hans', 'zh-Hant', 'en', 'ja'] # The internationalization list
default_lang: 'zh-Hans' # Default languageIf you want to write a post or page with a non-default language, please define the language used in meta information of the post or the page. The following is an example with English:
lang: enIf one post or page has more than one language version, you can define them in meta information to info readers like below:
langs: [en, zh-Hans]
Because the page with different languages will be generated automatically, the urls for different languages have to follow the rules. Otherwise, a 404 error will happen.
For example, the homepage of default language is /index.html:
- If Simplied Chinese is the default language, the homepage with English will be
/en/index.html. The homepage with Traditional Chinese will be/zh-Hant/index.html. - If English is the default language, the homepage with Simplied Chinese will be
/zh-Hans/index.html.
WARNING
- The pages with the default language could not be accessed with subdirectory!!!
- If the language used in post or page is not listed in
site.languages, a 404 error will happen.