longbridgeapp / rust-i18n

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

t! return previous value in the file #46

Open doowonee opened 1 year ago

doowonee commented 1 year ago

Does it can detect file changed and compile newer version of locale files? It seems not work.

I just modified the value with the same key locale file en.toml and it just showed me previous value of it.

How to tell rust-i18n to file is changed?

huacnlee commented 1 year ago

Show me your file struct please

doowonee commented 1 year ago

I use cargo workspace and i18n is in A crate in workspace.

I usually run B crate. When I modified en.toml in A crate and run B it shows not changed. only after cargo clean works

juh9870 commented 1 year ago

From my observations, if you modify only localization files in crate A, Cargo will not trigger a rebuild when crate B, which depends on A, is compiled. This results in B using an outdated version of A's localization files.

juh9870 commented 1 year ago

One solution I got hinted at in the Rust GameDev discord is to add locales folder as a build dependency via buildscript in crate A. Like this: build.rs

fn main() {
    println!("cargo:rerun-if-changed=locales");
}

Note that this will rebuild the whole crate A every time you change localization files.

doowonee commented 1 year ago

Thank you for your investigation!