From 5db4d712ef660273c1c12f211fdb4adf5a792ec3 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 27 Jan 2018 14:26:36 +0100 Subject: [PATCH] Differentiate Buffer strings and GUI strings in citeengines The former need to be translated to the buffer language, the latter to the GUI language. Fixes: #10946 --- lib/citeengines/basic.citeengine | 3 ++- lib/citeengines/biblatex-natbib.citeengine | 18 +++++++------ lib/citeengines/biblatex.citeengine | 16 +++++++----- lib/citeengines/jurabib.citeengine | 11 ++++---- lib/citeengines/natbib.citeengine | 11 ++++---- lib/layouts/stdciteformats.inc | 30 ++++++++++++---------- src/BiblioInfo.cpp | 19 +++++++++----- src/TextClass.cpp | 2 +- 8 files changed, 63 insertions(+), 47 deletions(-) diff --git a/lib/citeengines/basic.citeengine b/lib/citeengines/basic.citeengine index a7fe12d765..075cb1b211 100644 --- a/lib/citeengines/basic.citeengine +++ b/lib/citeengines/basic.citeengine @@ -45,7 +45,8 @@ CiteFormat default # # MACROS # - # 1. Translatable bits (need to be marked by _ prefix) + # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language, + # or B_, if translated to the buffer language) # Note that preceding and trailing spaces matter. # _notcited not cited diff --git a/lib/citeengines/biblatex-natbib.citeengine b/lib/citeengines/biblatex-natbib.citeengine index edff500dbb..d994add5c0 100644 --- a/lib/citeengines/biblatex-natbib.citeengine +++ b/lib/citeengines/biblatex-natbib.citeengine @@ -131,14 +131,15 @@ CiteFormat default # # MACROS # - # 1. Translatable bits (need to be marked by _ prefix) + # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language, + # or B_, if translated to the buffer language) # Note that preceding and trailing spaces matter. # _notcited not cited _addtobib Add to bibliography only. _keyonly Key only. _key Key - _finaland , and + B_finaland , and _footnote Footnote _foot Foot _fullcite bibliography entry @@ -149,10 +150,10 @@ CiteFormat default _citetitlestar F&orce full title[[Possible substitute to All aut&hors]] _citetitlestartooltip Use full title even if shorttitle exists # The following are handled by BiblioInfo - _etal et al. - _namesep , [[separate author names in citation, except for last name]] - _lastnamesep , and [[separate name of last author in citation]] - _pairnamesep and [[separate two authors in citation]] + B_etal et al. + B_namesep , [[separate author names in citation, except for last name]] + B_lastnamesep , and [[separate name of last author in citation]] + B_pairnamesep and [[separate two authors in citation]] # # 2. Macros re-used in the style definitions @@ -171,7 +172,7 @@ CiteFormat default !endlink {!!} # Add " , and " before the last item (but " and " if there are only two), else ", " - !smartsep {%second%[[{%next%[[%_namesep%]][[%_pairnamesep%]]}]][[{%next%[[%_namesep%]][[%_lastnamesep%]]}]]} + !smartsep {%second%[[{%next%[[%B_namesep%]][[%B_pairnamesep%]]}]][[{%next%[[%B_namesep%]][[%B_lastnamesep%]]}]]} # "Author et al." or "??" !abbrvciteauthor {%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]} @@ -294,7 +295,8 @@ CiteFormat numerical # # MACROS # - # 1. Translatable bits (need to be marked by _ prefix) + # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language, + # or B_, if translated to the buffer language) # _super Super _superscript Superscript diff --git a/lib/citeengines/biblatex.citeengine b/lib/citeengines/biblatex.citeengine index 96b07c6c04..bd101e4507 100644 --- a/lib/citeengines/biblatex.citeengine +++ b/lib/citeengines/biblatex.citeengine @@ -122,7 +122,8 @@ CiteFormat default # # MACROS # - # 1. Translatable bits (need to be marked by _ prefix) + # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language, + # or B_, if translated to the buffer language) # Note that preceding and trailing spaces matter. # _notcited not cited @@ -141,10 +142,10 @@ CiteFormat default _citetitlestar F&orce full title[[Possible substitute to All aut&hors]] _citetitlestartooltip Use full title even if shorttitle exists # The following are handled by BiblioInfo - _etal et al. - _namesep , [[separate author names in citation, except for last name]] - _lastnamesep , and [[separate name of last author in citation]] - _pairnamesep and [[separate two authors in citation]] + B_etal et al. + B_namesep , [[separate author names in citation, except for last name]] + B_lastnamesep , and [[separate name of last author in citation]] + B_pairnamesep and [[separate two authors in citation]] # # 2. Macros re-used in the style definitions @@ -155,7 +156,7 @@ CiteFormat default !endlink {!!} # Add " , and " before the last item (but " and " if there are only two), else ", " - !smartsep {%second%[[{%next%[[%_namesep%]][[%_pairnamesep%]]}]][[{%next%[[%_namesep%]][[%_lastnamesep%]]}]]} + !smartsep {%second%[[{%next%[[%B_namesep%]][[%B_pairnamesep%]]}]][[{%next%[[%B_namesep%]][[%B_lastnamesep%]]}]]} # A dummy year modifier. This just indicates that a modifier might be output, # to differentiate \cite* and \citeyear @@ -278,7 +279,8 @@ CiteFormat numerical # # MACROS # - # 1. Translatable bits (need to be marked by _ prefix) + # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language, + # or B_, if translated to the buffer language) # _super Super _superscript Superscript diff --git a/lib/citeengines/jurabib.citeengine b/lib/citeengines/jurabib.citeengine index 1de398020f..d2faecc5a3 100644 --- a/lib/citeengines/jurabib.citeengine +++ b/lib/citeengines/jurabib.citeengine @@ -114,7 +114,8 @@ CiteFormat authoryear # # MACROS # - # 1. Translatable bits (need to be marked by _ prefix) + # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language, + # or B_, if translated to the buffer language) # Note that preceding and trailing spaces matter. # _notcited not cited @@ -126,10 +127,10 @@ CiteFormat authoryear _before before _shorttitle short title # The following are handled by BiblioInfo - _etal et al. - _namesep / - _lastnamesep / - _pairnamesep / + B_etal et al. + B_namesep / + B_lastnamesep / + B_pairnamesep / # # 2. Macros re-used in the style definitions diff --git a/lib/citeengines/natbib.citeengine b/lib/citeengines/natbib.citeengine index 58d235f168..3d93ee1ade 100644 --- a/lib/citeengines/natbib.citeengine +++ b/lib/citeengines/natbib.citeengine @@ -112,7 +112,8 @@ CiteFormat default # # MACROS # - # 1. Translatable bits (need to be marked by _ prefix) + # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language, + # or B_, if translated to the buffer language) # Note that preceding and trailing spaces matter. # _notcited not cited @@ -120,10 +121,10 @@ CiteFormat default _keyonly Key only. _key Key # The following are handled by BiblioInfo - _etal et al. - _namesep , [[separate author names in citation, except for last name]] - _lastnamesep , and [[separate name of last author in citation]] - _pairnamesep and [[separate two authors in citation]] + B_etal et al. + B_namesep , [[separate author names in citation, except for last name]] + B_lastnamesep , and [[separate name of last author in citation]] + B_pairnamesep and [[separate two authors in citation]] # # 2. Macros re-used in the style definitions diff --git a/lib/layouts/stdciteformats.inc b/lib/layouts/stdciteformats.inc index fc34cb8750..a2378ce917 100644 --- a/lib/layouts/stdciteformats.inc +++ b/lib/layouts/stdciteformats.inc @@ -15,18 +15,20 @@ Format 66 CiteFormat default # - # Translatable bits + # Translatable bits (need to be marked by _ prefix, if translated to the GUI language, + # or B_, if translated to the buffer language) + # Note that preceding and trailing spaces matter. # - _pptext pp. - _edtext ed. - _edstext eds. - _voltext vol. - _numtext no. - _in in + B_pptext pp. + B_edtext ed. + B_edstext eds. + B_voltext vol. + B_numtext no. + B_in in # The following are handled by BiblioInfo. Note that preceding and trailing spaces matter - _namesep , [[separate author names in citation, except for last name]] - _lastnamesep , and [[separate name of last author in citation]] - _pairnamesep and [[separate two authors in citation]] + B_namesep , [[separate author names in citation, except for last name]] + B_lastnamesep , and [[separate name of last author in citation]] + B_pairnamesep and [[separate two authors in citation]] # # Macros @@ -42,13 +44,13 @@ CiteFormat default # Scheme of authors in citation references !citenameform {%prefix%[[%prefix% ]]}%surname% # pagination - !pages {%pages%[[, %_pptext% %pages%]]} + !pages {%pages%[[, %B_pptext% %pages%]]} # ed. or eds. - !makeed {%ifmultiple:editor%[[%_edstext%]][[%_edtext%]]} + !makeed {%ifmultiple:editor%[[%B_edstext%]][[%B_edtext%]]} # author or editor, as fullnames, following the schemes above !authoredit {%fullnames:author%[[%fullnames:author%, ]][[{%fullnames:editor%[[%fullnames:editor%, %!makeed%, ]]}]]} # "vol. 1, no. - !volnum {%volume%[[ %_voltext% %volume%, {%number%[[%_numtext% %number%]]}]]} + !volnum {%volume%[[ %B_voltext% %volume%, {%number%[[%B_numtext% %number%]]}]]} !quotetitle "%title%" !emphtitle {!!}%title%{!!} !emphjournal {!!}{%journal%[[%journal%]][[{%journaltitle%[[%journaltitle%]]}]]}{!!} @@ -57,7 +59,7 @@ CiteFormat default # # Entry types. Note that final punctuation will be added later, if needed. # - !insomething %fullnames:author%, %!quotetitle%, %_in%{%fullbynames:editor%[[ %fullbynames:editor%, %!makeed%,]]} {!!}%booktitle%{!!}%!volnum%{%edition%[[ %edition%]]} (%!location%%publisher%, %year%)%!pages%{%note%[[. %note%]]} + !insomething %fullnames:author%, %!quotetitle%, %B_in%{%fullbynames:editor%[[ %fullbynames:editor%, %!makeed%,]]} {!!}%booktitle%{!!}%!volnum%{%edition%[[ %edition%]]} (%!location%%publisher%, %year%)%!pages%{%note%[[. %note%]]} article %fullnames:author%, %!quotetitle%, %!emphjournal% {%volume%[[ %volume%{%number%[[, %number%]]}]]} (%year%)%!pages%{%note%[[. %note%]]} diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 86fd8401b4..dac2097bb9 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -541,16 +541,16 @@ docstring const BibTeXInfo::getAuthorList(Buffer const * buf, // These are defined in the styles string const etal = - buf ? buf->params().documentClass().getCiteMacro(engine_type, "_etal") + buf ? buf->params().documentClass().getCiteMacro(engine_type, "B_etal") : " et al."; string const namesep = - buf ? buf->params().documentClass().getCiteMacro(engine_type, "_namesep") + buf ? buf->params().documentClass().getCiteMacro(engine_type, "B_namesep") : ", "; string const lastnamesep = - buf ? buf->params().documentClass().getCiteMacro(engine_type, "_lastnamesep") + buf ? buf->params().documentClass().getCiteMacro(engine_type, "B_lastnamesep") : ", and "; string const pairnamesep = - buf ? buf->params().documentClass().getCiteMacro(engine_type, "_pairnamesep") + buf ? buf->params().documentClass().getCiteMacro(engine_type, "B_pairnamesep") : " and "; string firstnameform = buf ? buf->params().documentClass().getCiteMacro(engine_type, "!firstnameform") @@ -811,13 +811,20 @@ docstring BibTeXInfo::expandFormat(docstring const & format, fmt = from_utf8(val) + fmt.substr(1); counter += 1; continue; - } else if (key[0] == '_') { - // a translatable bit + } else if (prefixIs(key, "B_")) { + // a translatable bit (to the Buffer language) string const val = buf.params().documentClass().getCiteMacro(engine_type, key); docstring const trans = translateIfPossible(from_utf8(val), buf.params().language->code()); ret << trans; + } else if (key[0] == '_') { + // a translatable bit (to the GUI language) + string const val = + buf.params().documentClass().getCiteMacro(engine_type, key); + docstring const trans = + translateIfPossible(from_utf8(val)); + ret << trans; } else { docstring const val = getValueForKey(key, buf, ci, xrefs, max_keysize); diff --git a/src/TextClass.cpp b/src/TextClass.cpp index cc8b0aa2d5..333582db39 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -1180,7 +1180,7 @@ bool TextClass::readCiteFormat(Lexer & lexrc) char initchar = etype[0]; if (initchar == '#') continue; - if (initchar == '!' || initchar == '_') { + if (initchar == '!' || initchar == '_' || prefixIs(etype, "B_")) { if (type & ENGINE_TYPE_AUTHORYEAR) cite_macros_[ENGINE_TYPE_AUTHORYEAR][etype] = definition; if (type & ENGINE_TYPE_NUMERICAL) -- 2.39.5