* Simple question
@ 2022-05-09 22:15 Gerben Wierda via ntg-context
2022-05-10 7:10 ` Henning Hraban Ramm via ntg-context
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Gerben Wierda via ntg-context @ 2022-05-09 22:15 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Gerben Wierda
[-- Attachment #1.1: Type: text/plain, Size: 1473 bytes --]
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
\translatephrase[English phrase][nl]
\translatelocation[../LMTX-Output/without-ids/en/file.pdf][nl][simple]
and where I can maintain all the translations a bit like this:
\translationentry[English phrase]{
\definetranslatephrase[nl]Nederlandse frase]
\definetranslatephrase[fr][Phrase français]
}
}
\translatelocation[../LMTX-Output/without-ids/en/file.pdf][simple][nl][../LMTX-Output/without-ids/nl/file-simple.pdf]]
\translatelocation[../LMTX-Output/without-ids/en/file.pdf][none][nl][../LMTX-Output/without-ids/nl/file.pdf]]
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
Doable?
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 <https://ea.rna.nl/the-book/>
Book: Mastering ArchiMate <https://ea.rna.nl/the-book-edition-iii/>
[-- Attachment #1.2: Type: text/html, Size: 5205 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Simple question
2022-05-09 22:15 Simple question Gerben Wierda via ntg-context
@ 2022-05-10 7:10 ` Henning Hraban Ramm via ntg-context
2022-05-10 7:16 ` Database of translations (was: Simple question) Marco Patzer via ntg-context
2022-05-10 15:21 ` Simple question Wolfgang Schuster via ntg-context
2 siblings, 0 replies; 6+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-05-10 7:10 UTC (permalink / raw)
To: Gerben Wierda via ntg-context; +Cc: Henning Hraban Ramm
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
>
> \translatephrase[English phrase][nl]
> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][nl][simple]
>
> and where I can maintain all the translations a bit like this:
>
> \translationentry[English phrase]{
> \definetranslatephrase[nl]Nederlandse frase]
> \definetranslatephrase[fr][Phrase français]
> }
> }
>
> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][simple][nl][../LMTX-Output/without-ids/nl/file-simple.pdf]]
> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][none][nl][../LMTX-Output/without-ids/nl/file.pdf]]
>
>
> 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
>
> Doable?
>
> 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
> <https://ea.rna.nl/the-book/>
> Book: Mastering ArchiMate <https://ea.rna.nl/the-book-edition-iii/>
>
Hi Gerben,
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:
key;en;de;nl
yes;yes;ja;ja
LANG;English;Deutsch;Nederlands
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
text:
https://source.contextgarden.net/tex/context/modules/mkiv/m-translate.mkiv
Other options like .po files might be more versatile but also much more
involved.
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
\setupexternalfigures.
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
macros. (https://wiki.contextgarden.net/Modes)
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:
\doifmode{simple}{\setvariable{gerben}{level}{simple}}
and then
\externalfigure[images/\getvariable{gerben}{level}/\currentlanguage/cow]
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Database of translations (was: Simple question)
2022-05-09 22:15 Simple question Gerben Wierda via ntg-context
2022-05-10 7:10 ` Henning Hraban Ramm via ntg-context
@ 2022-05-10 7:16 ` Marco Patzer via ntg-context
2022-05-10 15:21 ` Simple question Wolfgang Schuster via ntg-context
2 siblings, 0 replies; 6+ messages in thread
From: Marco Patzer via ntg-context @ 2022-05-10 7:16 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Marco Patzer
On Tue, 10 May 2022 00:15:30 +0200
Gerben Wierda via ntg-context <ntg-context@ntg.nl> wrote:
> What is the easiest way to have a ‘database’ of translations for
> strings and maybe links?
Here's an idea:
\usemodule [translate]
%% \mainlanguage [nl]
\assigntranslation [en=alpha, nl=beta]\to\TRfoo
\translateinput [foo] [\TRfoo]
\assigntranslation [en=gamma, nl=delta]\to\TRbar
\translateinput [bar] [\TRbar]
\enableinputtranslation
\starttext
foo bar
\stoptext
It's not a good solution, but it's a start. There's also
\translate [en=foo, nl=bar]
But I don't know how to combine it with \translateinput. That would
remove the need of the \TR… macros.
Marco
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Simple question
2022-05-09 22:15 Simple question Gerben Wierda via ntg-context
2022-05-10 7:10 ` Henning Hraban Ramm via ntg-context
2022-05-10 7:16 ` Database of translations (was: Simple question) Marco Patzer via ntg-context
@ 2022-05-10 15:21 ` Wolfgang Schuster via ntg-context
2022-05-10 16:47 ` Gerben Wierda via ntg-context
2 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2022-05-10 15:21 UTC (permalink / raw)
To: mailing list for ConTeXt users, Gerben Wierda via ntg-context
Cc: Wolfgang Schuster
[-- Attachment #1.1: Type: text/plain, Size: 2373 bytes --]
Gerben Wierda via ntg-context schrieb am 10.05.2022 um 00:15:
> 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
>
> \translatephrase[English phrase][nl]
> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][nl][simple]
>
> and where I can maintain all the translations a bit like this:
>
> \translationentry[English phrase]{
> \definetranslatephrase[nl]Nederlandse frase]
> \definetranslatephrase[fr][Phrase français]
> }
> }
>
> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][simple][nl][../LMTX-Output/without-ids/nl/file-simple.pdf]]
> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][none][nl][../LMTX-Output/without-ids/nl/file.pdf]]
>
>
> 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
>
> Doable?
To set language dependent texts you can use the labeltext mechanism
which is used by ConTeXt to change the captions for floats etc.
Besides the default \labeltext and \setuplabeltext commands you can
create your own instance of the mechanism for your texts.
%%%% begin example
\definelabelclass [gerben]
\setupgerbentext [en] [phrase=English phrase]
\setupgerbentext [nl] [phrase=Nederlandse frase]
\setupgerbentext [fr] [phrase=Phrase français]
%\mainlanguage[nl]
%\mainlanguage[fr]
\starttext
\gerbentext{phrase}
\stoptext
%%%% end example
To change images you use multiple sub folders where each folder has
images which the same name. In ConTeXt you can use a mode to choose
which directory is used to load the image. Another method is to map the
file names of the images to symbolic names and use only the symbolic
names in your document.
%%%% begin example
\setupexternalfigures [location={local,global,default}]
\useexternalfigure [simple] [cow.pdf]
%\useexternalfigure [simple] [hacker.png]
\starttext
\externalfigure[simple]
\stoptext
%%%% end example
Wolfgang
[-- Attachment #1.2: Type: text/html, Size: 3836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Simple question
2022-05-10 15:21 ` Simple question Wolfgang Schuster via ntg-context
@ 2022-05-10 16:47 ` Gerben Wierda via ntg-context
2022-05-10 18:05 ` Denis Maier via ntg-context
0 siblings, 1 reply; 6+ messages in thread
From: Gerben Wierda via ntg-context @ 2022-05-10 16:47 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Gerben Wierda
[-- Attachment #1.1: Type: text/plain, Size: 2964 bytes --]
Thank you.
Is it possible to change the name of the resulting PDF file based on the language and a mode?
So that with a command
context language=fr mode=simple file.tex
the result is in
file-simple-fr.pdf
and with
context language=ru mode=none file.tex (or no mode given)
the result is
file-ru.pdf
G
> On 10 May 2022, at 17:21, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
>
> Gerben Wierda via ntg-context schrieb am 10.05.2022 um 00:15:
>> 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
>>
>> \translatephrase[English phrase][nl]
>> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][nl][simple]
>>
>> and where I can maintain all the translations a bit like this:
>>
>> \translationentry[English phrase]{
>> \definetranslatephrase[nl]Nederlandse frase]
>> \definetranslatephrase[fr][Phrase français]
>> }
>> }
>>
>> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][simple][nl][../LMTX-Output/without-ids/nl/file-simple.pdf]]
>> \translatelocation[../LMTX-Output/without-ids/en/file.pdf][none][nl][../LMTX-Output/without-ids/nl/file.pdf]]
>>
>>
>> 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
>>
>> Doable?
>
> To set language dependent texts you can use the labeltext mechanism which is used by ConTeXt to change the captions for floats etc.
>
> Besides the default \labeltext and \setuplabeltext commands you can create your own instance of the mechanism for your texts.
>
> %%%% begin example
> \definelabelclass [gerben]
>
> \setupgerbentext [en] [phrase=English phrase]
> \setupgerbentext [nl] [phrase=Nederlandse frase]
> \setupgerbentext [fr] [phrase=Phrase français]
>
> %\mainlanguage[nl]
> %\mainlanguage[fr]
>
> \starttext
> \gerbentext{phrase}
> \stoptext
> %%%% end example
>
> To change images you use multiple sub folders where each folder has images which the same name. In ConTeXt you can use a mode to choose which directory is used to load the image. Another method is to map the file names of the images to symbolic names and use only the symbolic names in your document.
>
> %%%% begin example
> \setupexternalfigures [location={local,global,default}]
>
> \useexternalfigure [simple] [cow.pdf]
> %\useexternalfigure [simple] [hacker.png]
>
> \starttext
> \externalfigure[simple]
> \stoptext
> %%%% end example
>
> Wolfgang
[-- Attachment #1.2: Type: text/html, Size: 25876 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Simple question
2022-05-10 16:47 ` Gerben Wierda via ntg-context
@ 2022-05-10 18:05 ` Denis Maier via ntg-context
0 siblings, 0 replies; 6+ messages in thread
From: Denis Maier via ntg-context @ 2022-05-10 18:05 UTC (permalink / raw)
To: ntg-context; +Cc: denis.maier
Don't know how if there's an automatic way, perhaps look into ctx processing instructions.
Anyway you can use
--result=name
As you have to set quite a few options on the command line (modes, language) you'll perhaps want to use a makefile anyway.
________________________________________
Von: ntg-context <ntg-context-bounces@ntg.nl> im Auftrag von Gerben Wierda via ntg-context <ntg-context@ntg.nl>
Gesendet: Dienstag, 10. Mai 2022 18:47:32
An: mailing list for ConTeXt users
Cc: Gerben Wierda
Betreff: Re: [NTG-context] Simple question
Thank you.
Is it possible to change the name of the resulting PDF file based on the language and a mode?
So that with a command
context language=fr mode=simple file.tex
the result is in
file-simple-fr.pdf
and with
context language=ru mode=none file.tex (or no mode given)
the result is
file-ru.pdf
G
On 10 May 2022, at 17:21, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com<mailto:wolfgang.schuster.lists@gmail.com>> wrote:
Gerben Wierda via ntg-context schrieb am 10.05.2022 um 00:15:
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
\translatephrase[English phrase][nl]
\translatelocation[../LMTX-Output/without-ids/en/file.pdf][nl][simple]
and where I can maintain all the translations a bit like this:
\translationentry[English phrase]{
\definetranslatephrase[nl]Nederlandse frase]
\definetranslatephrase[fr][Phrase français]
}
}
\translatelocation[../LMTX-Output/without-ids/en/file.pdf][simple][nl][../LMTX-Output/without-ids/nl/file-simple.pdf]]
\translatelocation[../LMTX-Output/without-ids/en/file.pdf][none][nl][../LMTX-Output/without-ids/nl/file.pdf]]
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
Doable?
To set language dependent texts you can use the labeltext mechanism which is used by ConTeXt to change the captions for floats etc.
Besides the default \labeltext and \setuplabeltext commands you can create your own instance of the mechanism for your texts.
%%%% begin example
\definelabelclass [gerben]
\setupgerbentext [en] [phrase=English phrase]
\setupgerbentext [nl] [phrase=Nederlandse frase]
\setupgerbentext [fr] [phrase=Phrase français]
%\mainlanguage[nl]
%\mainlanguage[fr]
\starttext
\gerbentext{phrase}
\stoptext
%%%% end example
To change images you use multiple sub folders where each folder has images which the same name. In ConTeXt you can use a mode to choose which directory is used to load the image. Another method is to map the file names of the images to symbolic names and use only the symbolic names in your document.
%%%% begin example
\setupexternalfigures [location={local,global,default}]
\useexternalfigure [simple] [cow.pdf]
%\useexternalfigure [simple] [hacker.png]
\starttext
\externalfigure[simple]
\stoptext
%%%% end example
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-10 18:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 22:15 Simple question Gerben Wierda via ntg-context
2022-05-10 7:10 ` Henning Hraban Ramm via ntg-context
2022-05-10 7:16 ` Database of translations (was: Simple question) Marco Patzer via ntg-context
2022-05-10 15:21 ` Simple question Wolfgang Schuster via ntg-context
2022-05-10 16:47 ` Gerben Wierda via ntg-context
2022-05-10 18:05 ` Denis Maier via ntg-context
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).