You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
Can we implement this by parsing all the Rust source code, and for the macro invocation, check if its ident is t, if so, extract the translation key, then we can do the needed checks. 🤔
This should work for code like:
t!("translation key");
However, usages like:
use rust_i18n::t as the_t_macro;the_t_macro!("translation key");
and
let translation_key = "translation key";
rust_i18n::t!(translation_key);
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:
rust-i18n/crates/macro/src/lib.rs
Lines 183 to 186 in ba2c7cb
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 sqlxquery!
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).
The text was updated successfully, but these errors were encountered: