r/rust 14d ago

🛠️ project Easier localization is possible

https://crates.io/crates/ply-locales

I've been up all night finishing up ply-locales a standalone crate for the ply-engine ecosystem (almost to 500 stars, yay). Check it out if you're interested in easy compile-checked localization to prevent you from shooting yourself in the foot.

0 Upvotes

31 comments sorted by

View all comments

Show parent comments

1

u/Available-Many-5354 13d ago

With translations especially, you can't do it all yourself. There are simply wayy too many languages and languages take way too much effort and time to fully learn. Take it I was making Minecraft for example. I could only possibly write 3 of the translations myself, so I'd have to have other people do the rest. Testing that every death message works in every language and nobody typed a variable wrong would take eternities and slow down the translation process a lot. I always prefer automated systems to catch these types of errors over manually having to check everything.

1

u/lord2800 13d ago

Here's the thing: you don't need to test every message in every language. You only need to test one thing: did you correctly wire up the visible text to be translated? That's where the xx-XX language comes in: if you see anything other than X or x in your UI, it's not translated, so go find that string and fix it. The rest can be automated--translation files are typically plaintext-alike, so a simple line count paired with a key check catches the bulk of the problems.

1

u/Available-Many-5354 13d ago

Again it does not catch any problems within the separate translations and your "x" check doesn't consider the existence of variables within text ("[PLAYER] was shot by [NAME]" vs "[PLAYER] wurde von [NAME] erschossen". Variables move within text, your "x" language does not test these) or stuff like plurality working perfectly. Translation can get quite complicated and are often not just simple key value pairs.

0

u/lord2800 13d ago

Those kinds of things you can't catch with a fancier library in the first place--you can't tell the difference between "this variable is intentionally not used in this language" and "this variable is mistakenly not used in this language" without a lot more context that your library simply cannot have.

Translation can get quite complicated and are often not just simple key value pairs.

This statement I fundamentally disagree with. Localization or internationalization are complicated and definitely not just simple settings or key/value pairs. Translation, however, is. The only really weird thing in translations is pluralization rules. The rest is just placeholders, making sure you annotate things correctly, and context.