Discussion:
\DeclareLanguageMapping
Add Reply
Peter Flynn
2018-11-02 22:47:53 UTC
Reply
Permalink
On 01/10/2014 11:42, Peter Flynn wrote:

[when using biblatex]
...I find that if I specify the local language for babel, *and* if I
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=apa]{biblatex}
\DeclareLanguageMapping{british}{british-apa}
This is no problem, but how do I know which languages and which
biblatex styles require the use of \DeclareLanguageMapping? Is there
a table somewhere which I can use as a lookup to determine whether or
not a given combination of language and biblatex style needs this
command?
I'm sorry to repeat this, but how do I know which languages and which
biblatex styles require the use of \DeclareLanguageMapping?

Why are some of the alternate LBX files named one way and some the other, eg

british-apa.lbx
cms-british.lbx

///Peter
Moewe
2018-11-03 13:54:01 UTC
Reply
Permalink
Post by Peter Flynn
I'm sorry to repeat this, but how do I know which languages and which
biblatex styles require the use of \DeclareLanguageMapping?
Styles that require an explicit \DeclareLanguageMapping should document
that in their manual. For example biblatex-apa versions earlier than
v7.5 had the following passage in the documentation
Post by Peter Flynn
Localisation is provided for APA-specific strings in the accompanying
|.lbx| files. To use these files, put an appropriate mapping in your
document preamble, after loading Bib\LaTeX.
followed by a few code examples for American, English and German.

Other styles (e.g. biblatex-chicago, biblatex-philosophy) decide to
issue \DeclareLanguageMapping automatically and therefore need no user
intervention.

Since version 3.6 biblatex has had a command called
\DeclareLanguageMappingSuffix{<suffix>} that styles can use to issue
blanket mappings of the form

\DeclareLanguageMapping{<lang>}{<lang><suffix>}

for all languages. Newer versions of biblatex-apa use this command and
need no explicit \DeclareLanguageMappings any more (hence the passage
quoted above is no longer present in the biblatex-apa documentation).
Post by Peter Flynn
Why are some of the alternate LBX files named one way and some the other, eg
british-apa.lbx
cms-british.lbx
biblatex did not enforce a particular file name (scheme) for language
mappings, so developers were free to choose whichever name they liked.
Examples in the documentation used the form <language>-<suffix>.lbx. The
new \DeclareLanguageMappingSuffix makes the form <language><suffix>.lbx
very natural and indeed that is what biblatex-apa uses.
biblatex-chicago's .lbx files predate \DeclareLanguageMappingSuffix and
use the scheme cms-<language>.lbx. Again if the name of the .lbx files
would become relevant for the end user I would expect the style
documentation to mention it.

From a technical point of view the name of the mapped file is
completely irrelevant (you could even call your variant of dutch.lbx
p-danish-f.lbx) as long as the contents of the file are such that the
mapped language file actually changes the original language.
Peter Flynn
2018-11-03 22:29:28 UTC
Reply
Permalink
Post by Moewe
Post by Peter Flynn
I'm sorry to repeat this, but how do I know which languages and which
biblatex styles require the use of \DeclareLanguageMapping?
Styles that require an explicit \DeclareLanguageMapping should document
that in their manual.
OK, thanks. So it's not programmatically detectable.
Post by Moewe
Since version 3.6 biblatex has had a command called
\DeclareLanguageMappingSuffix{<suffix>} that styles can use to issue
blanket mappings of the form
    \DeclareLanguageMapping{<lang>}{<lang><suffix>}
for all languages. Newer versions of biblatex-apa use this command and
need no explicit \DeclareLanguageMappings any more (hence the passage
quoted above is no longer present in the biblatex-apa documentation).
Ah...this sounds good. What is the <suffix> here? The style name?
Post by Moewe
biblatex did not enforce a particular file name (scheme) for language
mappings, so developers were free to choose whichever name they liked.
OK, thanks. The curse of open-source software strikes again :-)
Post by Moewe
Again if the name of the .lbx files would become relevant for the end
user I would expect the style documentation to mention it.
One of the problems is that the end user may not be aware of the need,
and has almost certainly not read the documentation.
Post by Moewe
From a technical point of view the name of the mapped file is
completely irrelevant
Not if you are trying to automate a publication workflow. Standards are
preferable to a free-for-all. But it looks like
\DeclareLanguageMappingSuffix is a good path.

Thanks very much for the explanation.

///Peter
Moewe
2018-11-04 08:06:52 UTC
Reply
Permalink
Post by Peter Flynn
Post by Moewe
Styles that require an explicit \DeclareLanguageMapping should document
that in their manual.
OK, thanks. So it's not programmatically detectable.
Indeed, there is no command that issues a warning to end users that a
mapping should be used or otherwise registers it as a requirement. I
assume that by now most style authors whose styles need a mapping take
care of issuing the mapping commands for the user.
Post by Peter Flynn
Post by Moewe
Since version 3.6 biblatex has had a command called
\DeclareLanguageMappingSuffix{<suffix>} that styles can use to issue
blanket mappings of the form
    \DeclareLanguageMapping{<lang>}{<lang><suffix>}
for all languages. [...]
Ah...this sounds good. What is the <suffix> here? The style name?
Again up to the developer, I'm afraid. The implicit assumption is that
it would be something related to the style/bundle name, i.e. '-apa' for
biblatex-apa (style=apa) or '-ieee' for biblatex-ieee (style=ieee and
style=ieee-alphabetic).
Post by Peter Flynn
Post by Moewe
Again if the name of the .lbx files would become relevant for the end
user I would expect the style documentation to mention it.
One of the problems is that the end user may not be aware of the need,
and has almost certainly not read the documentation.
Yes, the number of posts in all kind of LaTeX support forums about
biblatex-apa throwing errors or giving weird output because of
\mkbibdateapalongextra certainly proves your point. But I am not
convinced that it would be a huge improvement for those users if the
requirement for a mapping was detectable (If such a command were to
issue only a warning that a mapping is required, it might go unnoticed
or will not be connected with the later error. If such a command were to
issue an error, then I can't see why that command should not apply the
mapping in the first place).

For the most part there should be three situations
1. The style already loads the language mappings, no user interaction is
required.
2. The style does not load the mapping, but needs it. The user has to
load the mapping themselves.
3. The language mapping is optional. Users are free to apply them if
they like.

Obviously situation 1 needs no additional registering of the fact that
the mapping is required.

Situation 2 is unfortunate and I believe that style authors should
strive to turn it into situation 1. But I can't really see how
registering the need for a required mapping would be better than just
applying said mapping.

In situation 3 it would not make sense to register the need for a
mapping since the mapping is optional.
Post by Peter Flynn
Post by Moewe
From a technical point of view the name of the mapped file is
completely irrelevant
Not if you are trying to automate a publication workflow. Standards are
preferable to a free-for-all.
I was referring to biblatex-technicalities (biblatex-nical?), but now
I'm curious: is there a specific use case you have in mind where such
standards would be necessary/useful or is this just a general
observation? It's always possible to recommend best practices to style
developers in the manual, though it is unclear if and how those
practices can be enforced if styles predate them.
Peter Flynn
2018-11-04 14:21:06 UTC
Reply
Permalink
On 04/11/2018 08:06, Moewe wrote:
[...]
Post by Moewe
But I am not
convinced that it would be a huge improvement for those users if the
requirement for a mapping was detectable
No, but for a class developer having to provide for a user community
with an extremely wide of bibliographic requirements (read: university)
it would eventually be nice to be able to load up babel/polyglossia and
biblatex and know that the relevant mappings were being applied. It's
one more thing that the end user doesn't need to know about.

(Yes, it would be nice if users were interested enough to *want* to know
about such things, but we have to deal with users as they are, rather
than how they might be :-)
Post by Moewe
Situation 2 is unfortunate and I believe that style authors should
strive to turn it into situation 1. But I can't really see how
registering the need for a required mapping would be better than just
applying said mapping.
No indeed...so long as something like \DeclareLanguageMappingSuffix
degrades gracefully if it is called when it is not needed.
Post by Moewe
I was referring to biblatex-technicalities (biblatex-nical?), but now
I'm curious: is there a specific use case you have in mind where such
standards would be necessary/useful or is this just a general
observation? It's always possible to recommend best practices to style
developers in the manual, though it is unclear if and how those
practices can be enforced if styles predate them.
Just the case I originally mentioned: trying to invoke a required
mapping programmatically inside a document class where the user probably
has no idea if it is needed or not, and in any case has no idea what a
'mapping' is :-). But from what you say the variance is rare, and may
eventually be overtaken by \DeclareLanguageMappingSuffix

Many thanks for all your help.

///Peter

Loading...