Move `old_locale_version` hack out of `Localize` trait

finchie
Jul 22, 2025, 1:23 AM
VJCANIBGGIS7ICGVKKD637ULAFZCWPL3NZWSKZTCA4BQWV4OSDJQC

Dependencies

  • [2] 5I5NR4DQ Make `Localize::CANONICAL_LOCALE` a function instead of associated constant
  • [3] LU6IFZFG Remove `std::io::Write` trait bound from `Localize`
  • [4] QJC4IQIT Refactor `Localize` functions to infallibly return `String`
  • [5] U2PHMYPD Return `String` directly instead of writing to buffer in `Localize::localize`
  • [6] UN2XEIEU Migrate from `locale_select` to `env_preferences`
  • [7] GJMBIJOE Migrate to latest env_preferences version
  • [8] HHJDRLLN Create `fluent_embed_runtime` crate
  • [9] 7M4UI3TW Update dependencies to latest versions
  • [10] 3NMKD6I5 Refactor `Localize` trait to use `std::io::Write`

Change contents

  • edit in fluent_embed/src/lib.rs at line 27
    [2.1136][2.1136:1142](),[2.1142][3.4956:4957](),[3.2154][3.4956:4957](),[3.4956][3.4956:4957](),[3.4957][3.2871:2928](),[3.2928][3.101:164](),[3.164][3.2974:3145](),[3.2974][3.2974:3145](),[3.3145][3.165:219](),[3.219][3.3199:3279](),[3.3199][3.3199:3279](),[3.3279][3.220:320](),[3.320][3.3379:3440](),[3.3379][3.3379:3440]()
    }
    // TODO: remove this hack
    fn old_locale_version(
    new_locales: Vec<icu_locale_core::LanguageIdentifier>,
    ) -> Vec<icu_locid::LanguageIdentifier> {
    new_locales
    .into_iter()
    // Convert new `icu_locale::LanguageIdentifier` to canonical string
    .map(|icu_langid| icu_langid.to_string())
    // Convert canonical string to old `icu_locid` for `fluent_langneg`
    .map(|icu_langid| icu_locid::LanguageIdentifier::try_from_bytes(icu_langid.as_bytes()))
    .map(Result::unwrap)
    .collect::<_>()
  • replacement in fluent_embed/src/lib.rs at line 37
    [3.737][3.737:811](),[3.811][3.3521:3605](),[3.3521][3.3521:3605]()
    let requested_locales = Self::old_locale_version(system_langids);
    let available_locales = Self::old_locale_version(self.available_locales());
    [3.737]
    [3.3605]
    let requested_locales = old_locale_version(system_langids);
    let available_locales = old_locale_version(self.available_locales());
  • edit in fluent_embed/src/lib.rs at line 55
    [3.5310]
    [3.807]
    }
    // TODO: remove this hack
    fn old_locale_version(
    new_locales: Vec<icu_locale_core::LanguageIdentifier>,
    ) -> Vec<icu_locid::LanguageIdentifier> {
    new_locales
    .into_iter()
    // Convert new `icu_locale::LanguageIdentifier` to canonical string
    .map(|icu_langid| icu_langid.to_string())
    // Convert canonical string to old `icu_locid` for `fluent_langneg`
    .map(|icu_langid| icu_locid::LanguageIdentifier::try_from_bytes(icu_langid.as_bytes()))
    .map(Result::unwrap)
    .collect::<_>()