plk / biblatex

biblatex is a sophisticated bibliography system for LaTeX users. It has considerably more features than traditional bibtex and supports UTF-8
520 stars 118 forks source link

Multiscript testing for biblatex 4.0 #132

Closed plk closed 8 years ago

plk commented 11 years ago

Placeholder for discussions about testing multiscript branch.

maieul commented 10 years ago

I have juste wanted to test this version, but this example:

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{french}
\usepackage{fontspec}
\usepackage[citestyle=verbose]{biblatex}
\bibliography{test}
\begin{document}

\cite{Simon1686}

\cite{LeClerc1686}

\printbibliography
\end{document}

But I have obtained this message:

/Users/maieul/Library/texmf/tex/latex/biblatex/tex/latex/biblatex/biblatex.sty:
89: Missing = inserted for \ifnum.
<to be read again> 
                   D
l.89 

What I have done:

Noted that the problem is the same with all branch.

What have done wrong?

plk commented 10 years ago

Unless you modify the build.sh script in the git tree to work in your environment, you'll have to pull the 3.0 experimental package from SF. The git tree won't just run as it is. Also, you must be using the latest dev biber from SF (version 1.9).

maieul commented 10 years ago

ok, is it http://sourceforge.net/projects/biblatex/files/experimental/?

maieul commented 10 years ago

Ok, with this version + biber exp, I made the minimal example following:

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{french}
\usepackage{fontspec,xpatch}
\usepackage[citestyle=verbose,bibstyle=verbose]{biblatex}
\bibliography{test}
\begin{filecontents}{test.bib}
@book{Augustin_CD,
    Author = {Augustin},
    Author_Latin = {Augustinus},
    Title = {La cité de Dieu},
    Title_Uniform = {De civitate Dei}}
\end{filecontents}
\begin{document}
\renewbibmacro{title}{\printfield{title} \mkbibparens{\printfield[form=uniform]{title}}}
\cite{Augustin_CD}
\end{document}

Or I have not understand the documentation, or there is a bug in the form option of printfield. Because I obtained:

Augustin. La cité de Dieu (La cité de Dieu)

So \printfield[form=uniform]{title} have not printed the uniform version, even if the .bbl file has correctyl \field[form=uniform]{title}{De civitate Dei}.

plk commented 10 years ago

You need to use \printfield[][form=uniform]{title} as usual with optional args which come after other optional args. Note that "uniform" is really intended for names where a "translated" form doesn't make much sense.

maieul commented 10 years ago

Ok, so there is a problem in the handbook, l. 824-828 of the file biblatex.tex

plk commented 10 years ago

Ah, yes, thanks. This is a first draft of the 3.0 documentation so post here if you find anything else.

u-fischer commented 10 years ago

I have been testing a bit the new "vform" option of biblatex 3.0. And have the following problem: I tried to output two bibliographies. One original and one "romanised". That works perfectly when I start with the option vform=original, but not with vform=romanised. Then the original entries are lost. Is there a solution?

\documentclass{article} \usepackage[style=authoryear,% language=auto,% autolang=langname,% vform = romanised, %fails %vform=original, %works ]{biblatex} %\makeatletter\show\blx@vform

\addbibresource{vbib.bib} \begin{document} \cite{Bai2010} \makeatletter\def\blx@vform{original} \printbibliography \makeatletter\def\blx@vform{romanised} \printbibliography[] \end{document}

@Article{Bai2010, Title = {original title}, Title_romanised = {romanised title}, Author = {orginal author}, Author_romanised = {romanised author}, Year = {2010}, }

Ulrike Fischer

plk commented 10 years ago

Actually, this is correct behaviour. With vform=romanised, the default form for a field with no form specifier when biber reads the .bib is romanised which means that if you have:

author = {foo},
author_romanised = {bar}

The second one overwrites the first since they are both in fact author_romanised. I will add a warning in such cases.

On another topic, from your example, it looks like you would like some public way of switching the global vform which \print* uses?

u-fischer commented 10 years ago

Well currently I simply want to understand the handling of the new field forms. So I play around. But it looked to my as a quite logical task to try to print an "original" and a "romanised" version of a bibliography. In my eyes "activating vforms" should be a "global" option, but the vform used should be set locally.

plk commented 10 years ago

I am undecided about this at the moment - I appreciate your input. At the moment, if you want to be safe nomatter what you set the vform option to, change your .bib to:

@Article{Bai2010,
Title_original = {original title},
Title_romanised = {romanised title},
Author_original = {orginal author},
Author_romanised = {romanised author},
Year = {2010},
}

That is, just make the form explicit so that the vform option doesn't assume that fields with no explicit form are supposed to be the same as vform. This is safe in general to do since the default vform is original anyway. This makes your example work with both vform settings.

I have added new \vform, \vlang and \vtranslang commands so that switching these globally doesn't need the use of an internal macro. These new commands are documented and in the 3.0 biblatex I have just uploaded.

u-fischer commented 10 years ago

Hm. Yes making them explizit works, but imho it it not a suitable strategie for the general case. E.g. Assume someone wants to create bibliographies in two languages:

 \documentclass{article}
 \usepackage[english,ngerman]{babel}
 \usepackage[style=authoryear,%
        language=auto,%
        autolang=langname,%
        vform=translated,
        vtranslang=ngerman,
       ]{biblatex}

 \addbibresource{vbib.bib}
 \begin{document}
 \cite{Bai2010}

 \printbibliography

 \selectlanguage{english}
 \makeatletter\def\blx@vtranslang{english}
 \printbibliography[]
 \end{document}

 @Article{Bai2010,
   Title                     = {original title},
   Title_translated_english  = {english title},
   Author                    = {A author},
   journal={journal},
 }

It would be quite a nuisance to have to repeat author and journal and other fields which actually don't need a translation. Imho one needs for variant fields a way to declare a "fallback".

plk commented 10 years ago

You are right that this should work. I have uploaded new versions of experimental biblatex and biber.

Here is your example with the new macros which works for me:

\documentclass{article}
\usepackage[english,ngerman]{babel}
\usepackage[style=authoryear,%
        language=auto,%
        autolang=langname,%
        % vform=translated,
        % vtranslang=ngerman,
       ]{biblatex}

\addbibresource{vbib.bib}
\begin{document}
\cite{Bai2010}

\printbibliography
\selectlanguage{english}
\vform{translated}
\vtranslang{english}
\printbibliography[]
\end{document}

Note the commented biblatex options - I don't think you need these for this example - your .bib is implicitly ngerman. There are new commands \vfallbackon and \vfallbackoff which turn on/off the fallback behaviour. Default is on. When this is on, fields fall back to the global form/lang/translang defaults if no field with the currently modified globals (set via \vform, \vlang and \vtranslang) exists.

u-fischer commented 10 years ago

There is a spurious space before the author if the fallback is used. Imho it is from here:

 \def\blx@imc@ifbibfieldvx#1#2#3{%
     \ifcsdef{blx@vbibfield@#3}
       {\edef\blx@tempa{\@empty}%
        \edef\blx@tempb{\@empty}%
        \ifblank{#2}%[]{field}
          {}
          {\IfNoValueTF{#2}%{field}
            {}
            {\setkeys{blx@v}{#2}}}%
        \ifdefempty\blx@tempa
          {\edef\blx@tempa{\blx@vform}}
          {}%
        \ifnum\pdf@strcmp{\blx@tempa}{translated}=\z@
          \ifdefempty\blx@tempb
            {\edef\blx@tempb{\blx@vtranslang}}
            {}%
        \fi%
        \ifdefempty\blx@tempb
          {\edef\blx@tempb{\blx@vlang}}
          {}%
        \ifcsundef{abx@#1@#3@\blx@tempa @\blx@tempb}
          {\edef\blx@tempa{\blx@ovform}%
           \ifnum\pdf@strcmp{\blx@tempa}{translated}=\z@
             \edef\blx@tempb{\blx@ovtranslang}%<--- perhaps too
           \else
             \edef\blx@tempb{\blx@ovlang}%<---------------
           \fi}%
          {}%
        \@firstoftwo}
       {\@secondoftwo}}

Beside this it seems to work fine. Ulrike

plk commented 10 years ago

Thanks, I've corrected the space problems and uploaded again.

u-fischer commented 10 years ago

I have started to test how to add the variants in the entries and found a side effect of the fallback: Now the variant version of \iffieldundef etc always gives true so one has to disable the fallback before the tests. I also found that the alias for journaltitle, journal is not variant aware.

 \documentclass{article}
 \usepackage[english,ngerman]{babel}
 \usepackage[style=authoryear,%
         language=auto,%
         autolang=langname,%
         % vform=translated,
         % vtranslang=ngerman,
        ]{biblatex}

 \addbibresource{vbib.bib}

 \renewbibmacro*{title}{%
    \printfield{title}%
    % \vfallbackoff
     \iffieldundef[form=translated,lang=english]{title}{}{\addspace\mkbibparens{\printfield[][form=translated,lang=english]{title}}}%
    % \vfallbackon
    }

 \begin{document}
 \nocite{*}

 \printbibliography

 \vform{translated}\vtranslang{english}
% check the journal title:
 \printbibliography
 \end{document}

 @Article{Bai2010,
   Title                     = {original title},
   Title_translated_english  = {english title},
   Author                    = {A authorG and B bauthorG},
   Journaltitle              = {journaltitle},
   journaltitle_translated_english={english journaltitle},
   pages                     ={2-100},
   Year                      = {2010},
 }

 @Article{Bai2010x,
   Title                     = {original title},
   Author                    = {A authorXX},
   Journal                   = {journal},
   journal_translated_english= {english journal},
   pages                     = {2-100},
   Year                      = {2010},
 }
u-fischer commented 10 years ago

I will test the fallback change when its online. I tumbled over the next question (easter monday and nothing else to do ;-)): I can quite easily add the variants to simple fields. E.g. with

 \DeclareFieldFormat{titlecase}{\mkbibemph{#1}%
   \vfallbackoff
     \iffieldundef[form=translated,lang=english]{title}{}{\addspace\mkbibparens{\printfield[][form=translated,lang=english]{title}}}%
    \vfallbackon}

But what can be done with (name) lists? How could I print "AuthorA (AuthorA romanised), AuthorB and AuthorC (AuthorC romanised)?

There are two problems here: How to retrieve part X from another name list, and how to mark an "empty" position. E.g. if already the original entry of authorB is romanised and you don't want to get a double (imho if the first problem is solved the second should be easy with some \dummyname).

plk commented 10 years ago

The too-eager fallback should be fixed and uploaded (just biblatex) - it should only happen now when you are picking up a variant via the global form/lang/translang setting and not when you specify a variant explicitly.

The journal/journaltitle problem is more complicated - it's something I haven't done yet - make sourcemaps apply to all variants in certain cases (journal is sourcemapped to journaltitle and that's the problem). I'm looking into it.

The name thing is very hard. It would require a complete rewrite of the .bbl format for names at the very least.

u-fischer commented 10 years ago

Do you really think that the name thing is so complicated? I got the impression that all the needed information is already there. I actually managed to output the names by using

\setcounter{tempcounter}{\c@listcount}%
\mkbibparens{\printnames[last-first-simple][\value{tempcounter}-\value{tempcounter}][form=translated,lang=english]{author}}

in a DeclareNameFormat. But I don't like this as it is easy to get in a loop if the internal \printnames use the same format as the outer, also it is difficult to test the content. Couldn't one use \blx@namesetup to grab the data and create temporary fields "author-1" etc?

plk commented 10 years ago

biber is updated with a fix for the general variant mapping problem - your journal/journaltitle problem should be fixed now. The names thing is a bit complex if you need to specify different variants per individual name in the data source. There is no way bibtex format files will do that - it would need something more extensible like the biblatexml format (which is experimental and can't do this yet either). I see what you mean about the name list information being available between name lists. Hmm. I need to think about this a bit.

u-fischer commented 10 years ago

I have thought about the name problem too. I realized that the main problem is not accessing the data but the formatting: As names are not a simple data field but a sort of array it doesn't make much sense to try to use the "raw" data as with e.g. \thefield{url}. One will always need something like \printnames to get a sensible output like I did above. So perhaps one could simply create a "\printinnernames" and a \DeclareInnerNameFormat which uses it owns bunch of counters and its own set of name formats and so could be used safely in a \DeclareNameFormat.

u-fischer commented 10 years ago

On the french usenet group fr.comp.text.tex there was a related discussion: Someone wanted to mix the list of publishers with the list of locations. Paul Gaborit came up with a proposition which looks like mine: He used a inner \printlist command: https://groups.google.com/forum/#!topic/fr.comp.text.tex/pxQ503gcmsU

plk commented 10 years ago

@u-fischer - Please try the biblatex 3.0 on SF. See the documentation for \printnameelement and \printlistelement. These macros are designed to be used inside name/list formats to do exactly this. They have their own format declaration macros (\DeclareNameElementFormat and \DeclareListElementFormat) which won't clash with normal name/list formats (so you can even use the same format name).

u-fischer commented 10 years ago

This looks very good. I can without problems handle also the case of a "non-russian" name in the list with e.g.

 AUTHOR = {Schmitz, Walter and BulgakovR, PavelR and RosenfeldR, BorisR},
 AUTHOR_uniform = { * and Bulgakov, Pavel and Rosenfeld, Boris},

and then a test

 \DeclareNameElementFormat{test}{%
   \ifstrequal{#1}{*}{}{%
   \mkbibparens{\mkbibemph{#1}, \mkbibemph{#3}}}}

But imho it would be useful that before this is released in the wild there where some agreement what to use for "empty" elements in a list to avoid that every bib-files uses its own element marker.

Btw: AUTHOR_uniform = { {} and Bulgakov, Pavel and Rosenfeld, Boris} didn't work. It leads to unbalanced entries in the bbl.

plk commented 10 years ago

This is now an option in biber 2.0 - --variant-null-name and it defaults to '*'. This marker will be removed in the .bbl and so is guaranteed to be null in biblatex tests so you can test for a null name with \ifstrempty (see updated example in 3.0 docs).

u-fischer commented 10 years ago

I realized that one run into problem with sorting of the romanized variant if authors are missing completly. So I think a syntax like

     AUTHOR = {Schmitz, Walter and BulgakovR, PavelR and RosenfeldR, BorisR},
     AUTHOR_uniform = {\dummyname{Schmitz} and Bulgakov, Pavel and Rosenfeld, Boris},

make more sense, even if it means more work during the input. But I don't know how exaclty biber would handle this. Would this give the correct sorting? Also I'm currently thinking about a good test for the "\dummyname". Or could biber replace it after the sorting? (I don't know when in the process sorting is actually done).

plk commented 10 years ago

I think what I'll do is to have the sorting routines, when they find a null list element, use the corresponding element from the generic variant since that's what the nulls refer to. So:

AUTHOR = {Schmitz, Walter and BulgakovR, PavelR and RosenfeldR, BorisR},
AUTHOR_uniform = {* and Bulgakov, Pavel and Rosenfeld, Boris}

would sort the uniform variant as:

AUTHOR_uniform = {Schmitz, Walter and Bulgakov, Pavel and Rosenfeld, Boris}

This will also all work for other lists (not just name lists) and also for label creation.

u-fischer commented 10 years ago

It's certainly a sensible behaviour to pull the value from the generic variant.

(Also because the "\dummyname" doesn't work correcty. E.g. this here

 AUTHOR_uniform = {\dummyname{Schmitz, Walter} and Bulgakov, Pavel and Rosenfeld, Boris},

leads to

 {{hash=4b1211b5da9362c7a874eeec4155825e}{\dummyname{Schmitz,\bibnamedelimb Walter}}{\\bibinitperiod}{}{}{}{}{}{}}%

which doesn't look right (see the \ before bibinitperiod and the missing firstname interpretation).

u-fischer commented 10 years ago

Could the lang-key use \edef instead of \def:

\define@key{blx@v}{lang}{\edef\blx@tempb{#1}}

This would allow to write something like \printfield[][form=\mycurrentform,lang=\mycurrentlang]{title}

and use it together with \newcommand\mycurrentform{romanised} \newcommand\mycurrentlang{}

With the current definition of the key, lang=\mycurrentlang isn't recognized as empty and the romanised variant is not printed.

plk commented 10 years ago

Yes, good idea, I'll do that.

plk commented 10 years ago

Please pull 2.0/3.0 again - all of the discussed enhancements are now implemented. Note that the biber option which defines the null name marker is now renamed to --variant-null-list as it can also apply to non-name lists.

u-fischer commented 10 years ago

I have been trying now to write the first real style. And I think it is still not working as wanted. Take this example:

 \documentclass{article}
 \usepackage[english]{babel}
 \usepackage[autostyle]{csquotes}
 \usepackage[style=authoryear,%
             language=auto,%
             autolang=langname,%
             vform=romanised,
            ]{biblatex}

 \addbibresource{problem.bib}

 %\usepackage{citeall}
 \begin{document}
 %\citeall
 \cite{testmissingauthors} \cite{testsorting}

 \printbibliography
 \end{document}

with this bib: @article{testmissingauthors, author={Schmitz, Walter and Li,Wang}, author_romanised={* and LiRomanised, Wang}, title={test missing authors}, year={2014} }

@article{testsorting,
author={Abe, Albert},
title={test sorting a},
year={2014}}

This leads to labels "and LiRomanised 2014" and the entry is sorted before the Abe, so the sorting is wrong.

Currently it looks that if one would like to use two variants in one document one gets the best results with author_romanised ={Schmitz,Walter and LiRomanised, Wang}, author_original ={Schmitz,Walter and Li, Wang}, and then compare the hash to avoid things like "Walter Schmitz [romanised: Walter Schmitz]".

(author_original is needed so that one doesn't loose the original informations when vform is used).

Btw: While writing this comment I saw that the order of the author fields matter:

 author={Schmitz, Walter and Li,Wang},
 author_romanised={Schmitz,Walter and LiRomanised, Wang},

gives a different bbl then

  author_romanised={Schmitz,Walter and LiRomanised, Wang},
  author={Schmitz, Walter and Li,Wang}, 

In the second case I don't get the romanized names in the bbl. Imho this is a bug ;-).

u-fischer commented 10 years ago

I have been thinking a bit why I run in new problems everyday. I think the core of the problem is that I want to use variants in different, conflicting ways regarding the handling of missing fields and missing parts of lists:

  1. A variant can be a main" variant, e.g. if one wants to use romanised citatations and a romanised bibliography in an english journal. Such a general change should be done with "vform=romanised". In this case missing fields should be avoided and so pulled if possible from another variant and missing parts in name list should be filled somehow too. I'm a bit vage here about the origin of the fallbacks as the informations in the generic field is naturally the obvious candidate (and should be used now) but I can imagine that in the future someone would like to give more detailed instruction: "fill up a romanised variant first with uniform then with translated_english and then with generic". Or "fill up chinese first with transscript_traditional then with transscript_modern then with generic".
  2. A variant can be used to provide additional information like in "Булгаков, Павел (Bulgakov, Pavel)". In this case one does not want to repeat informations, one does not want "Walter Schmitz (Walter Schmitz)" or Title (Title). In the case of list there is the additional complication that one would probably like to get "Paris, London (Londres) and Lüttich (Liège)" but "Paris, London and Lüttich (Paris, Londres et Liège)". So let out Paris if the list is splitted but not in the full list.

I don't know very much about about the inner working of biber/biblatex but my impression is that 1. (filling up) should be handled by biber but 2. is something which should be handled by biblatex styles.

  1. I would suggest that as a first step when vform and vlang are used biber ensures that the created generic variant is "full", that is fills up missing names in lists by the names of the generic variant so that in my example above author_romanised={* and LiRomanised, Wang}, is handled like.
    author_romanised={Schmitz,Walter and LiRomanised, Wang}, Then every variant can be used as "main" without loosing fields and names. In the long run biber could perhaps offer source maps which allow to declare how to fill up variants. Then one could switch safely to another "main" variant with \vform in a document e.g for a second bibliography.
  2. For the biblatex part one need tests: Useful would be \ifnameelementequal{pos}[var specs]{namelist1}[var specs]{namelist2}
    and \ifnameelementempty[pos]{var specs]{namelist} (Both tests could use the hash) and similar tests for listelements. In the long run one will perhaps need some tests to compare other fields for equality.

Addition: Also -- to be able to get complete lists like "Paris, Londres et Liège" -- it would be useful if one could locally/temporarly replace the empty elements in one (name) list by the elements on the same position of another (name) list. It is naturally theoretically possible to create such lists also by some clever combination of \DeclareNameFormat and \printnamelement/DeclareListFormat and \printlistelement but some of the standard formats are quite complicated beast, which use a lot of bib-macros to get all the punctuation right and it would need a lot of work to reproduce this. Imho it is much more effective to first fill up if necessary the list and then to print it with the normal, existing formats.

plk commented 10 years ago

You're right about this. I am looking into implementing a variant fallback chain specification and having filling of list nulls and biber field queries depend on this. This will go a long way to solving these issues. I'll update here when you can pull again and we'll see where we are. You are also right that we'll need the macros in 2. above because if biber fills list nulls, then tests have to be based on name hashes or list elements and not simply using \ifempty. If you want to try to write those macros while I look at the biber side ...

u-fischer commented 10 years ago

Regarding the fallback: For normal fields the source mapping already seems to contain everything that is needed. E.g. before "romanising" I stored the original values with step like:

\step[fieldsource=author,  fieldset=author,  fieldsetform=original,fieldsetlang=default,origfieldval]
\step[fieldsource=title,   fieldset=title,   fieldsetform=original,fieldsetlang=default,origfieldval]
\step[fieldsource=location,fieldset=location,fieldsetform=original,fieldsetlang=default,origfieldval]
\step[fieldsource=editor  ,fieldset=editor,fieldsetform=original,fieldsetlang=default,origfieldval]

That works fine. The only problem are lists as there is not sensible access to the elements (I thought a bit about match and replace but couldn't imagine something straightforward).

I also already tried to extract the elements from a list to test their equality. In theory imho it is possible, in practice it is a bit difficult as I don't know enough about the data structure and the tools to extract the data and and what to do if one has to consider refsection, form, language and all the other informations. Also while I'm quite good at debugging and testing and reading code, I'm not so good at writiing complex code ... But if someone could give me more informations I could certainly help.

plk commented 10 years ago

Ok, this was quite complex and it's not completely done yet. I have implemented a fallback chain - see \DeclareVariantFallbacks in the doc. This fixes the problems you mention above about order-sensitivity etc. Biber won't now remove any information about variants in the .bbl. It also resolves null list elements using the fallback chain.

The fallback chain also is used to resolve fallbacks for sorting, label creation, inheritance etc. so that if you have, say vform=romanised as a global setting but there is no romanised form for a field used in sorting, it will fall back using the fallback chain. This prevents you from having to redefine all sorting, label, inheritance specs to match a romanised use case (which you can always do if you want really fine-grained control).

We still need the macros you mentioned above as now a simple \ifempty test will not work for null list items as biber has already filled them and so the test has to be a text or hash match.

u-fischer commented 10 years ago

Sorry I nearly missed your mail. It sounds very promising but I won't have time the next days to test it. But I will do it next week.

u-fischer commented 10 years ago

I finally found some time to do more testing about mulitlanguage/multiscripting. I downloaded the last biblatex/biber experimental (small problem: The doc-folder contains one for biblatex 2.9 and one named biblatex 3.0 documentation but seems to be for 4.0)).

I'm trying to setup some simple test files and I'm currently stuck at a simple example. I'm not sure if I'm overseeing something simple or if something broke in the last update:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[autostyle]{csquotes}
\usepackage[style=authortitle,%
            vform=translated,
            vlang=english
            ]{biblatex}

\addbibresource{variant.bib}

\begin{document}
\addsec{Document type}

one language (english)

\addsec{Goal}

If possible citations and the bibliography should use the translated english language variants.
If they don't exist they should fallback to the generic or the original variant.

\addsec{Tests}

\minisec{testenglishauthor}
\begin{labeling}{expected output\quad}
\item[Expected output] LiEng, Title testenglishauthor
\item[Real output]     \cite{testenglishauthor}
\item[missing]         labelname doesn't use english variant
\end{labeling}

\minisec{testenglishtitle}
\begin{labeling}{expected output\quad}
\item[Expected output] Li, Title translated testenglishtitle
\item[Real output]    \cite{testenglishtitle}
\item[missing] labeltitle don't use english variant
\end{labeling}

\minisec{testnovariants}
\begin{labeling}{expected output\quad}
\item[Expected output] Muster, title testnovariants
\item[Real output]    \cite{testnovariants}
\item[OK]
\end{labeling}

\printbibliography

\minisec{Problems in the bibliography}
Many fields are missing.
\end{document}

Variant.bib contains these entries:

@article{testenglishtitle,
 author={Li, Wang},
 title={Title testenglishtitle},
 title_translated_english={Title translated testenglishtitle},
 journal={journal},
 year={2014},
 }

@article{testnovariants,
 author={Muster, Max},
 title={title testnovariants},
 journal={journal},
 year={2014}
 }

@article{testenglishauthor,
 author={Li, Wang},
 author_translated_english={LiEng, Wang},
 title={Title testenglishauthor},
 journal={journal},
 year={2014},
 }
plk commented 10 years ago

For me, only the first case fails and this is because the labelname definition is a separate thing. Adding this to your preamble makes all three cases work for me:

\DeclareLabelname{%
  \field[form=translated,lang=english]{author}
  \field[form=romanised]{author}
  \field{author}
}
u-fischer commented 10 years ago

Hm. Well either I was blind yesterday or I changed something. Now the labeltitle works for me too. And I tried yesterday to redefine the labelname-Format and it didn't work either but now it does.

What about all the missing fields in the bibliography?

(I also think that something will have to be done with labelname, so that one doesn't have to add tons of to all sorts of documents).

\DeclareLabelname{%
\field[form=translated,lang=english]{shortauthor}
\field[form=romanised]{shortauthor}
\field{shortauthor}
\field[form=translated,lang=english]{author}
\field[form=romanised]{author}
\field{author}
\field[form=translated,lang=english]{shorteditor}
\field[form=romanised]{shorteditor}
\field{shorteditor}
....
}
plk commented 10 years ago

Missing fields? Yes, I think I'll automatically check the default form/lang version of any unqualified variants so that:

\DeclareLabelname{%
\field{author}
\field{shortauthor}
}

is the same as

\DeclareLabelname{%
\field[form=translated,lang=english]{author}
\field[form=translated,lang=english]{shortauthor}
}

when vform=translated and vlang=english.

u-fischer commented 10 years ago

With missing fields I mean the output of \printbibliography. None of the entries is complete: e,g, the journal is missing everywhere. author and title in some of the entries. The only thing that works is the (no variant aware) year:

I get this as output:

“Title translated testenglishtitle”. In: (2014). LiEng, Wang. In: (2014). In: (2014).

I found a way to get everywhere the expected output. But it only works if one doesn't use the global vform/vlanguage-options:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[autostyle]{csquotes}
\usepackage[style=authortitle,%
          %  vform=translated,
          %  vlang=english
            ]{biblatex}

\addbibresource{variant.bib}

\DeclareLabelname{%
 \field[form=translated,lang=english]{shortauthor}
 \field{shortauthor}
 \field[form=translated,lang=english]{author}
 \field{author}
 \field[form=translated,lang=english]{shorteditor}
 \field{shorteditor}
 \field[form=translated,lang=english]{editor}
 \field{editor}
 \field[form=translated,lang=english]{translator}
 \field{translator}
}

\DeclareLabeltitle{%
  \field[form=translated,lang=english]{shorttitle}
  \field{shorttitle}
  \field[form=translated,lang=english]{title}
  \field{title}
}

\AtBeginDocument{\vform{translated}
                               \vtranslang{english}}

\begin{document}

\addsec{Document type}

one language (english)

\addsec{Goal}

If possible citations and the bibliography should use the translated english language variants.
If they don't exist they should fallback to the generic or the original variant.

\addsec{Tests}

\minisec{testenglishauthor}
\begin{labeling}{expected output\quad}
\item[Expected output] LiEng, Title testenglishauthor
\item[Real output]     \cite{testenglishauthor}
\item[OK] 
\end{labeling}

\minisec{testenglishtitle}
\begin{labeling}{expected output\quad}
\item[Expected output] Li, Title translated testenglishtitle
\item[Real output]    \cite{testenglishtitle}
\item[OK] 
\end{labeling}

\minisec{testnovariants}
\begin{labeling}{expected output\quad}
\item[Expected output] Muster, title testnovariants
\item[Real output]    \cite{testnovariants}
\item[OK]
\end{labeling}

\minisec{citetitle command}
\begin{labeling}{expected output\quad}
\item[Expected output] title testnovariants, Title translated testenglishtitle
\item[Real output]    \citetitle{testnovariants}, \citetitle{testenglishtitle}
\item[OK]
\end{labeling}

\minisec{bibliography: OK}
\printbibliography
\end{document}
u-fischer commented 10 years ago

I now wanted to test combinations. That means to print "author (author romanised)". That is not really problematic with normal fields, but how could this be done with labelname and labeltitle? I don't know if the content of labelname is the author or the editor or something else. Do I have to compare it will all possible source candidates first?

plk commented 10 years ago

You're right about the explicit label declarations (comment before last). This is because the fallbacks fallback from the \vform/\vtranslang/\vlang settings to the global defaults. However, the labels are generated by biber and so can't see the \vform/\vtranslang/\vlang settings and so the selection criteria for label fields has to be explicit as it can't possible be context sensitive in the document.

The other problem - this is a good point which I was looking into. I will probably make some more fields available to say exactly which variant of which field was chosen to generation the label* fields. We already have a similar concept with the field datelabelsource.

plk commented 10 years ago

I've updated biblatex 4.0 and biber 4.0 experimental wilth all fixes to date. They now support the new fields:

labelnamesourcefield
labelnamesourceform
labelnamesourcelang
labeltitlesourcefield
labeltitlesourceform
labeltitlesourcelang

which give information on where labelname and labeltitle come from.

maieul commented 10 years ago

Actually, there is now way to chose the variant of a specific field except with modifiying everywhere \printfield{field} to \printfield[variant=xxx]{}, with, for complex styles, the risk of omission. Should it be possible \vform and \vlang take a option, like this \vform[title]{uniform},\vform[location]{translated} ?

plk commented 10 years ago

Well if you need different variants per field, that's just "msmode=entry". If you need to pick out different variants for each field in "msmode=db", then you should really use \printfield[variant ...]{field}.

maieul commented 10 years ago

ok, that was just a suggestion to make easier the life of styles author, in the case of msmode=db. But that is just a plus, not a need.

plk commented 8 years ago

Closing for now as this is on hold.