Skip to content

Review the fluent (i18n) implementation #1477

Closed
@Omikhleia

Description

@Omikhleia

Further the issues I encountered in #1474...

The Fluent implementation is real weird...

  1. It has potential side-effects...

    image

    • Line 68: message is nil is there was no localization found. Boom?
    • Line 57: So if a "locale" was set via options, it's now enforced for the rest of the document outside that command... Eek?
      • Additionally, This SILE.fluent:set_locale() thing really annoys me. It means the Fluent thing is state-full. It ought to be state-less, and SILE.fluent:get_message(key, locale) should be the way to go, IMHO.
  2. Let's checks every other call at SILE.fluent:set_locale()

    • In \font: likewise, the font change might be transient (if we had content, i.e. we are in a temporary settings push/pop state): the previous local ought to be restored... Or this thing be state-less, again...
    • Likewise in \ftl...
    • Hard to say for sure in SILE.languageSupport.languages.loadLanguage() but this have some smell...
  3. The Fluent library implementation is even weirder... It uses Penlight classes, which are already broken to some extent (Er... Do I have to quote the package owner here?), but that could be okay... Er, wait, all the metatable access are weird, and this is typically why one would want to use an OOP framework: to avoid those... Even after trying to fix (1) and (2) above, I couldn't make sense of the results seen on the SILE manual with Localization for as many languages as possible #1474...

I would suggest:

  • Rewriting this thing to be state-less, with the locale passed to commands needing it (e.g. get_message) rather than use some "global".
  • Revisit the core fluent implementation and stop trying to do more than what Penlight proposes... The _patch_init and self:catch things all have heavy code smell (IMHO) and are hardly understandable, therefore maintainable... for something, after all, which in the end resolves to some (key, value) patterns...

Metadata

Metadata

Assignees

Labels

refactorCode quality improvementstodo

Type

No type

Projects

  • Status

    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions