Why `SILE.languageSupport.loadLanguage` isn't loaded together with `document.language`?
jodros opened this issue · 4 comments
Just noticed how every time I use \lorem
I got:
! Setting document.language to 'la', but support for 'la' has not been loaded!
Consider invoking \language[main=la] which loads language support before
setting it or manually calling SILE.languageSupport.loadLanguage("la").
Why doesn't the hook of document.language
just call SILE.languageSupport.loadLanguage()
?
Is it about not being opinionated?
Do you have a minimal script? I plan to contribute a huge language-related refactor when I'll have finished my current work on bibliographies.
Do you have a minimal script?
I don't.
I'm just curious to know why the commit 83db3d9 only warns instead of actually load the support for a given language.
I'm just curious to know why the commit 83db3d9 only warns instead of actually load the support for a given language.
Because SILE.languageSupport.loadLanguage()
is a pretty low level API that end users shouldn't typically be calling directly anyway. Meanwhile ding other language loading stuff other than what that function does can have significant other side effects that may or may not be wanted.
The real question is why is the SILE.settings:set("document.language", "la")
in the lorem package not loading the language, it does seem like at that higher level command it auto to trigger an auto load of the language resources if needed.
I just ran into an issue that I think is another iteration of this problem: I tried to run SILE.call("ftl", ...)
to override the standard translations of book-chapter-title
in a multi-language document, but the changes didn't stick. It turns out (as best I could figure while under the gun to get a project printed) that where I was running that from (a project specific package's package:_init()
that gets loaded by a custom class class:_init()
) was running before the document content set the main language, and the messages that got set by me were being blown away when the language got set and actually triggered SILE to load related resources. It would have been easy to override later in the document, but not in the early init because the document language isn't known until content starts being processed.
The solution was to manually call SILE.languageSupport.loadLanguage()
on each locale I was overriding to get the default localizations set, thus making my overrides stick. That didn't feel right at all.