TransWikia.com

How to display license information in current language using doclicense package?

TeX - LaTeX Asked on June 15, 2021

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}{%
 @keytestpar 
 doclicenseTextpar
 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

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}
doclicenseTextpar
doclicenseIcon


makeatletterinput{doclicense-brazilian.ldf}makeatother
doclicenseTextpar
doclicenseIcon
end{document}

enter image description here

Correct answer by Ulrike Fischer on June 15, 2021

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}{makeatletterinput{doclicense-english.ldf}makeatotherdoclicenseTextpardoclicenseIcon}{
    iflanguage{french}{makeatletterinput{doclicense-french.ldf}makeatotherdoclicenseTextpardoclicenseIcon}{
    iflanguage{german}{makeatletterinput{doclicense-german.ldf}makeatotherdoclicenseTextpardoclicenseIcon}{
    iflanguage{portuguese}{makeatletterinput{doclicense-brazilian.ldf}makeatotherdoclicenseTextpardoclicenseIcon}{doclicenseTextpardoclicenseIcon}
    }}}}

begin{document}
selectlanguage{brazilian}
tlprintlicense

selectlanguage{english}
tlprintlicense
end{document}

Answered by LEo on June 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP