Translate Latex documents with Trados Studio

luatextexstudio

I am employee in mid-sized company that is currently experimenting with implementation of Latex
for writting technical documentation
(see Implementing Latex in our company).

Most of our documents need to be translated in various languages, which is done by translation agencies.
To perform this task, they normally use Trados Studio. However, this program does not support documents in
.tex format.

It does, however, support .html format. As I am using TexStudio (together with Tex Live), I am able to convert .tex documents
in .html format (using Tools -> Convert Source to Html). This creates a document that can show Html code when opened in
Notepad, but if you open it in web browser, a .tex code is shown.

However, the created document was not compatible with Trados Studio.

My question is:

  1. How can I solve this problem? Is the problem in the fact that the created .HTML document is not "correctly" converted
    (when checking the created Html document with Html validator, some errors pop up).

  2. If this approach of converting to .html documents is not the best approach for translating with Trados Studio, what alternative
    approach do you suggest?

Note that our typical documents are roughly 100 pages long and there is large amount of them, so a solution
that is not time-intensive would be preffered.

Edit: I used make4ht -l filename.tex, while the minimized example (probably I missed something) is:

% !TeX program = lualatex
% !TeX encoding = UTF-8 Unicode
% !TeX spellcheck = de_DE 

\documentclass[10pt,a4paper,twoside]{report}
\usepackage{geometry} 
\geometry{
    a4paper,
    total={170mm,251.5mm},  %default je 150mm,237mm
    outer=15mm,
    inner=20mm,
    top=25mm}

\usepackage{fontspec}
\setmainfont{Arial}
\usepackage{titlesec}

\usepackage[most]{tcolorbox}
\newtcolorbox{warning}[1][width=171.375mm, center]{%
    enhanced jigsaw,                %engine za risanje zahtevnejsih okvirjev
    enlarge top initially by=3mm,   %presledek pred okvirjem
    enlarge bottom finally by=3mm,  %presledek za okvirjem
    borderline={3.5pt}{-5pt}{black},    %to je dodaten okvir
    sharp corners,                  %kaksni so vogali
    fonttitle=\bfseries,            %NASLOV v krepkem
    title=WARNUNG!,                 %ime naslova
    coltitle=black,                 %font naslova crne barve
    colbacktitle={white!80!gray},   %ozadje naslova sivo
    halign title=center,            %naslov centriran--------------------
    fontupper=\bfseries,            %besedilo warninga je v krepkem
    halign=flush center,                    %upper (sredinski) part centriran, ALTERNATIVA: UKAZ CENTER
    halign lower=right,             %lower (spodnji) part poravnan desno
    colframe=black,                 %barva okvirja
    colback={white!80!gray},        %barva ozadja upper in lower part----
    lower separated=false,          %crta ki locuje
    fontlower=\tiny,                %font rms in številke
    middle=0mm,                     %minimalen razmik med upper in lower part
    bottom=0mm,                     %minimalen razmik med lower part in okvirjem
    %breakable,                     %ce bi hoteli da se prelomijo cez strani.
    #1
}
\newtcolorbox{caution}[1][]{%
    enhanced jigsaw,                %engine za risanje zahtevnejsih okvirjev
    enlarge top initially by=1.5mm, %presledek pred okvirjem
    enlarge bottom finally by=1.5mm,    %presledek za okvirjem
    %   borderline={0pt}{0pt}{black},   %to je dodaten okvir
    sharp corners,                  %kaksni so vogali
    fonttitle=\bfseries,            %NASLOV v krepkem
    title=ACHTUNG!,                 %ime naslova
    coltitle=black,                 %font naslova crne barve
    colbacktitle={white!80!gray},   %ozadje naslova sivo
    halign title=center,            %naslov centriran--------------------
    fontupper=\bfseries,            %besedilo warninga je v krepkem
    halign=flush center,                    %upper (sredinski) part centriran
    halign lower=right,             %lower (spodnji) part poravnan desno
    colframe=black,                 %barva okvirja
    colback={white!80!gray},        %barva ozadja upper in lower part----
    lower separated=false,          %crta ki locuje
    fontlower=\tiny,                %font rms in številke
    middle=0mm,                     %minimalen razmik med upper in lower part
    bottom=0mm,                     %minimalen razmik med lower part in okvirjem
    %fontupper={\setlength{\parindent}{20pt}},
    #1
}
\newtcolorbox{note}[1][]{%
    enhanced jigsaw,                %engine za risanje zahtevnejsih okvirjev
    enlarge top initially by=1.5mm, %presledek pred okvirjem
    enlarge bottom finally by=1.5mm,    %presledek za okvirjem
    %   borderline={0pt}{0pt}{black},   %to je dodaten okvir
    sharp corners,                  %kaksni so vogali
    %   fonttitle=\bfseries,            %NASLOV v krepkem
    title=HINWEIS,                      %ime naslova
    coltitle=black,                 %font naslova crne barve
    colbacktitle=white,             %ozadje naslova sivo
    halign title=center,            %naslov centriran--------------------
    %   fontupper=\bfseries,            %besedilo warninga je v krepkem
    halign=flush center,                    %upper (sredinski) part centriran
    halign lower=right,             %lower (spodnji) part poravnan desno
    colframe=black,                 %barva okvirja
    colback=white,                  %barva ozadja upper in lower part----
    lower separated=false,          %crta ki locuje
    fontlower=\tiny,                %font rms in ?tevilke
    middle=0mm,                     %minimalen razmik med upper in lower part
    bottom=0mm,                     %minimalen razmik med lower part in okvirjem
    %fontupper={\setlength{\parindent}{20pt}},
    #1
}

\usepackage[a-2b]{pdfx}
\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\newcommand{\fullref}[1]{\hyperref[#1]{\ref*{#1}\ \nameref*{#1}}}
\renewcommand{\figureautorefname}{Abbildung} 

\usepackage{lastpage}
\usepackage{fancyhdr}
\def\cnvjobname{\expandafter\cnvjobnameA\jobname\relax}
\def\cnvjobnameA#1{\ifx\relax#1\else
    \ifx?#1: \else \expandafter\ifx\string_#1 \else #1\fi\fi
    \expandafter\cnvjobnameA\fi
}
\newcommand*{\setmyjobname}{%
    \edef\myjobname{\cnvjobname}%
    \expandafter\expandafter\expandafter\setmyjobnameaux
    \expandafter\myjobname\expandafter"\myjobname"\relax
}

\newcommand*{\setmyjobnameaux}{}
\def\setmyjobnameaux#1"#2"#3\relax{\def\myjobname{#2}}
\setmyjobname

\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\includegraphics*[height=0.6cm]{example-image-b}}

\renewcommand{\figurename}{Abbildung}
\renewcommand{\tablename}{Tabelle} 
\newcommand{\cell}{\parbox[t]{20cm}\seqsplit}

\begin{document}
    something
\end{document}

Best Answer

There are two issues with the MWE, if you have up-to-date TeX Live. First is the fatal error caused by the PDFX package, second is caused by Hyperref.

In general, packages that have effect only in the PDF mode should be avoided when you convert your document with TeX4ht, as it operates in the DVI mode. This can result in fatal errors just by loading of the package.

There are two ways to disable the package. The first is to edit your document and include packages conditionally. This can be done for example using the following command:

\ifdefined\HCode\else
\usepackage[a-2b]{pdfx}
\fi

The second way is to change TeX4ht configuration files for packages. We have special files, that are loaded before a package, so package loading can be disabled. First, we have to declare such file in usepackage.4ht:

   \def\:temp{tex4ht}\ifx \:temp\@currname
   \:warning{\string\usepackage{tex4ht} again?}
   \def\:temp#1htex4ht.def,tex4ht.sty#2!*?: {\def\:temp{#2}}
\expandafter\:temp \@filelist htex4ht.def,tex4ht.sty!*?: %
\ifx \:temp\empty  \else
   \:warning{if
    \string\RequirePackage[tex4ht]{hyperref} or
    \string\usepackage[tex4ht]{hyperref} was
    used try instead, repectively,
    \string\RequirePackage{hyperref} or
    \string\usepackage{hyperref}}
\fi

\fi
\gdef\a:usepackage{\use:package ,!*?: }
\gdef\use:package#1,{%
   \if :#1:\def\:temp##1!*?: {}\else
      \def\:temp{#1}\ifx \@currname\:temp
             \def\:temp##1!*?: {\input usepackage.4ht  }%
      \else \let\:temp=\use:package \fi
   \fi \:temp}
\Configure{PackageHooks}{biblatex-chicago.sty}{biblatex-chicago-hooks.4ht}
\Configure{PackageHooks}{cleveref.sty}{cleveref-hooks.4ht}
\Configure{PackageHooks}{xr.sty}{xr-hooks.4ht}
\Configure{PackageHooks}{xr-hyper.sty}{xrhyper-hooks.4ht}
\Configure{PackageHooks}{eso-pic.sty}{esopic-hooks.4ht}
\Configure{PackageHooks}{showframe.sty}{showframe-hooks.4ht}
\Configure{PackageHooks}{expl3.sty}{expl3-hooks.4ht}
\Configure{PackageHooks}{savetrees.sty}{savetrees-hooks.4ht}
\Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht}
\Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht}
\Configure{PackageHooks}{fontawesome5-utex-helper.sty}%
{fontawesome5-utex-helper-hooks.4ht}
\Configure{PackageHooks}{fontawesome5.sty}{fontawesome5-hooks.4ht}
\Configure{PackageHooks}{biblatex.sty}{biblatex-hooks.4ht}
\Configure{PackageHooks}{xeCJK.sty}{xecjk-hooks.4ht}
\Configure{PackageHooks}{unicode-math.sty}{unicode-math-hooks.4ht}
\Configure{PackageHooks}{ctex.sty}{ctex-hooks.4ht}
\Configure{PackageHooks}{polyglossia.sty}{polyglossia-hooks.4ht}
\Configure{PackageHooks}{fontspec.sty}{fontspec-hooks.4ht}
\Configure{PackageHooks}{tikz.sty}{tikz-hooks.4ht}
\Configure{PackageHooks}{pdfbase.sty}{pdfbase-hooks.4ht}
\Configure{PackageHooks}{pdfx.sty}{pdfx-hooks.4ht}
\Configure{PackageHooks}{breakurl.sty}{breakurl-hooks.4ht}
\Configure{PackageHooks}{hyperref.sty}{hyperref-hooks.4ht}
\Configure{PackageHooks}{caption.sty}{caption-hooks.4ht}
\Configure{PackageHooks}{minted.sty}{minted-sty-hooks.4ht}
\Configure{PackageHooks}{graphics.sty}{graphics-hooks.4ht}
\Configure{PackageHooks}{graphbox.sty}{graphbox-hooks.4ht}
\Configure{PackageHooks}{xcolor.sty}{xcolor-hooks.4ht}
\Configure{PackageHooks}{imakeidx.sty}{imakeidx-hooks.4ht}
\Configure{PackageHooks}{fancyhdr.sty}{fancyhdr-hooks.4ht}
\Configure{PackageHooks}{exerquiz.sty}{exerquiz-hooks.4ht}
\Configure{PackageHooks}{hyperxmp.sty}{hyperxmp-hooks.4ht}
\Configure{PackageHooks}{datetime2.sty}{datetime2-hooks.4ht}


\endinput

The important line is this:

\Configure{PackageHooks}{pdfx.sty}{pdfx-hooks.4ht}

This declares the pdfx-hooks.4h file:

\:dontusepackage{pdfx}
\endinput

The \:dontusepackage prevents package loading, preventing PDFX from the fatal error.

Then there is a Hyperref error, caused by the following line:

\renewcommand{\figureautorefname}{Abbildung} 

The problem is that \figureautorefname is defined at the end of hyperref.sty, but Hyperref detects TeX4ht, and stops its loading earlier, so this command is undefined. We can fix it by copying of the autoref captions from hyperref.sty to hyperref-hooks.4ht:

\:AtEndOfPackage{%
\@ifpackageloaded{nameref}{}
{%
   \RequirePackage{ifthen}%
   \let\sv:label\label
   \RequirePackage{nameref}%
   \let\label\sv:label
   %\input nameref.4ht
}

\providecommand*\AMSautorefname{\equationautorefname}
\providecommand*\Hfootnoteautorefname{\footnoteautorefname}
\providecommand*\Itemautorefname{\itemautorefname}
\providecommand*\itemautorefname{item}
\providecommand*\equationautorefname{Equation}
\providecommand*\footnoteautorefname{footnote}
\providecommand*\itemautorefname{item}
\providecommand*\figureautorefname{Figure}
\providecommand*\tableautorefname{Table}
\providecommand*\partautorefname{Part}
\providecommand*\appendixautorefname{Appendix}
\providecommand*\chapterautorefname{chapter}
\providecommand*\sectionautorefname{section}
\providecommand*\subsectionautorefname{subsection}
\providecommand*\subsubsectionautorefname{subsubsection}
\providecommand*\paragraphautorefname{paragraph}
\providecommand*\subparagraphautorefname{subparagraph}
\providecommand*\FancyVerbLineautorefname{line}
\providecommand*\theoremautorefname{Theorem}
\providecommand*\pageautorefname{page}

}

With these changes, your document should compile without errors. You can update your TeX Live distribution, as these changes are already updated here.

Related Question