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 <a...@offog.org> escreveu:
>
> Bento Borges Schirmer <bbschir...@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 <a...@offog.org>                         <http://offog.org/>
>

Reply via email to