Skip to content

Commit

Permalink
fmt: Update i18n module
Browse files Browse the repository at this point in the history
  • Loading branch information
kairyou committed Dec 12, 2024
1 parent a5dd0d6 commit b03d639
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/i18n.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
//! # Examples
//! ```rust
//! use jenkins::i18n::I18n;
//! use jenkins::i18n::t;
//!
//! I18n::set_locale("zh-CN"); // Optional, set locale(default is system locale)
//! println!("current locale: {}", I18n::locale());
//! println!("available locales: {:?}", I18n::available_locales());
//! println!("{}", t!("hello-world"));
//! println!("{}", t!("welcome", "name" => "张三")); // with args
//! println!("{}", t!("welcome", "name" => "Zhang San"; "en-US")); // Optional, get translation with specified locale
//! ```
//!
use fluent::concurrent::FluentBundle;
use fluent::{FluentArgs, FluentResource, FluentValue};
use fluent_langneg::{negotiate_languages, LanguageIdentifier, NegotiationStrategy};
Expand All @@ -6,19 +20,6 @@ use rust_embed::RustEmbed;
use std::collections::HashMap;
use std::sync::{Arc, RwLock};

/// # Examples
/// ```rust
/// use jenkins::i18n::I18n;
/// use jenkins::i18n::t;
///
/// I18n::set_locale("zh-CN"); // Optional, set locale(default is system locale)
/// println!("current locale: {}", I18n::locale());
/// println!("available locales: {:?}", I18n::available_locales());
/// println!("{}", t!("hello-world"));
/// println!("{}", t!("welcome", "name" => "张三")); // with args
/// println!("{}", t!("welcome", "name" => "Zhang San"; "en-US")); // Optional, get translation with specified locale
/// ```
/// Embed all localization resource files
#[derive(RustEmbed)]
#[folder = "locales/"]
Expand Down

0 comments on commit b03d639

Please sign in to comment.