I have a collection of documents that share a common style file that has all the functions and templating shared by this particular collection. The majority of these are all in the same language, but o handful of them are actually translations of the others. I would like to keep using the same style include file, but a few tidbits (for example in the footer and title sheet) need to be adjusted per-language.

I'm using polyglossia1, and each document has its own language declaration using \setmainlanguage{} (in my case, mostly to Turkish). Is there some way to retrieve what language has been set and conditional output different strings based on which language is the document default?

1 Actually for some reason my style file also has \usepackage[turkish]{babel}, which seems to be should be redundant and potentially a conflict with polyglossia; maybe I should sort out why that got in there while I'm messing with this!

  • Both babel and polyglossia have \languagename which holds the currently active language name. And the translations package offers \ifcurrentbaselanguage{<lang>}{<true>}{<false>} for tests
    – cgnieder
    Mar 15, 2015 at 11:04

1 Answer 1


polyglossia stores the main language name in the macro \xpg@main@language, so it's easy to achieve what you want.








This document is written in \mainlanguage.

\IfStrEq{\mainlanguage}{turkish}{Yes, it's Turkish!}{No, it's not Turkish!}



enter image description here

As a side note, don't use babel if you're using polyglossia already...

  • 1
    In modern times, you can safely use babel with the new engines. But using babel and polyglossia is bad indeed.
    – Johannes_B
    Mar 15, 2015 at 10:34
  • Both babel and polyglossia have \languagename which holds the currently active language name. No need for \xpg@main@language
    – cgnieder
    Mar 15, 2015 at 11:05
  • @clemens as you say, \languagename holds the "currently active" language, not the "main" language as requested by the OP... Mar 15, 2015 at 11:13
  • But the OP says every of his documents has only one language so I don't see the difference here (although, I'm not sure \languagename can be trusted before begin document...)
    – cgnieder
    Mar 15, 2015 at 11:28
  • 1
    @clemens Actually it's pretty useful to know both options because my documents are not exclusively one language are the other, both directions have bits from other languages.
    – Caleb
    Mar 15, 2015 at 14:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.