Simple transliteration in LaTeX (for Latin)

I would like to typeset the same latin text in two or more "spellings".

My source is a modernized spelling (distinguishing i/j, u/v) and I would like to display it both with and without this distinction.

Since I would like to stay in (pdf)LaTeX, I had thought to hack the \lowercase macro by modifying lccodes and uccodes.

Here is a working example, which mainly does what I want:

\documentclass{article}
\newcommand{\translit}[1]{\begingroup
\lccode\A=\A
\lccode\B=\B
\lccode\C=\C
\lccode\D=\D
\lccode\E=\E
\lccode\F=\F
\lccode\G=\G
\lccode\H=\H
\lccode\K=\K
\lccode\L=\L
\lccode\M=\M
\lccode\N=\N
\lccode\O=\O
\lccode\P=\P
\lccode\Q=\Q
\lccode\R=\R
\lccode\S=\S
\lccode\T=\T
\lccode\W=\W
\lccode\X=\X
\lccode\Y=\Y
\lccode\Z=\Z

\lccode\I=\I
\lccode\J=\I

\lccode\U=\V
\lccode\V=\V

\lccode\v=\u
\lccode\j=\i

\uccode\u=\V
\uccode\j=\I

\lowercase{#1}

\endgroup}

\begin{document}

\lowercase{Vero. Ubi et Orbi.  Nuper Quidem cum iam te adventare arbitraremur. ut queant laxis.}\par

\translit{Vero. Ubi et Orbi.  Nuper Quidem cum iam te adventare arbitraremur. ut queant laxis.}\par

% checks that the modification is local
\lowercase{Vero. Ubi et Orbi.  Nuper Quidem cum iam te adventare arbitraremur. ut queant laxis.}\par

\bigskip

Original version\par

{ Arma virumque cano, Troiae qui primus ab oris

Italiam, fato profugus, Laviniaque venit

litora, multum ille et terris iactatus et alto

vi superum saevae memorem Iunonis ob iram;

multa quoque et bello passus, dum conderet urbem,

inferretque deos Latio, genus unde Latinum}

\medskip

Modified version\par

\translit{ Arma virumque cano, Troiae qui primus ab oris

Italiam, fato profugus, Laviniaque venit

litora, multum ille et terris iactatus et alto

vi superum saevae memorem Iunonis ob iram;

multa quoque et bello passus, dum conderet urbem,

inferretque deos Latio, genus unde Latinum}

\end{document}


My questions are:

• Is there a more sensible way to do that in LaTeX (I would rather not use XeTeX or ConTeXt at this point) (without locally changing codes) ?

• I also thought about building a dialect of the latin babel because the medieval setting does not do this: it is intended to change capitalization rules for headers and titles. Doing this development would have several advantages (I have custom things to do on ligatures, hyphenation, typographic rules) but it seems a little involved for me right now, and would certainly require a lot of help from the package maintainers (I now they are active on TeX.SE).

• Some things that this trick cannot do and I would like:

• Treat specially first letters of words. In some ancient typographic traditions, if a lowercase u/v was the first letter of a word, it was typed v, if inside the word, it was typed u. I thought this might be achieved with the same mechanism used in the french babel language file for typographic conventions: making certain characters active, etc.

• do not disturb hyphenation patterns for modified words

• Apply to text stored in definitions although it works well with inline text.

• One way would be to have a virtual font that used the same glyph for u and v (and optionally ligatured start of word with v (placed at some other slot in the font) but you would have to do this for each font, so might not be convenient. – David Carlisle Jun 7 '13 at 11:18
• Making UVuvIJij active is possible, but you must control your input in order not to have inside it commands that have one of those letters in their name. As far as hyphenation patterns are concerned, they use the final letters, so when you change v to u, the u is used for computing hyphenation points. – egreg Jun 7 '13 at 11:34
• @egreg if I understand correctly, in this case I can call inside my input commands (or aliases) that themselves call commands with UVuvIJij characters ? – ogerard Jun 7 '13 at 11:53
• If you choose to activate UVuvIJij, then the Latin parts where the translitteration should occurr cannot contain commands containing the letters in their name (such as \input, for instance); also, those parts cannot go inside arguments to other commands (but this restriction could be relieved in some cases). – egreg Jun 7 '13 at 12:48