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

Build back Babel #1508

Merged
merged 10 commits into from
Aug 4, 2022
1 change: 1 addition & 0 deletions classes/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class.packages = {}

function class:_init (options)
if self == options then options = {} end
SILE.languageSupport.loadLanguage('und') -- preload for unlocalized fallbacks
self:declareOptions()
self:registerRawHandlers()
self:registerCommands()
Expand Down
49 changes: 25 additions & 24 deletions classes/book.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,16 @@ function class:registerCommands ()
if SU.boolean(options.toc, true) then
SILE.call("tocentry", { level = level, number = number }, SU.subContent(content))
end
local lang = SILE.settings:get("document.language")
if SU.boolean(options.numbering, true) then
if options.prenumber then
if SILE.Commands[options.prenumber .. ":" .. lang] then
options.prenumber = options.prenumber .. ":" .. lang
end
SILE.call(options.prenumber)
end
SILE.call("show-multilevel-counter", { id = "sectioning" })
if options.postnumber then
if SILE.Commands[options.postnumber .. ":" .. lang] then
options.postnumber = options.postnumber .. ":" .. lang
end
SILE.call(options.postnumber)
if options.msg then
SILE.call("fluent", { number = number }, { options.msg })
else
SILE.call("show-multilevel-counter", { id = "sectioning" })
end
end
end)

self:registerCommand("book:chapter:pre", function (_, _)
SILE.call("fluent", {}, { "book-chapter-title-pre" })
end)

self:registerCommand("book:chapter:post", function (_, _)
SILE.call("fluent", {}, { "book-chapter-post" })
SILE.call("par")
end)

Expand Down Expand Up @@ -157,10 +143,15 @@ function class:registerCommands ()
numbering = options.numbering,
toc = options.toc,
level = 1,
prenumber = "book:chapter:pre",
postnumber = "book:chapter:post"
msg = "book-chapter-title"
}, content)
end)
local lang = SILE.settings:get("document.language")
local postcmd = "book:chapter:post"
if SILE.Commands[postcmd .. ":" .. lang] then
postcmd = postcmd .. ":" .. lang
end
SILE.call(postcmd)
SILE.call("book:chapterfont", {}, content)
SILE.call("left-running-head", {}, function ()
SILE.settings:temporarily(function ()
Expand All @@ -180,9 +171,14 @@ function class:registerCommands ()
SILE.call("book:sectioning", {
numbering = options.numbering,
toc = options.toc,
level = 2,
postnumber = "book:section:post"
level = 2
}, content)
local lang = SILE.settings:get("document.language")
local postcmd = "book:section:post"
if SILE.Commands[postcmd .. ":" .. lang] then
postcmd = postcmd .. ":" .. lang
end
SILE.call(postcmd)
SILE.process(content)
end)
if not SILE.scratch.counters.folio.off then
Expand Down Expand Up @@ -215,11 +211,16 @@ function class:registerCommands ()
SILE.call("book:sectioning", {
numbering = options.numbering,
toc = options.toc,
level = 3,
postnumber = "book:subsection:post"
level = 3
}, content)
SILE.process(content)
end)
local lang = SILE.settings:get("document.language")
local postcmd = "book:subsection:post"
if SILE.Commands[postcmd .. ":" .. lang] then
postcmd = postcmd .. ":" .. lang
end
SILE.call(postcmd)
SILE.typesetter:leaveHmode()
SILE.call("novbreak")
SILE.call("medskip")
Expand Down
8 changes: 7 additions & 1 deletion core/languages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ SILE.registerCommand("fluent", function (options, content)
message = entry:format(options)
else
SU.warn(string.format("No localized message for %s found in locale %s", key, locale))
fluent:set_locale('und')
entry = fluent:get_message(key)
if entry then
message = entry:format(options)
end
fluent:set_locale(locale)
end
SILE.process({ message })
SILE.processString(("<sile>%s</sile>"):format(message), "xml")
end, nil, nil, true)

SILE.registerCommand("ftl", function (options, content)
Expand Down
2 changes: 1 addition & 1 deletion documentation/c08-language.sil
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ A particularly common string to override might be the table of contents heading:

\begin{verbatim}
\line
\\ftl\{toc-heading = Table of Contents\}
\\ftl\{tableofcontents-title = Table of Contents\}
\\tableofcontents
\line
\end{verbatim}
Expand Down
3 changes: 3 additions & 0 deletions i18n/af.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Hoofstuk { $number }

tableofcontents-title = Inhoudsopgawe
3 changes: 3 additions & 0 deletions i18n/am.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = ክፍል { $number }

tableofcontents-title = ይዘት
3 changes: 3 additions & 0 deletions i18n/ar.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = باب { $number }

tableofcontents-title = المحتويات
3 changes: 3 additions & 0 deletions i18n/as.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = অধ্যায় { $number }

tableofcontents-title = সমল
3 changes: 3 additions & 0 deletions i18n/bg.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Глава { $number }

tableofcontents-title = Съдържание
3 changes: 3 additions & 0 deletions i18n/bn.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = অধ্যায় { $number }

tableofcontents-title = সূচীপত্র
3 changes: 3 additions & 0 deletions i18n/bo.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = ལེའུ་ { $number }

tableofcontents-title = དཀར་ཆག།
3 changes: 3 additions & 0 deletions i18n/ca.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Capítol { $number }

tableofcontents-title = Índex
4 changes: 2 additions & 2 deletions i18n/cs.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
toc-title = Obsah
book-chapter-title = Kapitola { $number }

book-chapter-title-pre = Kapitola{" "}
tableofcontents-title = Obsah
3 changes: 3 additions & 0 deletions i18n/cy.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Pennod { $number }

tableofcontents-title = Cynnwys
3 changes: 3 additions & 0 deletions i18n/da.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Kapitel { $number }

tableofcontents-title = Indhold
3 changes: 3 additions & 0 deletions i18n/de.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Kapitel { $number }

tableofcontents-title = Inhaltsverzeichnis
3 changes: 3 additions & 0 deletions i18n/el-monoton.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Κεφάλαιο { $number }

tableofcontents-title = Περιεχόμενα
3 changes: 3 additions & 0 deletions i18n/el-polyton.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Κεφάλαιο { $number }

tableofcontents-title = Περιεχόμενα
3 changes: 3 additions & 0 deletions i18n/el.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Κεφάλαιο { $number }

tableofcontents-title = Περιεχόμενα
16 changes: 8 additions & 8 deletions i18n/en.ftl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
hello = Hello { $name }!
bibliography-and = and

toc-not-generated = Rerun SILE to process the table of contents!
bibliography-edited-by = Edited by { $name }

toc-title = Table of Contents
bibliography-et-al = <language main="la">et al</language>.

book-chapter-title-pre = Chapter{" "}
bibliography-translated-by = Translated by { $name }

bibliography-and = and
book-chapter-title = Chapter { $number }

bibliography-edited-by = Edited by { $name }
hello = Hello <em>{ $name }</em>!

bibliography-et-al = et al.
tableofcontents-not-generated = Rerun SILE to process the table of contents!

bibliography-translated-by = Translated by { $name }
tableofcontents-title = Table of Contents
16 changes: 8 additions & 8 deletions i18n/eo.ftl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
hello = Saluton { $name }!

toc-not-generated = Reruli na SILE por trakti la enhavan tabelon!

toc-title = Enhavoj

book-chapter-title-pre = Ĉapitro{" "}

bibliography-and = kaj

bibliography-edited-by = Redaktita por { $name }

bibliography-et-al = kaj aliaj

bibliography-translated-by = Tradukita por { $name }

book-chapter-title = Ĉapitro { $number }

hello = Saluton <em>{ $name }</em>!

tableofcontents-not-generated = Reruli na SILE por trakti la enhavan tabelon!

tableofcontents-title = Enhavoj
3 changes: 3 additions & 0 deletions i18n/es.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Capítulo { $number }

tableofcontents-title = Índice
3 changes: 3 additions & 0 deletions i18n/et.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Peatükk { $number }

tableofcontents-title = Sisukord
3 changes: 3 additions & 0 deletions i18n/eu.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title ={ $number }. Kapitulua

tableofcontents-title = Gaien Aurkibidea
3 changes: 3 additions & 0 deletions i18n/fi.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Luku { $number }

tableofcontents-title = Sisällys
11 changes: 11 additions & 0 deletions i18n/fr.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bibliography-and = et

bibliography-edited-by = Édité par { $name }

bibliography-et-al = <language main="la">et al</language>.

bibliography-translated-by = Traduit par { $name }

book-chapter-title = Chapitre { $number }

tableofcontents-title = Table des matières
3 changes: 3 additions & 0 deletions i18n/ga.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Caibidil { $number }

tableofcontents-title = Clár Ábhair
Empty file added i18n/gu.ftl
Empty file.
3 changes: 3 additions & 0 deletions i18n/hi.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = अध्याय { $number }

tableofcontents-title = अनुक्रम
3 changes: 3 additions & 0 deletions i18n/hr.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Poglavlje { $number }

tableofcontents-title = Sadržaj
3 changes: 3 additions & 0 deletions i18n/hu.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = { $number }. fejezet

tableofcontents-title = Tartalomjegyzék
3 changes: 3 additions & 0 deletions i18n/hy.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Գլուխ { $number }

tableofcontents-title = Բովանդակություն
3 changes: 3 additions & 0 deletions i18n/id.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Bab { $number }

tableofcontents-title = Daftar Isi
3 changes: 3 additions & 0 deletions i18n/is.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Kafli { $number }

tableofcontents-title = Efnisyfirlit
3 changes: 3 additions & 0 deletions i18n/it.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Capitolo { $number }

tableofcontents-title = Indice
5 changes: 2 additions & 3 deletions i18n/ja.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# End with thin nonbreaking space (U+202F)
book-chapter-title-pre = 第 
book-chapter-title = 第 { $number } 章

book-chapter-post =  章
tableofcontents-title = 目次
Empty file added i18n/jv.ftl
Empty file.
3 changes: 3 additions & 0 deletions i18n/ka.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = თავი { $number }

tableofcontents-title = შინაარსი
3 changes: 3 additions & 0 deletions i18n/kn.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = ಅಧ್ಯಾಯ { $number }

tableofcontents-title = ವಿಷಯಗಳು
16 changes: 8 additions & 8 deletions i18n/la.ftl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
hello = Salve { $name }!

toc-not-generated = Curre SILE iterum ad mensam contentorum computetur!

toc-title = Tabula contentorum

book-chapter-title-pre = Caput{" "}

bibliography-and = et

bibliography-edited-by = Conpositor erat { $name }

bibliography-et-al = et al.

bibliography-translated-by = Interpres fuit { $name }

book-chapter-title = Caput { $number }

hello = Salve <em>{ $name }</em>!

tableofcontents-not-generated = Curre SILE iterum ad mensam contentorum computetur!

tableofcontents-title = Tabula contentorum
3 changes: 3 additions & 0 deletions i18n/lt.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = { $number } skyrius

tableofcontents-title = Turinys
3 changes: 3 additions & 0 deletions i18n/lv.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Nodaļa { $number }

tableofcontents-title = Saturs
3 changes: 3 additions & 0 deletions i18n/ml.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = അദ്ധ്യായം { $number }

tableofcontents-title = ഉള്ളടക്കം
3 changes: 3 additions & 0 deletions i18n/mr.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = प्रकरण { $number }

tableofcontents-title = अनुक्रमणिका
Empty file added i18n/my.ftl
Empty file.
1 change: 0 additions & 1 deletion i18n/nb.ftl

This file was deleted.

15 changes: 15 additions & 0 deletions i18n/nb.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bibliography-and = og

bibliography-edited-by = Redigert av { $name }

bibliography-et-al = <language main="la">et al</language>.

bibliography-translated-by = Oversatt av { $name }

book-chapter-title = Kapittel { $number }

hello = Hei <em>{ $name }</em>!

tableofcontents-not-generated = Kjør SILE om igjen slik at innholdsfortegnelsen blir behandlet!

tableofcontents-title = Innhold
3 changes: 3 additions & 0 deletions i18n/nl.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
book-chapter-title = Hoofdstuk { $number }

tableofcontents-title = Inhoudsopgave
1 change: 0 additions & 1 deletion i18n/nn.ftl

This file was deleted.

15 changes: 15 additions & 0 deletions i18n/nn.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bibliography-and = og

bibliography-edited-by = Redigert av { $name }

bibliography-et-al = <language main="la">et al</language>.

bibliography-translated-by = Redigert av { $name }

book-chapter-title = Kapittel { $number }

hello = Hei <em>{ $name }</em>!

tableofcontents-not-generated = Kjør SILE om igjen slik at innholdsfortegnelsen blir behandlet!

tableofcontents-title = Innhald
Loading