longbridgeapp / rust-i18n

A better and simply I18n crate for Rust.
MIT License
297 stars 32 forks source link

Compile time checks #63

Open woojiq opened 12 months ago

woojiq commented 12 months ago

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.wronmesag".

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