I think this works:
\makeatletter
\AtEveryCitekey{%
\blx@langsetup\abx@field@hyphenation%
\blx@hyphenreset%
}
\makeatother
In \abx@field@hyphenation
is hyphenation value. Probably it needs some testing, if it is set.
edit:
Some time ago, I was looking at biblatex language switching because of problem with my citation style[1]. I didn't understand this code at all, so I ended with ugly hack[2].
But when I looked yesterday on biblatex's patch of babel you posted, I have found line
\blx@langsetup\languagename\select@language
Function \blx@langsetup
uses edef
to define \blx@languagename
, which is used by macro \blx@hyphenreset
to load hyphenation patterns, and then loads localization strings for given language. So in fact, instead of
\blx@langsetup\abx@field@hyphenation%
it is possible to use just
\edef\blx@languagename{\abx@field@hyphenation}%
Then there is problem with French language. When used as the main document language, instead of
... (Fis-
el 1985)...
there is
...(FISCHEL
1985)...
I think there is issue only with French, I tried Czech, Russian and Spanish and they worked correctly.
With babel
, we can solve this issue with
\select@language\abx@field@hyphenation%
but, polyglossia
in xelatex has same issue and this trick is there not working, I don't know how to fix that.
Anyway, if you don't need French with polyglossia
, this is the current solution
\makeatletter
\AtEveryCitekey{%
\ifcsdef{abx@field@hyphenation}{%
\edef\blx@languagename{\abx@field@hyphenation}%
\select@language\abx@field@hyphenation%
\blx@hyphenreset%
}{}%
}
\makeatother
[1] Biblatex - using two languages in one reference entry
[2] Biblatex - using two languages in one reference entry
You should load babel if you're unsure about the default language. A system administrator in the UK may well have changed it to British English instead of US English (they have different hyphenation rules).
Assuming TeX Live is used (but also MiKTeX, I believe), lines such as
\usepackage[USenglish]{babel}
\usepackage[UKenglish]{babel}
will guarantee that the requested hyphenation rules are used during typesetting. Another use for babel is for choosing a not directly supported set of hyphenation patterns; for example,
\usepackage{hyphsubst}
\HyphSubstLet{english}{usenglishmax}
\usepackage[english]{babel}
will use the "maximal set" of US English hyphenation patterns (check your language.dat
file for the exact string to use, usenglishmax
is surely correct for TeX Live).
Best Answer
Package
babel
knows more than four languages of the family English:And
babel
knows lots of hyphenation patterns (macro\l@<language>
), fromenglish.ldf
A detection of an English language would have to test either eight language names or eight hyphenation patterns.
Non-expandable
\IfLangEnglish
The following example defines
\IfLangEnglish
using LaTeX's\in@
to check if an argument can be found in a list:The categories of the letters inside
\languagename
can be 11 (letter) or 12 (other) or even a mixup (e.g. first character has 12, the others 11). Therefore\@onelevel@sanitize
normalizes the characters to category 12 for the comparison.Result:
Expandable
\IfLangEnglish
The former
\IfLangEnglish
is not fully expandable because of assignments and definitions.Therefore I would use the following definition for
\IfLangEnglish
based on the expandable\IfLanguageName
of packageiflang
:Package
iflang
2014/04/29 v1.7The new version of
iflang
is available here until it hits CTAN. (The.dtx
file is embedded as PDF attachment, run it through plain TeX to get the unpacked package file.)The new version provides test commands for language families:
The implementation is based on the expandable
\IfLangEnglish
macro.See the documentation for the supported language families and their included languages.