Some Thoughts On String Interpolation [l10n, restricting access, AA]
Adam D Ruppe
destructionator at gmail.com
Fri Oct 27 11:20:04 UTC 2023
On Friday, 27 October 2023 at 11:03:55 UTC, kdevel wrote:
> How is the translation workflow organized now? What is put in
> the po-Files?
I literally have an example of this:
https://github.com/adamdruppe/interpolation-examples/
There's a few different ways we could do it, this here is working
with the existing D gettext lib which married itself to
std.format (much to my chagrin) but it still wasn't hard to make
it work.
Remember, the library can tell the difference between the string
literal segments and the interpolated segments, and it can work
with the string literal segments at compile time. So it can CTFE
msgids out of it in whatever format it wants and list all the
possible things for the .pot file through compile time reflection
(aggregated at runtime).
These are all solved problems - my thing is a small wrapper
around the existing gettext D lib which is a small wrapper around
GNU gettext. All you have to do is arrange the data available to
you.
In my example, I used $1, $2, etc as placeholders for the
parameters in the msgid/msgstrs, except for the plural param
which had to be %d cuz the D gettext lib made that assumption and
im trying to be compatible with it. This allows easy reordering
etc by the translator, without conflicting with std.format's %s
stuff.
Look at that repo to see for yourself.
More information about the Digitalmars-d
mailing list