Sort bibliography separately for sources in different languages

edited July 19, 2017
This discussion was created from comments split from: Now available: Zotero 5.0.
  • edited July 19, 2017

    I need to sort Bibliography separately for sources in different languages. I usually use 3 or 4 languages. Do you know if it is possible to specify the language code in a field language and then process it within the macro?

    In the example below they use A000 (empty) vs. B000 (not empty). But I need more flexible solution. Any suggestions? Many thanks in advance!

    <macro name="language-sort">
    <if variable="language">
    <text value="B000"/>
    <text value="A000"/>
  • edited July 19, 2017
    It is based on your exact needs. You can add key variable="language" to the sort page, but this is not the same functionality as you describe in your code.
    Did you try <text variable="language">?
  • edited July 19, 2017
    As far as I know the solution I have quoted above is limited to the functionality of Zotero itself as it doesn't let to read the contents of the Language field.

    I didn't try <text variable="language">. Can you please write an example? As I have very little experience with CSL.
  • That is no problem, but I would like to know what output you expect, exactly.
  • edited July 19, 2017
    1. cyrillic
    ... author title year (а-я, 0-9)
    99. cyrillic
    100. latin
    ... author title year (abc, 0-9)
    110. latin
    111. japanese
    ... author title year

    I want it to be sorted automatically. To achieve that I am ready to fill in the Language field for each source with tags like ru, en, de, ja, etc. Or with full names of languages (though this doesn't matter I guess).
  • Adding <text variable=language /> to the ‘sort’ section of the ‘bibliography’ section of the style should work.
  • Will it then sort in the following order: de, en, ja, ru...? Should I use numbers in the Language field to achieve the desirable sort order?
  • "bibliography section of the style"... do you mean this part?
    <bibliography et-al-min="4" et-al-use-first="1" page-range-format="">
    <key macro="language-sort"/>
    <key macro="author-title"/>
    <key variable="issued"/>

    <layout locale="en" suffix=".">
    <text macro="bibliography"/>

    <layout suffix=".">
    <text macro="bibliography"/>

  • Yes, you can remove the macro=language-sort line and replace it with the one I gave above. I think that adding numbers should work to sort in the order you specify, but that will also breaking other language functionality (e.g., title casing for English items). If that is a problem, you will need to manually reorder the blocks of languages at the final stage of finishing your document.
  • Can you provide your CSL file on It would be an easy way to discuss potential coding.

    can you see it? It's not my code. I am just trying to find out how to adjust its functionality to my needs.
  • Do you need "Cyrillic" "latin" etc. on each line? Or on the head of each "section"?
  • I need something like this:

    1. Владимирцов Б.Я. ... Поездка к кобдоским дэрбэтам летом 1908 г. : [Доложено в заседании Отд-ния этнографии 1909 г.] / Б.Я. Владимирцов. – Санкт-Петербург: тип. М.М. Стасюлевича, 1911. – 33 с.
    2. ...Из находок П.К. Козлова в г. Хара-Хото / А.И. Иванов [и др.]. – Санкт-Петербург: тип. М.М. Стасюлевича, 1909. – 16 с.
    3. Котвич В.Л. ... Монгольские надписи в Эрдэни-дзу / В.Л. Котвич. – Петроград: тип. Рос. акад. наук, 1917. – 205-214 с.
    4. Aalto P. A catalogue of the Hedin collection of Mongolian literature / P. Aalto, S.A. Hedin. – Stockholm,: Statens etnografiska museum, 1953. – 69-108 с.
    5. Poppe N. A Fragment of The Bodhicaryavatara From Olon Sume / N. Poppe // Harvard Journal of Asiatic Studies. – 1954. – Т. 17. – № 3/4. – С. 411-418.
    6. 乌云毕力格. 17世纪20—30年代喀喇沁部的台吉和塔布囊 / 乌云毕力格 // 蒙古史研究(第六辑). – 2000. – С. 6.
  • First, Cyrillic sources are listed, followed by sources in Latin, wrapped up by sources in Chinese characters or Japanese kana.
  • edited July 20, 2017
    O.K. you have three possible ways:
    1. change line 515 from <key macro="language-sort"/> to <key varaible="language"> and define in field language your prefered sorting of languages (for example by number):
    1. Cirilic
    2. Latin
    But it is not the best way because you have to add numbers in the field language and bwiernik describe the loss of functionality if you use non-standard content of language field.

    2. I think, the better way is using any other "unused" field, which is mapped to the CSL variables (see in all types of documents. For example, field Library Catalog is mapped to the variable "source". On another hand, you use old documents in your example so I think, that Library Catalog and Call Number is important for you.

    3. Alternation for this is using any "unused" CSL variable ( and define it in Extra field. Maybe variable "section" or "status" can be usable for you.
    Here is an example for variable "section":
    Add to the extra field:
    section: 1. cyrilic
    etc. for all items
    And change line 515 in your CSL to <key varaible="section">.
  • In my opinion, the best way to address this would be to add a "Bibliography Sort" field to all Zotero type document and add this field to the all the corresponding CSL documents. I imagine this involves a lot of discussions and energy, but this will authorize everyone to make an ordered bibliography what is more and demanded in academic works.
Sign In or Register to comment.