Some Thoughts On String Interpolation [l10n, restricting access, AA]
kdevel
kdevel at vogtner.de
Fri Oct 27 11:03:55 UTC 2023
On Thursday, 26 October 2023 at 15:34:52 UTC, Adam D Ruppe wrote:
>> [...]
>> How could the language version be selected (at runtime)? BTW:
>> Is there a "D way of localization"?
>
> With gnu gettext, you'd first pass the string through a tr()
> function, which lets it swap out at runtime.
Okay. Usually there is a source string in English language which
is subject to translation:
```d
int n = 3;
writefln (_("n is %d"), n);
```
The source string in this example is `n is %d`. Now for every
target language one creates seperate .po-files [1]. These files
essentially contain pairs of source/target strings:
```
msgid "n is %d"
msgstr "n ist %d"
```
These .po-Files are compiled into .mo-Files from which at runtime
the strings read.
If now interpolation is in play
```d
int n = 3;
writefln (_(i"n is $(n)"));
```
How is the translation workflow organized now? What is put in the
po-Files?
[1]
https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html
More information about the Digitalmars-d
mailing list