[Tex/LaTex] Make hyperref’s \autoref output in Bulgarian

hyperreflanguages

I'm trying to use hyperref for references, but by default it outputs them in English like "chapter 2". According to Hyperref ignores \setdefaultlanguage from polyglossia, doing

\usepackage[bulgarian]{hyperref}

Should do the trick, but this gives me a cryptic error:

! Package xkeyval Error: `bulgarian' undefined in families `Hyp'.

See the xkeyval package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.4319 \ProcessKeyvalOptions{Hyp}

Note that it works for german. Here is my styling:

\ProvidesPackage{style}

\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{DejaVu Serif}
\setsansfont[Ligatures=TeX]{DejaVu Sans}
\setmonofont[Ligatures=TeX]{DejaVu Sans Mono}
% \newfontfamily{\TelSubstFont}[Ligatures=TeX]{Cantarell}

\usepackage{polyglossia}
\setmainlanguage{bulgarian}
\setdefaultlanguage{bulgarian}

\usepackage{minted}

\usepackage[bulgarian]{hyperref}
\hypersetup{pdflang=bg}

\usepackage[numbers]{natbib}

P.S. I'm still new to LaTeX, using XeLaTeX to compile the document.

Best Answer

Since Bulgarian is not yet supported, you can convince it to cooperate with hyperref by defining the needed keywords yourself:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{FreeSerif}

\usepackage{polyglossia}
\setmainlanguage{bulgarian}
\setotherlanguage{english}

\usepackage{hyperref}

\makeatletter
\ifdefined\HyLang@bulgarian\else
\appto\blockextras@bulgarian{%
  \def\equationautorefname{Equation}%
  \def\footnoteautorefname{footnote}%
  \def\itemautorefname{item}%
  \def\figureautorefname{Figure}%
  \def\tableautorefname{Таблица}%
  \def\partautorefname{Part}%
  \def\appendixautorefname{Appendix}%
  \def\chapterautorefname{chapter}%
  \def\sectionautorefname{section}%
  \def\subsectionautorefname{subsection}%
  \def\subsubsectionautorefname{subsubsection}%
  \def\paragraphautorefname{paragraph}%
  \def\subparagraphautorefname{subparagraph}%
  \def\FancyVerbLineautorefname{line}%
  \def\theoremautorefname{Theorem}%
  \def\pageautorefname{page}%
}
% \inlineextras@bulgarian is empty, so we simply set it
% equal to \blockextras@bulgarian
\let\inlineextras@bulgarian\blockextras@bulgarian
\fi
\makeatother

\begin{document}
\begin{table}
\caption{A table}\label{A}
\end{table}
\autoref{A}

\end{document}

Here I have modified from the English keywords only the one corresponding to "Table". A picture of the result:

enter image description here

The \ifdefined...\fi wrapper means that when hyperref will have the support for Bulgarian, the part in between will not be read any more.