Skip to content

Feature request: configurable path to lang (in context) #51

@sverro2

Description

@sverro2

It would be useful if the 'lang' template context path is configurable when registering a fluent helper. If I pass a common context object to every template I use fluent with, I could for example promise the lang data can be found at {{ my_context_object.language }} instead of {{ lang }}:
handlebars.register_helper("fluent", Box::new(FluentLoader::new(&*LOCALES, "my_context_object.language")));

I know this makes code in this lib a bit more complex, but it definitely will make my project using this library cleaner.

Why would someone want this? Well, I already inserted an object containing lots of common data into the context (including language). I just want it to read that object, instead of having to clone the lang data to another field in the context.

It is one line of code less, for every route in my project (nice). But even nicer... currently if I forget to pass this variable to the 'context!' it will just use the fallback language, and I don't even get a compiler warning! If I forget to pass the common object, it's a lot easier to spot :D

Thanks for reading!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions