maciejhirsz/ramhorns

Internationalization (i18n)

Weasy666 opened this issue · 4 comments

As an idea for a future feature, i think internationalization would be really great and useful to a lot of people.
For doing this i would suggest using Project Fluent, which even has a Rust Crate fluent-rs.

I'm not quite sure that i18n logic branching should belong in the templates. For one, I find that i18n is always pretty opinionated (are you using English strings as keys for translation, or are you using quasi variable names like FOO_DESCRIPTION?).

It's also horribly difficult to make templates like that that are generic enough to fit all languages and grammars correctly. Case in point: the project you just linked (at first glance, I might be wrong) assumes that you can use the same grammar for all plural forms of enumeration. That's true in English (4 apples; 5 apples; 42 apples; 100 apples), but is not true in my native Polish (4 jabłka; 5 jabłek; 42 jabłka; 100 jabłek).

Not to make a jab, as this simple thing trips over almost every i18n library/framework that is not written by someone who is a linguist, or for this specific case, at least familiar with some slavic language. I'm not a linguist, I don't even know what I don't know about a lot of grammars (except for German, I'm aware of a lot of German grammar that I'm wilfully ignorant of :D), so I think delegating the work of internationalization to a 3rd party library authors is probably the safest bet.

Also Ramhorns is mostly intended to be a logic-less template :).

Yeah….german is a grammar bitch ^^ I'm also ignoring a lot of the "High" german grammar.
The reason why i thought about an i18n integration is that when you are using this template framework you are most likely using it for a webpage/webservice that is available in more than one country and as such you would need a way to change your displayed text depending on the users country. And you need this for the part of code that faces the user, the UI, and that is also the part of the code that Ramhorns is responsible for.
So i thought combining both is a good idea. There is also a not released Fluent framework for Askama, so i think it is possible to integrate this. Sure...not everybody needs this so it should be behind a feature gate.

I can't tell you much about the polish plural, but did you scroll down the starting page of Project Fluent? I think they are especially empathising about the different plural forms.
image

Ah, so they do handle it, that's pretty neat, I really only glanced at it :P. I'll think on this a bit more.

Doing some feature pruning in general. It seems we are leaning into making Ramhorns a compliant mustache implementation, and I think it might be a good idea to stick to unix philosophy here.

Plus I really don't see myself finding time to do this :).