Am 10.05.22 um 00:15 schrieb Gerben Wierda via ntg-context:
What is the easiest way to have a ‘database’ of translations for strings
and maybe links?
I now have 4 languages and 2 versions so 8 documents, but I’d like to
have all translatable strings together so I can maintain these in a
single file. Ideally I can do a file where the key of the translation is
one language (say English) and the translations are part of that.
Something I can call like this
and where I can maintain all the translations a bit like this:
Where the \translatelocation command can be used inside an
\externalfigure command and \translatephrase can be used as as text.
In the end I’d like to compile with
context language=fr mode=simple mainfile.tex
Gerben Wierda (LinkedIn <https://www.linkedin.com/in/gerbenwierda>)
R&A IT Strategy <https://ea.rna.nl/> (main site)
Book: Chess and the Art of Enterprise Architecture
Book: Mastering ArchiMate <https://ea.rna.nl/the-book-edition-iii/>
a lot is doable, it depends on by whom ;)
But this looks like a quite easy case.
Of course the answer is always “Lua tables”, but I guess the
translations would be most easy to maintain in a CSV file (you can edit
it in LibreOffice or Excel, while the latter often botches the encoding).
It could look like:
i.e. the first column is the keyword and the other columns contain the
translated term (so you can also change the “original” version).
(We’re using the same in a LaTeX3 project made by Marei.)
Without researching I assume there are already Lua functions to read a
CSV file into a Lua table, and the lookup is easy – since I’m not fluent
in Lua, I won’t provide the function(s) for you.
BTW there is already \translate
(https://wiki.contextgarden.net/Command/translate) that changes text
depending on the current language.
And there is the translate module that changes terms within the whole
Other options like .po files might be more versatile but also much more
This covers \translatephrase; for your figures I’d just just a language
variable in the path, like \externalfigure[images/\LANG/cow.pdf]
If this is always the current language, use \currentlanguage.
You can also setup the language dependent directory in
Regarding modes, the current language is set as a system mode (*en,
*nl), and of course you can query modes with one of the many \doif
Since it doesn’t make sense to try
\externalfigure[path/\currentmode/cow] (you never know how many modes
are active), you can set a macro or variable depending on a mode:
If your question is of interest to others as well, please add an entry to the
maillist : firstname.lastname@example.org / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net