-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🌐 feat(i18n): overhaul translation system & add languages #145
Conversation
Revamp the existing translation system, simplifying management and adding several new languages. The new system reads from TOML files in the `/i18n` directory and improves template structures. It also enhances customisation options and robustness by providing fallbacks and modularity. - Implement a new, streamlined translation macro. - Load translations from `/i18n` TOML files. - Remove redundant configuration requirements. - Refactor templates to align with new i18n system. - Add support for Hindi, Japanese, Russian, Portuguese, Chinese, Italian, German, Ukranian, Korean, and French languages. - Credit Thomas Weitzel (@thomasweitzel) for inspiration.
Oh my "All translated strings are now optional, falling back to English." That alone is absolutely worth pursuing this! I will be following up with doing the same! |
Finally found a way to do it! |
Regarding the "machine translation" did you find a convenient way to automatically pull the translations into files? or was it copy paste into google translate. (which is how I did most of mine) |
I asked GPT-4 for the translations, giving it the I validated the output (like the joined 404 keys, or the metadata in context) to make minor adjustments (with GPT-4), and finally I translated the keys on Google Translate and/or DeepL to verify it was reasonable. |
I just tested using this: https://github.com/mgruner/deepl-api-rs I signed up for the free account, and it seems to work: echo "Recent Posts" | deepl translate --source-language EN --target-language FR | cat -
Messages récents There is a 500,000 monthly character limit, so no idea how quickly I would hit that limit. For a small site I would think your unlikely to hit the limit very fast. After I implement what you have done here, I would like to try automating some of the translations, possibly via a bash script. I am going to see if there is a way to automate the use of GPT-4 as well, no idea if they have an API yet. |
TL;DR
Overhauled the translation system, loading strings from/i18n
TOML files.Overview
This PR aims to significantly improve the localisation system, streamline template structures, and add multiple new languages. It offers a more user-friendly approach to managing translations and addresses several issues related to the readability and maintainability of the codebase.
Advantages
Ease of Translation Management: Moved translations to an
/i18n
folder, allowing easier addition and modification.User customisation: Theme users can easily override or add new translation strings without touching the core logic.
Flexible default language: Users can set a default language other than English.
Robustness: Missing translation strings will fall back to English, reducing the chance of errors.
Reduced configuration: Eliminated the need for
config.extra.languages
and copying/pasting strings into config files.Modularity: Enhanced modularity by isolating translation and language-switching logic.
Simplicity: Simplified the translation macro, making it easier to read and maintain.
Performance: Potentially minor performance gains by reducing conditional checks.
Also fixes #134.
Changes
/i18n
directory, allowing for easy management.language_strings
variable, aligning them with the improved translation system. All translated strings are now optional, falling back to English.content.html
and integrated its logic intopage.html
. (Certain macros should be partials #141)Credit
This overhaul was inspired by Thomas Weitzel's (@thomasweitzel) work on the i18n of his Zolarwind theme.