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

Why SILE.languageSupport.loadLanguage isn't loaded together with document.language? #2084

Open
jodros opened this issue Jul 21, 2024 · 4 comments
Labels
bug Software bug issue modules:packages Issue relates to core or 3rd party packages

Comments

@jodros
Copy link
Contributor

jodros commented Jul 21, 2024

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?

@jodros jodros changed the title Why SILE.languageSupport.loadLanguage isn't loaded together with 'document.language'? Why SILE.languageSupport.loadLanguage isn't loaded together with document.language? Jul 21, 2024
@Omikhleia
Copy link
Member

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.

@jodros
Copy link
Contributor Author

jodros commented Jul 21, 2024

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.

@alerque
Copy link
Member

alerque commented Aug 20, 2024

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.

@alerque alerque added bug Software bug issue modules:packages Issue relates to core or 3rd party packages labels Aug 20, 2024
@alerque
Copy link
Member

alerque commented Aug 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Software bug issue modules:packages Issue relates to core or 3rd party packages
Projects
Development

No branches or pull requests

3 participants