1

I'm working in a template and I want to use the doclicense package and I want it to display license information accordingly to the current language. Unfortunately, for some reason, it is not doing as expected.

The minimal class file example testclass.cls is displayed below:

\ProvidesClass{testclass}
\LoadClass{article}
\RequirePackage[brazilian,english]{babel}
\RequirePackage[
    type={CC},
    modifier={by},
    version={4.0},
]{doclicense}

\def\@keytest{
    \iflanguage{english}{test}{
    \iflanguage{portuguese}{TESTE}{not found}
    }}

\newcommand{\showtest}{%
 \@keytest\par 
 \doclicenseText\par
 \doclicenseIcon
}

and the .tex file is below:

\documentclass[brazilian,english]{testclass}
\usepackage[utf8]{inputenc}

\title{Teste}
\author{Eu}

\begin{document}
\selectlanguage{brazilian}
\maketitle

\showtest
\end{document}

The result achieved from the above code setting the language to english is:

result using english

and the result setting the language to brazilian is:

result using brazilian

Note that the article's date and the test variable (keytest) changed their values accordingly, but the license text did not.

2 Answers 2

3

doclicense hasn't code to change the language in the document. It will use whatever \languagename is set when the package is loaded.

If you want brazilian you could load the language definitions manually. Be aware that they contain empty lines and spaces, so do it between paragraphs:

\documentclass{article}
\RequirePackage[brazilian,english]{babel}
\RequirePackage[
    type={CC},
    modifier={by},
    version={4.0},
]{doclicense}

\begin{document}
\selectlanguage{brazilian}
\doclicenseText\par
\doclicenseIcon


\makeatletter\input{doclicense-brazilian.ldf}\makeatother
\doclicenseText\par
\doclicenseIcon
\end{document}

enter image description here

0

Using the tip provided by @ulrike-fischer, I've embedded the solution in a newcommand.

\documentclass{article}
\RequirePackage[brazilian,english]{babel}
\RequirePackage[
    type={CC},
    modifier={by},
    version={4.0},
]{doclicense}

\newcommand{\tlprintlicense}{
    \iflanguage{english}{\makeatletter\input{doclicense-english.ldf}\makeatother\doclicenseText\par\doclicenseIcon}{
    \iflanguage{french}{\makeatletter\input{doclicense-french.ldf}\makeatother\doclicenseText\par\doclicenseIcon}{
    \iflanguage{german}{\makeatletter\input{doclicense-german.ldf}\makeatother\doclicenseText\par\doclicenseIcon}{
    \iflanguage{portuguese}{\makeatletter\input{doclicense-brazilian.ldf}\makeatother\doclicenseText\par\doclicenseIcon}{\doclicenseText\par\doclicenseIcon}
    }}}}

\begin{document}
\selectlanguage{brazilian}
\tlprintlicense

\selectlanguage{english}
\tlprintlicense
\end{document}

You must log in to answer this question.

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