Skip to content

Compile time checks #63

@woojiq

Description

@woojiq

I didn't find any information about compile-time checks. If message in locale file is missing then string passed to macro will be displayed: https://github.com/longbridgeapp/rust-i18n/blob/ba2c7cb8e1083ccc12c8887623a43c25bf9ee4d6/crates/macro/src/lib.rs#L183-L186

Will it be hard to create a separate macro or add option for t!() to make sure the message I use exists in the locale file at compile time (like sqlx query! does)? This can be tricky, so maybe an easier way is to create xtask (or test) to check that all the messages I'm using in the code are defined. This way it can be easily integrated with CI.
All I want to achieve is if my app has passed CI, the locale files will have the appropriate content and the user won't see "en.wron_mesag".

Probably internationalization-rs can be used to see how they achieve compile time verification (using build.rs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions