0

I would like to know if it is possible to conditionally require, in a given document, the inclusion of a chapter or the input of a particular piece of text, depending on the language set on babel or in polyglossia.

I mean something similar to the mechanism used by the package translations for the customization of a document according to the setting of its main language. Precisely, I would like that, after setting the main document language by

\usepackage[lang]{babel}

or

\setmainlanguage{lang},

a language file text_lang is automatically included in the text: : specialist in documentation design call this language conditioned parts "tags".

Is this possible and, if so, could you address me to the relevant packages or show an example code?

  • 1
    You mean like in this question: https://tex.stackexchange.com/q/461973/134574 ? – Phelype Oleinik Jan 12 '19 at 15:10
  • 1
    You can check the current language with https://ctan.org/pkg/iflang or https://ctan.org/pkg/tracklang – moewe Jan 12 '19 at 15:10
  • 1
    Note that there are differences in the way babel and polyglossia handle language variant/dialects. babel usually assigns a new language name (if you will), for example ngerman for German with new orthography rules and naustrian for Austrian German with new orthography rules. But polyglossia would use the same base language in that case (german) and would handle the new/old orthography rules and German/Austrian/Swiss German with additional properties that are hard to detect from the outside – moewe Jan 12 '19 at 15:17
  • 1
    @PhelypeOleinik: Thank you very much! I am a bit perplexed from the fact that I was not able to find it by searching the TEX.SE: however this is exactly what I need. – Daniele Tampieri Jan 12 '19 at 15:20
  • @moewe: so for polyglossia it would be more difficult to conditionally import text in different languages sharing a common linguistic root. However this is not a problem for me at present, since I am trying to discriminate between quite different languages. Anyway, thank you so much for the packages you suggested/highlighted. – Daniele Tampieri Jan 12 '19 at 15:24
  • I wouldn't say different languages with a common linguistic root (since that seems to be quite general and would in my Book include for example German and Dutch), it is more about variants/dialects of one language (though there could be some disagreement whether or not something is a variant or a different language in its own right). In the end this is about how polyglossia handles these languages. – moewe Jan 12 '19 at 15:29

0 Answers0