Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package babel Error: There is no ini file for the requested language #757

Closed
XiangyunHuang opened this issue Apr 29, 2022 · 15 comments
Closed

Comments

@XiangyunHuang
Copy link

An reproducible example

  1. create skeleton quarto book.

  2. add lang: zh to _quarto.yml.

  3. Click Render Book button to build PDF document.

partial log

pandoc 
  to: latex
  output-file: index.tex
  standalone: true
  toc: true
  number-sections: true
  top-level-division: chapter
  pdf-engine: xelatex
  variables:
    graphics: true
    tables: true
  default-image-extension: pdf
  filters:
    - crossref
    - citeproc
  
metadata
  crossref:
    chapters: true
  documentclass: scrreprt
  papersize: letter
  classoption:
    - DIV=11
    - numbers=noendperiod
  header-includes:
    - '\KOMAoption{captions}{tableheading}'
  block-headings: true
  lang: zh
  bibliography:
    - references.bib
  title: quarto-zh
  author: Jane Doe
  date: 4/29/2022
  
runnning xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  
updating tlmgr

updating existing packages

compilation failed- error
Package babel Error: There is no ini file for the requested language
(babel)                (: ). Perhaps you misspelled it or your
(babel)                installation is not complete..

See the babel package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.208 \babelprovide[main,import]{}
                                   

see /Users/xiangyun/Documents/Github/quarto-zh/index.log for more information.

Here is a full log file index.log

Session Info

xfun::session_info(c("rmarkdown", "quarto","knitr"),dependencies = F)
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.3.1, RStudio 2022.2.1.461

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  knitr_1.39     quarto_1.1     rmarkdown_2.14

Pandoc version: 2.18

I use Quarto Version 0.9.309 which installed from brew install quarto

@cderv
Copy link
Collaborator

cderv commented Apr 29, 2022

Does this happens only with Quarto Books ?

@XiangyunHuang
Copy link
Author

Yes.

@cderv
Copy link
Collaborator

cderv commented Apr 29, 2022

I can reproduce using Quarto book but I also have the issue with a single document. Can you retry with a single qmd file (out of quarto book project) ? I tried example from

---
title: "demo"
format: 
  pdf:
    lang: zh
    keep-tex: true
---

# 标题

got the same

compilation failed- error
Package babel Error: There is no ini file for the requested language
(babel)                (: ). Perhaps you misspelled it or your
(babel)                installation is not complete..

See the babel package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.144 \babelprovide[main,import]{}

I think this is an issue related to jgm/pandoc#7945 which lead to a change in pandoc's template that we don't have yet in Quarto jgm/pandoc@bc7f749

\fi
\babelprovide[main,import]{$babel-lang$}
$for(babel-otherlangs)$

With Pandoc 2.18, when lang it should fill in also babel-lang by paring the lang attributes as bcp47 - see recent changes in Pandoc 2.18 NEWS file. It seems babel-lang was converted from lang to something empty. So the change made in pandoc to fix this, was to bypass babel for Chinese language, relying only on xeCJK (which seems to be the among advice https://latex3.github.io/babel/guides/locale-chinese.html). So there may still be an issue on why Pandoc does not convert lang: zh to correct language.

I don't know why Pandoc does not manage to do the correct conversion. It seems something that would need to be improve and the pandoc maintainer is asking for help on this. jgm/pandoc#7945 (comment)

By the way, you can look into the tex file produced by adding keep-tex: true in the YAML under pdf. The error arise at
l.208 \babelprovide[main,import]{} because a lang is missing in the curly braces. Pandoc should add babel-lang in there which is a conversion of lang

So it seems to a Pandoc issue. I don't know how babel should work for Chinese writing. @yihui do you have insights to help on the Pandoc issue ? Or not using babel but another specific CTAN package the usual option ?

Slightly related: @dragonstyle what is our process to keep template up to date with the Pandoc version we are including in quarto ? It seems like we don't benefit from their last fix yet.

Hope it helps

@XiangyunHuang
Copy link
Author

Thanks for digging this, I get the same issue when I just use

---
title: "demo"
format: 
  pdf:
    lang: zh
    keep-tex: true
---

# 标题

@cderv
Copy link
Collaborator

cderv commented Apr 29, 2022

Thanks for the confirmation. So I really think this is a Pandoc issue first. Meaning this would work probably in Pandoc 2.18 but \babelprovide{} command would not be in the tex file, per jgm/pandoc#7945
if you have insights about babel usage with language zh, you could probably comment there too to help

@XiangyunHuang
Copy link
Author

XiangyunHuang commented Apr 29, 2022

There are any other ways to translate instead of lang: zh?

---
title: "demo"
documentclass: ctexart
format: 
  pdf:
    keep-tex: true
---

# 标题

::: {#thm-line name="相合性"}
The equation of any straight line, called a linear equation, can be written as:

$$
y = mx + b
$$
:::

See @thm-line.

::: callout-note
Note that there are five types of callouts, including: `note`, `tip`, `warning`, `caution`, and `important`.
:::

Here is output of above qmd

截屏2022-04-29 21 14 09

@yihui
Copy link
Contributor

yihui commented Apr 29, 2022

So it seems to a Pandoc issue. I don't know how babel should work for Chinese writing. @yihui do you have insights to help on the Pandoc issue ?

@cderv I don't have much experience here. I have never tried to set the lang option before.

There are any other ways to translate instead of lang: zh?

@XiangyunHuang I'm surprised that documentclass: ctexart doesn't work (theorem labels are not automatically translated). I don't know why.

@XiangyunHuang
Copy link
Author

When I try to add list of tables/figures,

---
title: "demo"
documentclass: ctexart
format: 
  pdf:
    keep-tex: true
    toc: true
    lof: true
    lot: true
---

截屏2022-04-29 21 32 27

They are alse not translated.

@cderv
Copy link
Collaborator

cderv commented Apr 29, 2022

Oh I see now. The translation of this part is directly related to Quarto internationalization feature: https://quarto.org/docs/authoring/language.html . Quarto is using the same lang option to determine which language file to use.

I believe this is conflicting with the error with Pandoc template. Probably when we have the template fix ported (ignore babel-lang when it is empty), it should work fine.

As a workaround, note that you can customize any value of the translation (https://quarto.org/docs/authoring/language.html#alternate-language) or download the language file and use it in the YAML directly: https://github.com/quarto-dev/quarto-cli/tree/main/src/resources/language

language: _language-zh.yml    

it should work. I can't test, as I don't have a valid font available 😓

@dragonstyle
Copy link
Collaborator

It looks like we have some missing template updates from pandoc 2.18 (we have a new tool to update our pandoc dependency which also generates template diffs, but that tools came online right when pandoc 2.18 was release so we didn't use It). I'll update the template now.

@cderv
Copy link
Collaborator

cderv commented Apr 29, 2022

Thanks @dragonstyle. Once there are a new release @XiangyunHuang you could try again adding lang: zh and the correct translation file should be picked. And pandoc should not error anymore...

Hopefully using lang: zh won't mess up things anymore with pandoc

@dragonstyle
Copy link
Collaborator

Ok, I've updated the template here: a39271c and the release https://github.com/quarto-dev/quarto-cli/releases/tag/v0.9.327 contains the updated template. Apologies for missing the update!

@XiangyunHuang
Copy link
Author

Thanks for all of you! The problem is solved.

@cderv
Copy link
Collaborator

cderv commented Apr 29, 2022

Thanks @dragonstyle !

@dragonstyle
Copy link
Collaborator

@cderv @yihui and @XiangyunHuang did all the real work here- thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants