Looks cool.
Thanks!
Reading your docs, I think you need some clarification on how _form works. It's not clear at all to me how you got from "FINLAND" to "Suomi". You seem to be implying there is some recursive label expansion going on, but that's surely a separate feature from inflected forms.
Yeah, it's always difficult to figure out how to word things. Good feedback. I might have to add more pictures of spreadsheets to show the correspondences.
Basically: FINLAND is the identifier of another label defined in a translation spreadsheet, with the English locale's value being
Finland and the Finnish locale's value being
%[Suomi, Suomessa], defining two distinct inflected forms of the noun in Finnish, so that the translator can call on a specific form in a token by its index, so that
%{n;0} (or just
%{n} since index 0 is assumed by default) would yield the first form (
Suomi if the FINLAND label is used) and
%{n;1} would yield the second form (
Suomessa if the FINLAND label is used).
So what
_form does is tell the localiser getting a label that it wants to replace a token with the requested inflected form of another token (i.e. replace the tokens in LABEL with one of the forms in FINLAND):
localiser.get("LABEL", "FINLAND"_form");
→
This is Finland. This is in Finland.
Tämä on Suomi. Tämä on Suomessa.
As you can see, only one argument is passed, because both tokens are index 0 (as defined by
%{0}, only requesting different forms.
This might be useful if your software needs a list of countries that are dynamically determined by the program somewhere and they need to be used in different grammatical contexts. So you could keep defining labels for more countries and your program would pick the right one before requesting the label:
Also added Icelandic here to display a different strategy, adding the preposition to the inflected form, since Icelandic requires different prepositions depending on the country.
Also, you should mention what class _form constructs. We're likely to want variables, not literals!
Ain't that what
auto is for?
But sure, it's a
karhu::localisation::Inflection. But I guess you meant you want to construct variables from other (string) variables, which I suppose the suffix can't do. For example in my above example of dynamic country names. That's a good point. Maybe I should add a little utility function to construct them as well. The class name is a bit too long. I guess I could change it to
Form instead.
EDIT:Changed the name to of Inflection to Form and updated the info page a bit.