Skip to content

Releases: longbridge/rust-i18n

v4.0.0

11 Apr 13:06

Choose a tag to compare

What's Changed

Breaking Changes

  • Backend trait signature changed to use Cow<'_, str>available_locales() now returns Vec<Cow<'_, str>> instead of Vec<&str>, and translate() now returns Option<Cow<'_, str>> instead of Option<&str>. Custom Backend implementations must be updated accordingly. (#114)
  • SimpleBackend::add_translations() signature changed — Now takes Cow<'static, str> for locale and HashMap<Cow<'static, str>, Cow<'static, str>> for data, instead of &str and &HashMap<&str, &str>. (#133)
  • New required method messages_for_locale on Backend trait — Returns all translation messages for a given locale as Option<Vec<(Cow<'_, str>, Cow<'_, str>)>>.
  • Removed once_cell dependency — Replaced with std::sync::LazyLock from the standard library. The re-export rust_i18n::once_cell is no longer available. This raises the minimum supported Rust version (MSRV) to 1.80.0. (#131)

Performance Improvements

  • Dramatically reduced allocations in the i18n! macro expansion — Previously, the macro generated one HashMap per translation pair; now it generates one HashMap per locale. For large projects, this reduces HashMap creation from thousands to just a handful (e.g., 14,000 → 32). This also fixes stack overflow crashes on Windows for projects with many translations. (#133)
  • Eliminated unnecessary String allocations — By using Cow<'static, str> throughout, static translation strings are no longer cloned into heap-allocated Strings. (#114, #133)

New Features

  • messages_for_locale() method on Backend — Retrieve all translation key-value pairs for a specific locale, useful for inspection and debugging.
  • try_load_locales() function — A fallible alternative to load_locales() in rust-i18n-support that returns Result instead of panicking, with detailed error messages for file lookup, parsing, and I/O failures. (#127)
  • Improved error messages — Parsing failures now include the specific error reason instead of a generic panic message. (#116)

Internal / Maintenance

  • Replaced once_cell::sync::Lazy with std::sync::LazyLock (#131)
  • Added Cargo.lock to version control (#120)
  • Improved CI workflow with concurrency groups and branch filtering
  • Added release workflow
  • Bumped slab from 0.4.10 to 0.4.11 (#122)

Migration Guide

If you have a custom Backend implementation, update it to:

use std::borrow::Cow;

impl Backend for MyBackend {
    fn available_locales(&self) -> Vec<Cow<'_, str>> { /* ... */ }
    fn translate(&self, locale: &str, key: &str) -> Option<Cow<'_, str>> { /* ... */ }
    fn messages_for_locale(&self, locale: &str) -> Option<Vec<(Cow<'_, str>, Cow<'_, str>)>> { /* ... */ }
}

If you were using rust_i18n::once_cell, switch to std::sync::LazyLock (requires Rust 1.80+).

New Contributors

Full Changelog: v3.1.5...v4.0.0

v3.1.5

22 May 11:50

Choose a tag to compare

What's Changed

  • Add parsing of workspace.metadata.i18n by @litcc in #93
  • Fix load translations to avoid stack overflow. by @nduchaux in #112

New Contributors

Full Changelog: v3.1.4...v3.1.5

v3.1.4

01 Apr 14:08

Choose a tag to compare

What's Changed

Full Changelog: v3.1.3...v3.1.4

v3.1.3

20 Feb 03:04

Choose a tag to compare

What's Changed

  • Replace HashMap with BTreeMap to remove non-determinism in build by @ilmanzo in #104

New Contributors

Full Changelog: v3.1.2...v3.1.3

v3.1.2

20 Aug 11:52

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v3.1.1...v3.1.2

v3.1.1

09 Aug 03:30

Choose a tag to compare

What's Changed

  • Introduced the minify_key feature for i18n! and added support for format specifiers in t! by @varphone in #73
  • Update example for share I18n in entire workspace by @huacnlee in #80
  • Update doc for locale file version. by @huacnlee in #82
  • Update to use serde_yml (#86)

Full Changelog: v3.0.1...v3.1.1

v3.0.1

23 Jan 01:46

Choose a tag to compare

What's Changed

  • Use arc_swap to implement AtomicStr for thread-safe. by @Kijewski in #72

New Contributors

Full Changelog: v3.0.0...v3.0.1

v3.0.0

19 Jan 07:45

Choose a tag to compare

What's Changed

  • Add more than one fallback with priority support, eg: i18n!("locales", fallback = ["en", "es]); by @varphone #69
    • Remove RwLock from locale() and set_locale().
    • String patterns replacement, time reduce 10% ~ 80%.
    • Reduce memory copy on t!().

Performance improved

- t                       time:   [100.91 ns 101.06 ns 101.24 ns]
- t_with_args             time:   [495.56 ns 497.88 ns 500.64 ns]
+ t                       time:   [58.274 ns 60.222 ns 62.390 ns]
+ t_with_args             time:   [167.46 ns 170.94 ns 175.64 ns]

Breaking Changes

  • rust_i18n::locale() -> String => rust_i18n::locale() -> Arc<String> .
  • t!() -> String => t!() -> Cow<str>.

v2.3.1

15 Jan 07:33

Choose a tag to compare

What's Changed

Fallback example:

  1. zh-CN or zh-HK or zh-SG
  2. zh

New Contributors

Full Changelog: v2.3.0...v2.3.1

v2.3.0

14 Nov 02:59

Choose a tag to compare

What's Changed

  • Split cargo i18n to separate crate by @urkle in #66
$ cargo install rust-i18n-cli

Full Changelog: v2.2.1...v2.3.0