💾 Archived View for gemini.hitchhiker-linux.org › gemlog › internationalizing_zond.gmi captured on 2023-04-26 at 13:11:47. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

➡️ Next capture (2023-06-14)

-=-=-=-=-=-=-

Internationalizing Zond

2022-11-13

My capsule generator, Zond, hasn't seen a lot of new features lately because it's been pretty feature complete, at least for my own usage. I have been keeping on top of tracking newer versions of it's dependencies as they come out. I also periodically run `clippy` as new versions of the compiler come out to check it against all of the latest lints, which over time tends to accumulate a number of changes making the code more idiomatic. But other than that it hasn't really changed much and has just been a rock solid boring tool for me.

A little while ago an issue was filed on the repository regarding translations. Specifically, the code had been translated to provide output in Italian instead of English, and he was wondering if I would be interested in incorporating the work into my branch or if he should maintain his own fork. Even though I wrote the tool for my own needs, obviously I'm thrilled to have someone else find it useful. I'm also thrilled to see more content appear on Gemini in other languages. So of course I wanted to incorporate his work into the code.

Choosing a translation framework

I have never tried to use i18n in Rust before so I had to familiarize myself with the options and pick one. Having used Gettext from C, Vala, and even in shell scripts before I was biased towards using it again, if there was a way to do so, and as it turns out there are some well maintained bindings available in the gettext-rs crate. A few people also recommended Fluent over Gettext though, so I looked into it.

fluent-rs

In looking at Fluent I do think that it is a better designed system. In particular, it allows one to place variables into your string translations, so any portion of a string which is going to remain static accross all languages can be placed into the correct grammatical position accross all languages. However, there is a lot to be said for inertia in software, and if I'm going to go through the work to make Zond i18n capable then I want to also make it as easy as possible on potential translators. Gettext has been a standard for such a long time and has great tools that have grown up around it's use such as Poedit. So ultimately that's what I went with.

The changes to the code are surprisingly minimal. I've gone beyond providing i18n for the generated output and made it also possible to translate the user interface (cli) and error messages. Obviously the generated output is the most important to have, but it's always nice to use a tool which presents messages to you in your native language. Anyway, the changes to the code itself are complete, and the translation .pot template is done. I just need to update the build runner so that it will run msgfmt on the translation files and then merge the working branch back into the main.

Tags for this page

i18n

zond

rust

software

Home

All posts

All content for this site is released under the CC BY-SA license.

© 2022 by JeanG3nie

Finger

Contact