hexo i18n support transformation
In my work, most of the documents I search and refer to are in English. So, I thought of update my blog to support multiple languages, and at the same time, consider it as a good start for the new year.
Objectives
The goals for this transformation are twofold:
- Global support for multiple languages (Chinese and English).
- Switching between different languages seamlessly.
Exploration
Although hexo and the NexT theme I used before have i18n support, it mainly covers fixed content like navigation and menus and lacks comprehensive global support.
After searching online, I found roughly three solutions:
No. | Solution | Pros | Cons |
---|---|---|---|
1 | Create an en folder under _post to store English articles. |
Simple and clear, no additional changes required. | The blog homepage will display all articles. Additional development is needed for language-specific display. |
2 | Use the hexo-generator-i18n plugin. | Simple, just install and configure. | 1. The plugin has not been updated for a long time. 2. Additional development is required after installing the plugin, such as language switching. |
3 | Create two separate websites for different language versions. | Relatively simple and completely independent. | Some configuration and code redundancy between the two websites. |
Considering the ease of operation and maintenance (mainly laziness, not wanting to develop further), I decided to go with the third solution.
During my research, I also came across the Fluid theme, which felt comfortable, so I took this opportunity to upgrade it as well.
Transformation
Under the folder of the new blog, I used hexo init
to create two blogs for each language. The directory structure is as follows:
1 |
|
For configurations related to the Fluid theme and multilingual support, please refer to: A Detailed Account of Hexo Blog Migration and Multilingual Site Transformation. The article provides a comprehensive and detailed guide, allowing for a step-by-step implementation.
Regarding the deployment aspect, you may refer to: Hexo Adding Multilingual Support “Internationalization i18n”. The deployment process has been consolidated into a shell
script, making it a more straightforward read and facilitating the deployment process.
Fundamentally, the addition involves creating an en
folder in the compiled files, storing English content. Consequently, you can access it through https://{your-blog}/en
.
1 |
|
Migration
Migrating hexo is the easiest task in this process. Simply copy the necessary files from the source
directory to the new location.
Other Considerations
The remaining task is translation work. Let’s explore whether we can leverage the power of Google Translate or GPT.
Finally, feel free to visit my updated blog for some recreational reading.
(Translated by ChatGPT)