2

I am working on a package for redacting names in minutes of meetings. The idea is that a name 'John Doe' is replaced by '<person 1>'. However, this package may be used both in English and in Dutch texts (where one wants '<persoon 1>'), hence I wonder if there is a preferred way for internationalisation (working with babel a/o polyglossia) of a package written with the LaTeX3 kernel. I am aware of the 'translator' and 'translations' packages, but they appear to be geared towards LaTeX2e.

MWE:

\documentclass{article}
\usepackage{expl3}
\usepackage{xparse}

\ExplSyntaxOn

\prop_new:N \g_redact_person_prop
\prop_set_from_keyval:Nn \g_redact_person_prop {
    {Douwe~Hoekstra} = 1
}

\cs_new_protected:Npn \redact_replace_person:n #1 {
    \prop_get:NnNT \g_redact_person_prop {#1} \l_tmpa_tl {<person~\tl_use:N \l_tmpa_tl>}
}

\NewDocumentCommand{\person}{m}{\redact_replace_person:n {#1}}
\ExplSyntaxOff

\begin{document}
\person{Douwe Hoekstra}
\end{document}
3
  • Which package are you using? Is it freely accessible to the users? If not can you post the snippet which is used for the replacements? We would need a minimal working example which demonstrates what can be achieved with the current state of the code. Then enhancements can be suggested easily.
    – Niranjan
    Dec 26, 2021 at 12:24
  • Further clarification question: why are you specifically interested in LaTeX3 instead of LaTeX2e?
    – Marijn
    Dec 26, 2021 at 12:34
  • I'm interested in LaTeX3 since the bulk of the package is written with the LaTeX3 programming layer.
    – D Hoekstra
    Dec 26, 2021 at 13:05

1 Answer 1

1

Without using babel or polyglossia, so a partial solution only.

For the redaction end of the processing, make whatever the language tag turns out to be as a part of the control sequence names that will expand to person or persoon, and then refer to the control sequence dynamically with the cs:w and cs_end: pair.

Example: if \langtag is defined as \newcommand\langtag{ne}, and if \personnamene is defined as \newcommand\personnamene{persoon}, then \cs:w personname\langtag \cs_end: will typeset persoon.

persoon

You might also need to easily highlight input errors, perhaps, if there is high-volume text.

Note that expl3 syntax ignores spaces.

MWE

\documentclass{article}
%\usepackage{expl3} % part of kernel now
\usepackage{xparse} % only needed for LaTeX prior to 2020-10-01

\ExplSyntaxOn

\newcommand\langtag{ne}
\newcommand\personnameen{person}
\newcommand\personnamene{persoon}

\prop_new:N \g_redact_person_prop

\prop_set_from_keyval:Nn \g_redact_person_prop {
    { Douwe ~ Hoekstra } = 1,
    { Jan ~ van ~ der ~ Zee } = 2
}

\cs_new_protected:Npn \redact_replace_person:n #1 {
  \prop_if_in:NnTF 
     \g_redact_person_prop
     {#1} {
       \prop_get:NnNT 
           \g_redact_person_prop 
           {#1} 
           \l_tmpa_tl 
           { 
            <
                             \cs:w personname\langtag \cs_end: 
            ~ 
            \tl_use:N \l_tmpa_tl
            > 
           }
          } % in property list
        {XXX???} % not in property list
           
}

\NewDocumentCommand{\person} { m } {
        \redact_replace_person:n {#1}
        }
\ExplSyntaxOff

\begin{document}
\textbackslash langtag is: \langtag.

\person{Douwe Hoekstra} \ldots

\person{Douwe hoekstra} \ldots  typing error

\person{Jan van der Zee} \ldots -- another name

\bigskip
\renewcommand\langtag{en}
\textbackslash langtag is: \langtag.

\person{Douwe Hoekstra} \ldots

\person{Douwe hoekstra} \ldots  typing error

\person{Jan van der Zee} \ldots -- another name

\end{document}
2
  • Is there any reason why you use \cs:w ... \cs_end: instead of \use:c{...} here? Dec 27, 2021 at 13:42
  • @MarcelKrüger No. (Other than half a vague thought about what to do if multiple tokens might become involved with language identification -- in any case, did not realize significance of \use:c even though it is on previous page to \cs:w {linear reading of documentation on-screen is not an intuitive action, as opposed to search-and-read for a specific code solution}: looking now, I see all the \...use:c commands form a functional set by design, so therefore very easy to remember now - very handy: thanks for pointing it out.)
    – Cicada
    Dec 28, 2021 at 12:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .