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

Help with the first small LBX -- vietnamese. #1376

Closed pauloney closed 3 months ago

pauloney commented 3 months ago

I gave my first try at one of the small LBX (below). The file is found by latex, but the strings for "pages" and "cited on" are not replaced. Can anyone shed some light on what is happenning?

\ProvidesFile{vietnamese.lbx}
[\abx@lbxid]

\DeclareBibliographyExtras{%
  \protected\def\bibrangedash{%
    \textendash\penalty\hyphenpenalty}% breakable dash
  \let\finalandcomma=\empty
  \let\finalandsemicolon=\empty
  \def\mkbibordinal{\mkbibmascord}%
  \protected\def\mkbibmascord#1{%
    \stripzeros{#1}\textordmasculine}% \textordmasculine -> textcomp.sty
  \protected\def\mkbibfemord#1{%
    \stripzeros{#1}\textordfeminine}%  \textordfeminine  -> textcomp.sty
  \protected\def\mkbibneutord{\mkbibmascord}%
  \protected\def\mkbibdatelong#1#2#3{%
    \iffieldundef{#3}
      {}
      {\stripzeros{\thefield{#3}}%
       \iffieldundef{#2}{}{\nobreakspace de\space}}%
    \iffieldundef{#2}
      {}
      {\mkbibmonth{\thefield{#2}}%
       \iffieldundef{#1}{}{\nobreakspace de\space}}%
    \iffieldbibstring{#1}
      {\bibstring{\thefield{#1}}}
      {\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}}%
  \protected\def\mkbibdateshort#1#2#3{%
    \iffieldundef{#3}
      {}
      {\mkdayzeros{\thefield{#3}}%
       \iffieldundef{#2}{}{/}}%
    \iffieldundef{#2}
      {}
      {\mkmonthzeros{\thefield{#2}}%
       \iffieldundef{#1}{}{/}}%
    \iffieldbibstring{#1}
      {\bibstring{\thefield{#1}}}
      {\dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}}%
  \savecommand\mkbibordedition
  \savecommand\mkbibordseries
  \def\mkbibordedition{\mkbibfemord}%
  \def\mkbibordseries{\mkbibfemord}%
  \expandafter\protected\expandafter\def\csname mkbibtime24h\endcsname#1#2#3#4{%
      \iffieldundef{#1}
        {}
        {\mktimezeros{\thefield{#1}}%
         \iffieldundef{#2}{}{\bibtimesep}}%
      \iffieldundef{#2}
        {}
        {\mktimezeros{\thefield{#2}}%
         \iffieldundef{#3}{}{\bibtimesep}}%
      \iffieldundef{#3}
        {}
        {\mktimezeros{\thefield{#3}}}%
      \iffieldundef{#4}{}
        {\bibtimezonesep
         \mkbibtimezone{\thefield{#4}}}}%
  \expandafter\protected\expandafter\def\csname mkbibtime12h\endcsname#1#2#3#4{%
      \stripzeros{\mktimehh{\thefield{#1}}}\bibtimesep
      \forcezerosmdt{\thefield{#2}}%
      \iffieldundef{#3}{}
        {\bibtimesep
         \forcezerosmdt{\thefield{#3}}}%
       \space
       \ifnumless{\thefield{#1}}{12}
         {\bibstring{am}}
         {\bibstring{pm}}%
      \iffieldundef{#4}{}
       {\space\bibtimezonesep
        \parentext{\mkbibtimezone{\thefield{#4}}}}}%
  \protected\def\mkbibseasondateshort#1#2{%
    \mkbibseason{\thefield{#2}}%
    \iffieldundef{#1}{}{\space}%
    \dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}%
  \protected\def\mkbibseasondatelong#1#2{%
    \mkbibseason{\thefield{#2}}%
    \iffieldundef{#1}{}{\space}%
    \dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}%
}

\UndeclareBibliographyExtras{%
  \restorecommand\mkbibordedition
  \restorecommand\mkbibordseries
}

\DeclareBibliographyStrings{%
  page             = {{trang}{tr\adddotspace}},
  pages            = {{trang}{tr\adddotspace}},
  urlfrom          = {{Khai thác từ }{Khai thác từ }},
  urlseen          = {{Khai thác từ }{Khai thác từ }},
  backrefpage      = {{trích dẫn ở trang}{trích dẫn ở tr\adddotspace}},
  backrefpages     = {{trích dẫn ở trang}{trích dẫn ở tr\adddotspace}},
}

\endinput

with the file:

\documentclass{article}

\usepackage{polyglossia}
\usepackage{csquotes}
\setmainlanguage{english}
\setotherlanguage{vietnamese}

\usepackage[style=authoryear,
            backref=true,
            language=auto,
            autolang=other,
            backend=biber]{biblatex}

\addbibresource{viet-lib.bib}

\begin{document}

Citing \textcite{Hirsch-Smale:vi} and \textcite{Birkhoff-MacLane:vi}.

\nocite{*}
\printbibliography

\end{document}

and BIB file:

@book{Hirsch-Smale:vi,
     author = {Hirsch, M. W. and Smale, S.},
      title = {Phương trình vi phân. Hệ động lực và đại số tuyến tính},
       year = {1979},
      pages = {442},
  publisher = {Đại học và Trung học chuyên nghiệp},
    address = {Hà Nội},
     langid = {vietnamese},
}

@book{Birkhoff-MacLane:vi,
     author = {Birkhoff, Garett and Mac Lane, Saunders},
      title = {Tông quan về Đại số hiện đại},
  publisher = {Nhà xuất bản Đại học và Trung học chuyên nghiệp},
    address = {Hà Nội},
       year = {1979},
       pages = {217},
     langid = {vietnamese},
}
pauloney commented 3 months ago

Works like a charm in TL'24. Closing it now.