latex3 / babel

The multilingual framework to localize LaTeX, LuaLaTeX and XeLaTeX
https://latex3.github.io/babel/
LaTeX Project Public License v1.3c
130 stars 35 forks source link

plain TeX: unknown command `\begindocument` #119

Closed lemzwerg closed 3 years ago

lemzwerg commented 3 years ago

[TeXLive rev. 57852, 2021-02-23]

At least for the files germanb.sty, austrian.sty, and naustrian.sty the macro \begindocument fails if used with Plain TeX, in contradiction to the documentation.

lemzwerg commented 3 years ago

It seems that babel's plain TeX support is missing a definition for \IfFileExists.

jbezos commented 3 years ago

It works fine with languages like spanish, dutch, polish, estonian and others (my test files are based on some of these), so I wonder if it's related to the complex file structure in the german style. I have to investigate.

jbezos commented 3 years ago

It seems there is a bug in ngermanb, because the line:

\LdfInit\CurrentOption{captions\CurrentOption}

is misplaced. It must be just after \ProvidesLanguage. With this change it works for me.

@jspitz Can you have a look at it?

jspitz commented 3 years ago

@jbezos sure. Is there a MWE I can test with?

jbezos commented 3 years ago

@jspitz See the linked issue above: https://github.com/latex3/babel/issues/118

jspitz commented 3 years ago

It seems there is a bug in ngermanb, because the line:

\LdfInit\CurrentOption{captions\CurrentOption}

is misplaced. It must be just after \ProvidesLanguage. With this change it works for me.

Moving this still produces the same error for me. Also I think the movement is not possible as \CurrentOption needs to be defined in the preceding lines (in order to support the different varieties)

jbezos commented 3 years ago

@jspitz You may need to update to the version in GitHub because there was a bug in babel (oddly, it has not been detected in years). Or add by hand to ngermanb.sty the two missing lines at the end:

\def\CurrentOption{ngerman}
\input ngermanb.ldf\relax

See https://github.com/latex3/babel/issues/118#issuecomment-785717226. In Plain, the catcodes are set by \LdfInit, so it must be placed before any macro containing @. Alternatively, you can change the catcodes explicitly.

jspitz commented 3 years ago

Should be fixed in the repo. @lemzwerg can you test from https://github.com/jspitz/babel-german/?

lemzwerg commented 3 years ago

Thanks for the fix. It works for ngermanb.sty. However, it still fails for germanb.sty. This test file

\input germanb.sty
\begindocument
\showhyphens{Fassade modernste Abendstern Mordopfer}
\bye

produces

! Undefined control sequence.
\bbl@provide@locale ...sname \relax \IfFileExists 
                                                  {babel-\languagename .tex}...

\select@language ...guagename \bbl@provide@locale 
                                                  \bbl@iflanguage \languagen...

\bbl@set@language ...ect@language {\languagename }
                                                  \expandafter \ifx \csname ...

\@begindocumenthook ...after {\bbl@main@language }
                                                  \ifbbl@single \renewcomman...

\begindocument ->\@begindocumenthook 
                                     \global \let \@begindocumenthook \@unde...
l.2 \begindocument
jspitz commented 3 years ago

Better now?

lemzwerg commented 3 years ago

Yep, this works now, thanks.