Track Fluent files using `include!`

finchie
Aug 29, 2024, 5:18 AM
K3G4HK2JH4MFDAMYD6N2AZONCHE7QYMQ3S4LAND3A5IAD7BHC5TAC

Dependencies

  • [2] 3NMKD6I5 Refactor `Localize` trait to use `std::io::Write`
  • [*] CESJ4CTO Move macro-specific code into `macro_impl` module

Change contents

  • edit in fluent_embed_derive/src/macro_impl/mod.rs at line 26
    [4.646]
    [4.646]
    // Keep track of all the Fluent files
    let tracked_paths = locales.clone();
    let tracked_paths = tracked_paths
    .values()
    .map(|path| path.to_string_lossy().to_string());
    let path_count = locales.len();
  • edit in fluent_embed_derive/src/macro_impl/mod.rs at line 55
    [4.1507]
    [2.211]
    impl #ident {
    // Call the `include_str!` macro to make sure the Fluent files are tracked
    // so when Fluent code changes, the generated code should be rebuild
    // TODO: This is a hack that should be replaced with https://github.com/rust-lang/rust/issues/99515 once stable
    const _tracked_paths: [&str; #path_count] = [#(include_str!(#tracked_paths)),*];
    }