Get the declarations for the applied languages, in the form
*\\usepackage{polyglossia}
\\setdefaultlanguage{language1}
\\setotherlanguage{language2}
\\setotherlanguage{language3}
...
Add the given locale to the list of applied locales and return definitions for applying the * language to a text portion:
*\textlanguage[variant=languagevariant]
\begin{language}[variant=languagevariant]
...\end{language}
The first applied language is the default language
* * @param sLang The language * @param sCountry The country (may be null) * @return a string array containing definitions to apply the language: Entry 0 contains a command * and Entry 1 and 2 contains an environment */ public String[] applyLanguage(String sLang, String sCountry) { String sLocale = sCountry!=null ? sLang+"-"+sCountry : sLang; if (commands.containsKey(sLocale)) { return commands.get(sLocale); } else { // Get the Polyglossia language and variant String sPolyLang = getEntry(languageMap,sLocale,sLang); if (sPolyLang!=null) { String sVariant = getEntry(variantMap,sLocale,sLang); if (sVariant!=null) { sVariant = "[variant="+sVariant+"]"; } else { sVariant = ""; } if (languages.size()==0) { // First language, load Polyglossia and make the language default declarations.add("\\usepackage{polyglossia}"); declarations.add("\\setdefaultlanguage"+sVariant+"{"+sPolyLang+"}"); languages.add(sPolyLang); sVariant = ""; // Do not apply variant directly } else if (!languages.contains(sPolyLang)) { // New language, add to declarations declarations.add("\\setotherlanguage"+sVariant+"{"+sPolyLang+"}"); languages.add(sPolyLang); sVariant = ""; // Do not apply variant directly } String[] sCommand = new String[3]; sCommand[0] = "\\text"+sPolyLang+sVariant; if ("arabic".equals(sPolyLang)) { sPolyLang="Arabic"; } sCommand[1] = "\\begin{"+sPolyLang+"}"+sVariant; sCommand[2] = "\\end{"+sPolyLang+"}"; commands.put(sLocale, sCommand); return sCommand; } else { // Unknown language String[] sCommand = new String[3]; sCommand[0] = ""; sCommand[1] = ""; sCommand[2] = ""; commands.put(sLocale, sCommand); return sCommand; } } } }