egui-i18n

Crates.ioegui-i18n
lib.rsegui-i18n
version0.1.2
created_at2025-06-07 15:51:26.990778+00
updated_at2025-06-07 16:07:54.28117+00
descriptionegui i18n
homepagehttps://github.com/fewensa/egui-i18n
repositoryhttps://github.com/fewensa/egui-i18n
max_upload_size
id1704171
size23,436
(fewensa)

documentation

README

egui-i18n

egui-i18n is an internationalization (i18n) solution designed specifically for the egui framework. It supports both Fluent syntax and traditional key-value translation formats. With flexible resource loading, dynamic parameter interpolation, and performance optimizations, it helps developers easily implement multi-language support in their applications.


🛠 Project Origin

egui-i18n originated from a proposal to add i18n support in the official egui repository. Since egui does not currently include a built-in i18n system, this project was developed independently to fulfill real-world needs without modifying egui's core. The goals include:

  • Provide multi-language support without modifying egui's source code.
  • Support both Fluent and classic key-value translation formats.
  • Enable runtime language switching and dynamic parameter interpolation.
  • Deliver high performance and flexibility for Rust-based GUI applications.

✨ Features

🗣 Multi-language Support

  • Fluent: Ideal for complex linguistic structures.
  • Classic key-value format: Suitable for simple and straightforward translations.

🔄 Dynamic Parameter Interpolation

  • Easily insert dynamic values (e.g. names, dates, numbers) into translation strings.

📂 Flexible Resource Loading

  • Load .ftl (Fluent) or .properties (key-value) files from specified file paths.
  • Language fallback support (e.g. fallback from zh-HK to zh).

⚡ High Performance

  • Built-in caching system to speed up parsing and lookup of translation resources, suitable for real-time UI rendering.

📦 Installation

Add the dependency in your Cargo.toml:

[dependencies]
egui-i18n = "0.1"

🚀 Getting Started

Using Fluent Translations

[dependencies]
egui-i18n = { version = "0.1", features = ["fluent"] }
use egui_i18n::tr;

fn main() {
  let greeting = tr!("greeting", { name: "Alice" });
  println!("{}", greeting); // Output: Hello, Alice!
}

Fluent resource file example (en-US.ftl):

greeting = Hello, { $name }!

Using Classic Key-Value Translations

use egui_i18n::tr;

fn main() {
  let greeting = tr!("classic_greeting");
  println!("{}", greeting); // Output: Hello, world!
}

Classic key-value resource example:

classic_greeting = Hello, world!

⚙️ Configuration Options

Cargo Features

  • fluent: Enables Fluent translation mode.
  • classic: Enables classic key-value translation mode (enabled by default).

📄 License

This project is open source under the MIT License. Contributions and feedback are welcome!


For more examples, API documentation, or integration guides, check the project source code and the examples directory. If you encounter any issues or have suggestions, feel free to open an issue or submit a PR!

Commit count: 14

cargo fmt