Different language for single reference in bibliography

Is there any way to change the language (guessing by switching locale) for a single reference in the bibliography list? For APA (at least as it's used in Sweden), a reference to a book chapter in English, for example, should be written in English: i.e. Ed./Eds. instead of Red./Reds, pp instead of ss and so on.

Any simple way to do this?
«13
  • There is a way, but it is (as yet) non-standard (the CSL will not validate against the CSL 1.0 schema). Whether it qualifies as simple is a matter of opinion. :)

    The syntax is documented here. I'm working on more detailed documentation of this and other features available in the experimental multilingual client, for inclusion in a book (draft text available here), but I won't get to the multilingual stuff for at least another month.

    If it's only a few references, you're probably best off hand-editing in the final edit for the present.
  • I see, thanks. Although, I'm not really sure where in the CSL file I should put that in? And also, how can I tell Zotero that this or that reference should be cited in a specific language?
  • It's triggered by the "language" variable on the item, or alternatively by the default language of the style if the variable is empty. The examples under the link show how it works; you would move the content of the layout to a macro (if all you're changing is the terms, you can use the same macro for all languages), and then define multiple layouts, giving the macro as the sole content of each. Each layout but the last has a locale attribute, containing the ISO codes of the CSL-supported languages to be applied. I guess you would be defining an "en" layout, falling back to Swedish, and with the default-locale of the style set to Swedish.

    If none of that makes much sense, you're probably safer waiting until this is a little closer to showtime (!).
  • edited August 10, 2012
    I searched a lot to find out how create multilanguage style. So, I installed MLZ, edited this multilanguage style: https://github.com/NovemberZulu/GOST-Numeric-style-for-MLZ and added Lithuanian layout to it, identical to other layouts exept language definition. I described terms (as pages, volumes etc.) in Lithuanian locale. But this stile is not working properly because English and Lithuanian terms are mixed. So I can see Lithuanian terms (such as “t.” instead “vol.” or “nr.” instead “no.”) in Lithuanian reference and vice versa. One term may be Lithuanian, other - English in the same reference. But it is all right with Russian references and terms.

    There is no Lithuanian locale of csl. Can this be the reason of such behavior?

    Or am I doing wrong something? I've read that: http://gsl-nagoya-u.net/http/pub/citeproc-js-csl.html#multilingual-layouts and that: http://forums.zotero.org/discussion/18482/?Focus=96869 I created four layouts (last without localization) but I don't know how to "move the content of the layout to a macro". Should I define entire layout of one language inside one macro and how to do that? Or should I define only terms in such a macro? But where define look of citations or bibliography in such a case if layout must have only one macro? Examples are too simple and my experience too small.

    And this mess with multilanguage styles is main obstacle from moving toward Zotero for me. So is there any solution?
  • @maras,

    I'll be happy to look at your style, and fix any problems that turn up in testing. Can you paste the code of your style to http://gist.github.com, save it as a public gist, and post the URL from the address bar back here?
  • edited August 10, 2012
    Thank you for quick response.

    Here is my modification of Chicago manual style (full note): git://gist.github.com/3315481.git And Lithuanian terms overrides English ones in English references in this case. Lithuanian references are good.

    Here is slightly modified that file (only different terms in locales): git://gist.github.com/3315497.git English terms overrides Lithuanian ones in Lithuanian references there. English references are good.

    Russian terms are OK in both cases.

    I can upload my modification of GOST style too. It produces the same situation - English overrides Lithuanian, but Russian "№" overrides english "no." in English references (all other English terms are OK).

    What are my mistakes? :)
  • I tried to remove default locale in both documents

    <locale>
    <terms>
    <term name="accessed">žiūrėta</term>
    <term name="online">interaktyvus</term>
    </terms>
    </locale>

    but result the same.
  • Here is my modification of Chicago manual style (full note)
    We can start with this one.

    An ordinary CSL style like this one can only output with one locale setting per document; all references will be rendered in the same locale. You can switch locales (for the whole document) by changing the bibliography locale setting in Zotero.

    Alternatively, you can anchor a style to a specific language, by setting a default-locale attribute in the cs:style node (the second line of the style). You can read about that here: http://citationstyles.org/downloads/specification.html#the-root-element-cs-style

    Multiple locales in a single document are possible, following the documents you linked to, but let's get these simpler styles fixed first, and then move on to that.

    The odd behaviour you see in this style is because it is invalid (the syntax of the file is broken). You can get information on validation of CSL styles here: https://github.com/citation-style-language/styles/wiki/Validation

    Here are the validation errors in the version that you posted:

    (1) There is a nesting error at line 44. Move the closing <term/> up by two lines.
    (2) The "mont-1" etc. names need to be "month-01" etc.
    (3) The "lang=" attributes should be "xml:lang="
    (4) There is no "number" term, so that one should be removed.

    Once the style is fixed and validating, you should be able to set default-locale="lt" in the style node, reinstall the style, and switch away from the style and back in any open document to find that the Lithuanian terms are used for all items. Changing to default-locale="en" and going through those steps, you should find English terms everywhere.

    When that's confirmed to work, we'll be ready to go forward to a mixed-language style.
  • I fixed style, but it is not validating. Errors are about locales, as I can understand:
    Error: Attribute locale not allowed on element layout from namespace http://purl.org/net/xbiblio/csl at this point.

    From line 779, column 5; to line 779, column 60

    rue">↩ <layout prefix="" suffix="." delimiter="; " locale="lt">↩

    Error: Element layout from namespace http://purl.org/net/xbiblio/csl not allowed as child of element citation from namespace http://purl.org/net/xbiblio/csl in this context. (Suppressing further errors from this subtree.)

    From line 815, column 4; to line 815, column 60

    ayout>↩ <layout prefix="" suffix="." delimiter="; " locale="en">↩

    Error: Element layout from namespace http://purl.org/net/xbiblio/csl not allowed as child of element citation from namespace http://purl.org/net/xbiblio/csl in this context. (Suppressing further errors from this subtree.)

    From line 851, column 5; to line 851, column 60

    yout>↩ <layout prefix="" suffix="." delimiter="; " locale="ru">↩

    Error: Element layout from namespace http://purl.org/net/xbiblio/csl not allowed as child of element citation from namespace http://purl.org/net/xbiblio/csl in this context. (Suppressing further errors from this subtree.)

    From line 887, column 5; to line 887, column 48

    yout>↩ <layout prefix="" suffix="." delimiter="; ">↩

    Error: Attribute locale not allowed on element layout from namespace http://purl.org/net/xbiblio/csl at this point.

    From line 929, column 5; to line 929, column 35

    sort>↩ <layout suffix="." locale="lt">↩

    Error: Element layout from namespace http://purl.org/net/xbiblio/csl not allowed as child of element bibliography from namespace http://purl.org/net/xbiblio/csl in this context. (Suppressing further errors from this subtree.)

    From line 948, column 5; to line 948, column 35

    yout>↩ <layout suffix="." locale="en">↩

    Error: Element layout from namespace http://purl.org/net/xbiblio/csl not allowed as child of element bibliography from namespace http://purl.org/net/xbiblio/csl in this context. (Suppressing further errors from this subtree.)

    From line 967, column 5; to line 967, column 35

    yout>↩ <layout suffix="." locale="ru">↩

    Error: Element layout from namespace http://purl.org/net/xbiblio/csl not allowed as child of element bibliography from namespace http://purl.org/net/xbiblio/csl in this context. (Suppressing further errors from this subtree.)

    From line 986, column 5; to line 986, column 23

    yout>↩ <layout suffix=".">↩

    There is "fixed" style: git://gist.github.com/3316761.git

    Now Lithuanian terms disappeared completely. I set default locale to ru, lt and en. Terms are English all the time in Lithuanian and English references, but Russian terms all the time in Russian references. Changing default locale changes nothing.
  • edited August 10, 2012
    Sorry, I had missed that your first example also used a multilingual layout. That will indeed throw a validation error against the schema, but the locale attributes are the only error; the style is correct for MLZ.

    You are right that the Lithuanian locale is being ignored because it is undefined. Let me do some testing to see how best to handle undefined locales set within a style, I'll get back in a few hours.

    You might like to prepare a Lithuanian locale for use with CSL generally, by modifying the English locale file here. I'm sure the CSL group will be happy to add it to the official CSL distribution.

    (Edit: amended to reflect the link provided by Rintze below.)
  • Actually, if you're willing to translate the CSL locale file to Lithuanian, please use https://github.com/citation-style-language/locales/blob/1.0.1/locales-en-US.xml as the starting point. We have some translation instructions here: https://github.com/citation-style-language/locales/wiki/Translation-Instructions
  • Well, I am finishing locale draft. Where can I post it? I made comments in it. Some problems must be discussed. Some can be resolved in English, but for some I need help for users of Lithuanian, rather educated users :).
  • edited August 10, 2012
    It should be enough to paste the locale to http://gist.github.com, as you have done with your styles.

    For the multiple language layout issue, I did some testing and found that undefined locales (i.e. a locale defined inside the style, but absent from the CSL locale set) are recognised by the processor. There was a bug, however, that could cause selection of the incorrect locale for some items. I've fixed the bug, and released an updated version of the citeproc-js CSL processor. The simplest way to test with it is to install this plugin, which replaces the CSL processor in Zotero with the latest version.

    If you will be producing documents that span language boundaries, you might take a look at MLZ (Multilingual Zotero). This is a personal project of my own, that (among other things) allows flexible inclusion of translations and transliterations in printed citations. MLZ is not supported by the core Zotero team, and you will want to back up your Zotero database and other files before installing, but it may be useful in your environment.
  • There is a draft of lt_LT locale for CSL: git://gist.github.com/3318667.git Maybe better is to create another thread with questions about it?

    I have MLZ installed and it works perfectly. Thank you for it.

    I'll install new version of plugin to see how it works.
  • edited August 10, 2012
    I've installed plugin. No changes - English terms in Lithuanian and English references and all good with Russian ones.
    Maybe it is due bad construction of my style? It is the same as there: https://gist.github.com/3316761 I only removed default-locale.
  • edited August 10, 2012
    I'll be working on another task for a few hours, but I'll take a look. If you're using the latest version of MLZ (m224), you won't need the processor plugin; it already contains the latest processor version.

    One thing to confirm before I take a look: do you have "lt" set in the Language field of your Lithuanian entries? That's what should trigger the language switch. If that's in place, and the only errors in your style are those locale attributes, you may be experiencing a lingering bug in the processor. I'll take a look in a few hours.
  • edited August 10, 2012
    There is a draft of lt_LT locale for CSL: git://gist.github.com/3318667.git Maybe better is to create another thread with questions about it?
    Yes, please. (and it's slightly handier for us if you copy/paste the URL from the address bar, like https://gist.github.com/3318667, instead of git://gist.github.com/3318667.git )
  • edited August 10, 2012
    @ fbennett,

    Yes, I see, that my Zotero is 3.0m224.
    O yes, I have locales defined. Actually, I am "playing" now with selected types of references and locales: I am testing, how different styles display them. Sometimes I am changing language field from "lt" to "ru" or "en" of selected entries. With "ru" and "en" there is no problem - after such a change terms of references in Writer document also changes (after refresh), as in Zotero CSL Editor or CSL preview. But references in Lithuanian are stuck to English.

    @ Rintze,
    sorry, I didn't notice that.
  • edited August 11, 2012
    @maras: We owe you a round of applause.

    The Lithuanian terms in your style were not turning up due to a processor bug that caused locale nodes with specific xml:lang attributes to be masked in all styles, in both official Zotero and in MLZ. This must have been confusing to many style authors, and I'm very glad get it fixed.

    If you update MLZ to the latest (m225), you should find that your style works as expected. For completeness, you might want to add all of the relevant nodes (style-options, date, and terms) from the locale you have prepared to the style, until your locale makes its way into a CSL release.

    Let me know if you run into any more snags; but I think the tool will start doing its job for you now.

    (Edit: If you haven't yet made major changes to the Chicago Fullnote style on which you're basing your work, you might take a look at the MLZ Chicago Fullnote style as an alternative. It validates against the MLZ extended CSL schema, which permits the multiple layout syntax. Validation works in the same way as for official CSL, but using the alternative schema. (I'll be reorganising the schema source soon, but that repo address will always contain the multilingual version.)
  • I updated MLZ to m225 and... still no luck. I even created two new styles (from MHRA and MLZ-CMS-full), by adding "ru" and "lt" locales to existing "en" and quadruplicated theirs layouts of citation and bibliography ("en", "ru", "lt" and without locale at the end). No other changes. Just to be sure, that not styles created that mess. All of them are not working. Some of them adds Russian terms to Lithuanian references, some - English terms. Lithuanian terms appears only after removing from locale "xml:" before lang="lt". But that creates mess in English and Lithuanian references (some terms Lithuanian, some - English in both, Russian - intact). I can only guess, that processor searches Lithuanian xml file when "xml:lang="lt"".

    I am only testing styles and locales and therefore I am doing only essential changes to styles as described.

    Is there opportunity to validate MLZ styles with validator.nu? I pasted this link: https://github.com/fbennett/schema/tree/multi to schemas field in it, but it validates all, even truly wrong styles.
  • It definitely tests correctly here. It's late here, I'll be going to bed. If you can paste a style that fails for you, and data that fails with it (exported as Zotero RDF), I'll see if I can reproduce the behaviour you describe tomorrow morning.
  • Thank you for you patience and help :).
    There is my style modification: https://gist.github.com/3325436
    There is my references: https://gist.github.com/3325361 Actually they are only for testing purposes, so they aren't real but created to fill as much fields as possible. Two of them are Lithuanian, one - Russian and one - English.
    Hope this will help.
  • edited August 11, 2012
    The style is throwing some English terms in the Lithuanian locale because the Lithuanian term set defined in the style is incomplete, and English is used as an ultimate fallback. Here is a version that includes all of your defined locale terms, which seems to work normally: https://gist.github.com/3328311

    Validation against the MLZ extended CSL schema is a little awkward at present. I'll try to set up an easy validation channel sometime fairly soon, but you should be good with the style above for now.

    (Edit: I made one small set of changes to the processor, to handle the switching of punctuation-in-quotes behaviour across locales in a multi-layout style. You can pick up the changes by updating MLZ.)
  • edited August 11, 2012
    Some of them adds Russian terms to Lithuanian references
    The only way I was able to reproduce this was by setting default-locale="ru" with an incomplete set of Lithuanian terms. In that case, Russian is used as a fallback, and some Russian terms show through in Lithuanian entries. If the Lithuanian locale is fully defined, the terms seem to come out consistently in one language. If you do see mixed terms in cites with a fully defined Lithuanian locale, though, do let me know; that should never happen.
  • Well, now all terms in Lithuanian AND English references are... Lithuanian. I even pasted all en_US locale to en locale of style, but no effect at all. And all OK with Russian references.
    I upgraded MLZ.

    There were some issues with the style file - bigger half of it was red when opened in Gedit. Because some remarks (in <!-- -->) maybe broke the code itself (apostrophe in "don't"). I don't know how this affected code. But there was no changes after I corrected that.

    I think, that these problems will vanish after Lithuanian locale adding to Zotero. But there is languages without locales and it is not good if such a problem will continue.

    Or problem is with my style.
    How my style, modified by you, behaves with English references?

    Now I am going to bed :).
  • edited August 11, 2012
    I think, I managed to success! It is all right with all the languages and terms by setting default-locale="en" of style. Maybe multilingual style must have default locale?

    (Edited. But when default locale is set to "ru" or "lt", all terms are Lithuanian of English and Lithuanian references and Russian - in Russian. I have one idea and will test it soon.)
  • edited August 11, 2012
    Here's what I get with those references and the style I linked above:

    http://img805.imageshack.us/img805/816/mixedlocales.png

    That's all correct, I think.

    Be sure that the language attribute in the locale nodes is set with xml:lang=, and not with plain lang=. The latter is not recognized, so that node would become the fallback. If a locale node in the style was set to <locale lang="lt"> with a full Lithuanian set of terms inside, that would produce the behaviour you describe (i.e. Lithuanian everywhere, unless overridden). But that's just a guess.

    For final debugging, I'll need to see exactly what you are using for the style and for the entries for a specific error. The major wrinkles have all been ironed out, as far as I can tell; the problems are almost certainly with the input, and I'll need to see it directly in order to track down the cause of odd behaviour.

    (Edit: we crossed in the post -- response below.)
  • edited August 11, 2012
    Yay, that's good to hear. The fallback locale can be a little tricky; if a style has no default-locale, the fallback used would (I think) be the Firefox locale, or (maybe) the one that shows in MLZ Preferences -> Languages next to "CSL:". I assumed that it would be English, but it could of course (facepalm) be different in your environment.

    For styles that use multiple layouts, I think our experience today suggests that setting default-locale on the style is indeed a good idea. :-)

    (Edit: crossed in the post with your qualification above. Will look forward to hearing what you turn up. When you have a stable set of data that misbehaves, send it along and I'll take a look.)
  • edited August 11, 2012
    With default-locale="ru", I do get bad output here, with Lithuanian terms in an English entry. This absolutely should not happen. I'll take a look. With luck you'll find it's fixed tomorrow morning.
  • edited August 11, 2012
    Yes, my guess was correct. I've just installed old variant of this style, that wasn't working - without all Lithuanian locale, only some Lithuanian terms described. All terms of English and Lithuanian references were Lithuanian in it. BUT all was corrected when I've set default-locale="en" in style.
    But I must default locale set to "lt" in other bad my style to get it working properly.

    (Edited. So, this depends not on Firefox (Iceweasell in my Debian) or on MLZ preferences.)
Sign In or Register to comment.