The simplest method is to use the glossaries-extra
package. The translation is stored in the user1
key. The long-short-user
abbreviation style is designed to include additional information in the parenthetical material on first use. By default it picks up the information from the user1
field.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[colorlinks]{hyperref}
\usepackage[acronym,
nomain,% don't create "main" glossary
postdot% put a period after the description
]{glossaries-extra}
\makeglossaries
% \glscurrentfieldvalue only works with glossaries v4.23 (and above)
\renewcommand{\glsxtrpostdescacronym}{%
\ifglshasfield{\glsxtruserfield}{\glscurrententrylabel}%
{ (\glscurrentfieldvalue)}%
{}%
}
\setabbreviationstyle[acronym]{long-short-user}
\newacronym[user1=Phase Shift Keying]{psk}{PSK}{Phasenumtastung}
\newacronym{aa}{AA}{Another Acronym}
\begin{document}
First use: \gls{psk}. Subsequent use: \gls{psk}.
First use: \gls{aa}. Subsequent use: \gls{aa}.
\printglossaries
\end{document}
The post-description hook (\glsxtrpostdesc
category) appends information after the description in the glossary. This is a convenient way of making a minor adjustment without having to define a new glossary style.
If you prefer to use \newabbreviation
instead of \newacronym
, you need to redefine \glsxtrpostdescabbreviation
instead of \glsxtrpostdescacronym
and use \setabbreviationstyle{long-short-user}
instead of \setabbreviationstyle[acronym]{long-short-user}
. (\newacronym
implicitly sets category=acronym
and \newabbreviation
implicitly sets category=abbreviation
.)
If you want to stick with just the base glossaries
package, it's slightly more complicated. The translation is still provided in the user1
field:
\documentclass{article}
\usepackage{glossaries}
\makeglossaries
% define an acronym style for the acronyms with a translation:
\newacronymstyle{acronymslang}%
{%
\GlsUseAcrEntryDispStyle{long-short}%
}
{%
\GlsUseAcrStyleDefs{short-long}%
\renewcommand*{\genacrfullformat}[2]{%
\glsentrylong{##1}##2\space
(\protect\firstacronymfont{\glsentryshort{##1}}%
\ifglshasfield{useri}{##1}%
{, \glsentryuseri{##1}}{})%
}%
\renewcommand*{\Genacrfullformat}[2]{%
\Glsentrylong{##1}##2\space
(\protect\firstacronymfont{\glsentryshort{##1}}%
\ifglshasfield{useri}{##1}%
{, \glsentryuseri{##1}}{})%
}%
\renewcommand*{\genplacrfullformat}[2]{%
\glsentrylongpl{##1}##2\space
(\protect\firstacronymfont{\glsentryshortpl{##1}}%
\ifglshasfield{useri}{##1}%
{, \glsentryuseri{##1}}{})%
}%
\renewcommand*{\Genplacrfullformat}[2]{%
\Glsentrylongpl{##1}##2\space
(\protect\firstacronymfont{\glsentryshortpl{##1}}%
\ifglshasfield{useri}{##1}%
{, \glsentryuseri{##1}}{})%
}%
}
\setacronymstyle{acronymslang}
\newacronym[user1=Phase Shift Keying]{psk}{PSK}{Phasenumtastung}
\newacronym{aa}{AA}{Another Acronym}
% glossary style for acronyms with a translation
\newglossarystyle{acronymslang}
{%
\setglossarystyle{long}%
\renewcommand*{\glsgroupskip}{}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\glspostdescription
\ifglshasfield{useri}{##1}{ (\glsentryuseri{##1})}{}%
\space ##2\tabularnewline
}%
}
\setglossarystyle{acronymslang}
\begin{document}
First use: \gls{psk}. Subsequent use: \gls{psk}.
First use: \gls{aa}. Subsequent use: \gls{aa}.
\printglossaries
\end{document}
This doesn't have the benefit of the post-description hook so a custom glossary style is required. The difference between the two methods can be seen from the position of the period (full-stop) inserted after the description through the postdot
or postpunc=dot
(glossaries-extra
only) or nopostdot=false
package options. With the glossaries-extra
post-description hook the terminating punctuation is placed after the hook.
My original answer used an old version of glossaries
and had to use internal commands, which isn't desirable. It's better to update to a newer version and use one of the above methods instead. There's no custom glossary style as it uses a hack to append the user1
contents to the description
field.
\documentclass{article}
\usepackage{glossaries}
\usepackage{etoolbox}
\newtoks\customtok
\renewcommand*{\newacronymhook}{%
\edef\dosetkeys{\noexpand\setkeys{glossentry}{user1={},\the\glskeylisttok}}%
\dosetkeys
\ifcsempty{@glo@useri}%
{%
\expandafter\customtok\expandafter{\the\glsshorttok}%
}%
{%
\edef\custom{\the\glsshorttok, \csexpandonce{@glo@useri}}%
\expandafter\customtok\expandafter{\custom}%
}%
}
\newcommand*{\custompostdesc}[1]{%
\ifcsempty{glo@#1@useri}{}{ (\glsentryuseri{#1})}%
}
\renewcommand*{\CustomAcronymFields}{%
user1={},%
name={\the\glsshorttok},%
description={\the\glslongtok\noexpand\custompostdesc{\the\glslabeltok}},%
first={\the\glslongtok\space(\the\customtok)},%
firstplural={\the\glslongtok\noexpand\acrpluralsuffix
\space (\the\customtok)}%
text={\the\glsshorttok},%
plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}
\SetCustomStyle
\makeglossaries
\newacronym[user1=Phase Shift Keying]{psk}{PSK}{Phasenumtastung}
\newacronym{aa}{AA}{Another Acronym}
\begin{document}
First use: \gls{psk}. Subsequent use: \gls{psk}.
First use: \gls{aa}. Subsequent use: \gls{aa}.
\printglossaries
\end{document}
I can't see how acronyms relate to your question, but a new key for \newglossaryentry
can be added using \glsaddkey
where you specify the new key, a default value if the key hasn't been assigned, and various commands that can be used to later access the information provided by that key. (These commands are analogous to commands like \glsentrytext
, \Glsentrytext
, \glstext
, \Glstext
and \GLStext
and so are not governed by the first use flag.)
For brevity, I've only defined the masculine cases. You can apply a similar method for the other genders and plural cases. I've also only defined one term also for brevity. I may have made grammatical errors, but this should give you the general gist of how to add new keys:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{glossaries}
\makeglossaries
% Without article:
% masculine nominative
\glsaddkey
{mnominative}% key
{}% default value
{\glsentrymnominative}% no link cs
{\Glsentrymnominative}% no link ucfirst cs
{\glsmnom}% link cs
{\Glsmnom}% link ucfirst cs
{\GLSmnom}% link all caps cs
% masculine accusative
\glsaddkey
{maccusative}% key
{}% default value
{\glsentrymaccusative}% no link cs
{\Glsentrymaccusative}% no link ucfirst cs
{\glsmacc}% link cs
{\Glsmacc}% link ucfirst cs
{\GLSmacc}% link all caps cs
% masculine genitive
\glsaddkey
{mgenitive}% key
{}% default value
{\glsentrymgenitive}% no link cs
{\Glsentrymgenitive}% no link ucfirst cs
{\glsmgen}% link cs
{\Glsmgen}% link ucfirst cs
{\GLSmgen}% link all caps cs
% masculine dative
\glsaddkey
{mdative}% key
{}% default value
{\glsentrymdative}% no link cs
{\Glsentrymdative}% no link ucfirst cs
{\glsmdat}% link cs
{\Glsmdat}% link ucfirst cs
{\GLSmdat}% link all caps cs
% With definite article:
% masculine nominative
\glsaddkey
{mdefnominative}% key
{der \glsentrymnominative{\glslabel}}% default value
{\glsentrymdefnominative}% no link cs
{\Glsentrymdefnominative}% no link ucfirst cs
{\glsmdefnom}% link cs
{\Glsmdefnom}% link ucfirst cs
{\GLSmdefnom}% link all caps cs
% masculine accusative
\glsaddkey
{mdefaccusative}% key
{des \glsentrymaccusative{\glslabel}}% default value
{\glsentrymdefaccusative}% no link cs
{\Glsentrymdefaccusative}% no link ucfirst cs
{\glsmdefacc}% link cs
{\Glsmdefacc}% link ucfirst cs
{\GLSmdefacc}% link all caps cs
% masculine genitive
\glsaddkey
{mdefgenitive}% key
{dem \glsentrymgenitive{\glslabel}}% default value
{\glsentrymdefgenitive}% no link cs
{\Glsentrymdefgenitive}% no link ucfirst cs
{\glsmdefgen}% link cs
{\Glsmdefgen}% link ucfirst cs
{\GLSmdefgen}% link all caps cs
% masculine dative
\glsaddkey
{mdefdative}% key
{den \glsentrymdative{\glslabel}}% default value
{\glsentrymdefdative}% no link cs
{\Glsentrymdefdative}% no link ucfirst cs
{\glsmdefdat}% link cs
{\Glsmdefdat}% link ucfirst cs
{\GLSmdefdat}% link all caps cs
% With indefinite article:
% masculine nominative
\glsaddkey
{mindefnominative}% key
{ein \glsentrymnominative{\glslabel}}% default value
{\glsentrymindefnominative}% no link cs
{\Glsentrymindefnominative}% no link ucfirst cs
{\glsmindefnom}% link cs
{\Glsmindefnom}% link ucfirst cs
{\GLSmindefnom}% link all caps cs
% masculine accusative
\glsaddkey
{mindefaccusative}% key
{eines \glsentrymaccusative{\glslabel}}% default value
{\glsentrymindefaccusative}% no link cs
{\Glsentrymindefaccusative}% no link ucfirst cs
{\glsmindefacc}% link cs
{\Glsmindefacc}% link ucfirst cs
{\GLSmindefacc}% link all caps cs
% masculine genitive
\glsaddkey
{mindefgenitive}% key
{einem \glsentrymgenitive{\glslabel}}% default value
{\glsentrymindefgenitive}% no link cs
{\Glsentrymindefgenitive}% no link ucfirst cs
{\glsmindefgen}% link cs
{\Glsmindefgen}% link ucfirst cs
{\GLSmindefgen}% link all caps cs
% masculine dative
\glsaddkey
{mindefdative}% key
{einen \glsentrymdative{\glslabel}}% default value
{\glsentrymindefdative}% no link cs
{\Glsentrymindefdative}% no link ucfirst cs
{\glsmindefdat}% link cs
{\Glsmindefdat}% link ucfirst cs
{\GLSmindefdat}% link all caps cs
\newglossaryentry{alt}%
{%
name={Alt},% how it appears in the glossary
text={alt},% predicative
plural={alt},% predicative plural
description={old},% description
% without article
mnominative={alter},% nominative
maccusative={alten},% accusative
mgenitive={altem},% genitive
mdative={alten},% dative
% with definite article
mdefnominative={der alte},% nominative
mdefgenitive={dem alten}% genitive
}
\begin{document}
Ich bin \glsmindefnom{alt} Mann.
Ich bin \glsmdefnom{alt} Mann.
Ich sehe die Frau \glsmdefacc{alt} Mannes.
Ich gebe \glsmdefgen{alt} Mann ein Buch.
\printglossaries
\end{document}
This produces:
Best Answer
This is a bug. I'll get it fixed in the next version. For now, a simple workaround is to use one of the new acronym styles: