Skip to content

Added support for Hugo Multilingual Mode - #55

Closed
0lbap wants to merge 1 commit into
AsahiLinux:mainfrom
0lbap:main
Closed

0lbap wants to merge 1 commit into
AsahiLinux:mainfrom
0lbap:main

Conversation

@0lbap

@0lbap 0lbap commented Dec 21, 2023

Copy link
Copy Markdown

I added support for both English and French languages. I've followed Hugo's official documentation on multilingual mode closely to implement these changes. However, please feel free to review and provide feedback, as there's always a chance I might have overlooked something or made some typos.

More languages can be added in the config.toml file. The default language is set to English, and you can access the different languages with the URL (for example, the /about page is in English, but /fr/about page is in french).

Template text translation is done through the i18n function, which can be shorten by simply writing T. This uses the i18n/en.toml and i18n/fr.toml translation files (a list of key/value pairs). See this page for more information.

The content directory now contains two directories en and fr, in which the Markdown content is manually translated.

Here are some steps to add a new language :

  1. Declare your new language in config.toml by adding it under the [languages] and defining the contentDir, languageCode, languageName and weight
  2. Create your associated translation file (for example, i18n/fr.toml). You can use the English file as a base
  3. Create your language content directory (for example, content/fr/). You can use the English directory as a base
  4. Now you can start translating !

This marks my first open source contribution, and I'm eager to learn and improve.

Signed-off-by: 0lbap <pablo.laviron@gmail.com>
@Jibec

Jibec commented Feb 19, 2025

Copy link
Copy Markdown

please refer to #67 for discussion on this nice PR

@0lbap 0lbap closed this Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants