groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Translation design patterns or approaches


From: Oliver Corff
Subject: Re: Translation design patterns or approaches
Date: Fri, 8 Nov 2024 23:04:40 +0100
User-agent: Mozilla Thunderbird

Hi,

in my humble opinion, a solution to your problem (if I understood it
correctly) already exists. Perhaps a good starting point for writing
useful macros which output the desired text according to language is the
macro repository of groff.

Check, e.g. the macro files trans.tmac, de.tmac, sv.tmac, cs.tmac,
fr.tmac etc.in /usr/share/groff/1.23.0/tmac

They demonstrate the mechanism how you can use string macros with good
mnemonic names that issue the names of months, days etc. according to
selected language, including a lot of phrases necessary for writing letters.

Best,

Oliver.


On 08/11/2024 20:12, Bento Borges Schirmer wrote:
Hey Adam and onf,

Thanks for the suggestion about po4a, it is good to know such thing
exists. But I didn't find any examples about it and I was not in the
mood to understand it, so I tried to be creative!

I kludged together the switch case example from groff documentation
[1] and now I have this in the top of my source:

.ds EN
.ds PT
.ie !d lang \{\
.de PT
.ds text \\$*
..
.\}
.el \{.ie '\*[lang]'pt' \{\
.de PT
.ds text \\$*
..
.\}
.el \{.ie '\*[lang]'en' \{\
.de EN
.ds text \\$*
..
.\}
.el .ds title \" empty
.\}\}\}

My intent is to define one macro for each language, but only one of
them works and the remainder becomes no-ops. The user must pass the
flag e.g. -d lang=en to groff to enable english, otherwise the
defaults to portuguese. So now I'm rewriting my CV like this:

.EN Education
.PT Educação
.RLD 12p
.HEADING 1 "\*[text]"

And:

.ITEM
.PT Ferramentas de escritório
.EN Office tools
\*[text]:
.PT e
.EN and
Microsoft Word \*[text] PowerPoint, \*[text] Google Forms
.LIST OFF

And:

.LIST USER "\(en\ "
.ITEM
.PT Desenvolveu \fIfront end\fP em React e \fIback end\fP com AWS Lambda
.EN Developed front end in React and back end with AWS Lambda
\*[text]
.LIST OFF

Working okay so far. I will finish translating my CV and pray nothing
goes wrong lol

Best regards,
Bento

[1]https://www.gnu.org/software/groff/manual/groff.html.node/Conditional-Blocks.html

Em sex., 8 de nov. de 2024 às 11:09, Adam Sampson<ats@offog.org> escreveu:
Bento Borges Schirmer<bbschirmer@inf.ufsm.br> writes:

I want to translate my CV to english. [...] Do you know any design
pattern, macro set or preprocessor that could handle this task in a
manageable way?
po4a (https://po4a.org/, packaged in most distributions already) is one
approach to this -- you write the document in your preferred source
language, then use gettext translations to specify how it's translated
into other languages.

This makes it reasonably easy to keep the translation up to date when
changes are made, because you can see what new phrases have been added
to the list of translations. (It's also convenient if you're already
using gettext in a project to translate strings in code.)

However, it needs to have an understanding of the document structure to
pull out phrases for translation, and while it supports man/mdoc already
it might not understand enough general groff for your purposes...

--
Adam Sampson<ats@offog.org>                         <http://offog.org/>

--

Dr. Oliver Corff
Mail:oliver.corff@email.de


reply via email to

[Prev in Thread] Current Thread [Next in Thread]