Aardwolf-Social/aardwolf

Tying Languages to Templates

BanjoFox opened this issue · 2 comments

This is item 3, in the Hackers Guide to Aardwolf

The web interface for the application follows the Tera syntax for populating the content. Rocket can use several template formats, however Tera was written specifically for Rust. Previous versions of Aardwolf templates used the Handlebars format, which is more geared toward JavaScript users. One point of interest is that the Handlebars templates rendered, and simply rendered the variable names. However, Tera compiles but throws an error during runtime because the variables are not, yet, tied to specific value.

The language files live inside of /lang, and are simple key=value pairs using the TOML syntax. When the app loads it should scan the /lang directory to ensure that at least one valid language file is present. All of the key=value pairs in the language files are stored in a struct (/src/aardwolf/lang.rs) that is used to parse the files more efficiently. Currently there are two places where the language files can be configured. The main aardwolf.toml, and the user preferences dropdown.

This feature is being tracked in the a-i18n-langages* branch: Shortcut here --> a-i18n-langages

(footnote) Why the hell would I spell LANGUAGES correctly -.-...

TLDR;

  • Language translations live in /lang/
  • There is a Rust struct for the key/value pairs in /src/aardwolf/lang.rs

Needed for MVP
The application must be able to read in the values from the struct + TOML pair. In doing so, the variables can be used in the Tera UI templates.

Not needed for MVP

  • Validation of the TOMLs would be great (not needed for MVP),

Duplicate of #80