Skip to content

Commit

Permalink
v0.4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
MXWXZ committed Nov 22, 2024
1 parent 3ca3237 commit 8e863c9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.4.10
## Changes
1. `Locale::new` support `Into<String>` instead of `String`.

# 0.4.9
## New
1. New feature `serde` to add `Serialize`, `Deserialize` for supported structs.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ We use `rust-i18n-support` from [rust-i18n](https://crates.io/crates/rust-i18n)

Load locale:
```
let locale = Locale::new(String::from("en-US")).add_locale(i18n!("locale"));
let locale = Locale::new("en-US").add_locale(i18n!("locale"));
```

Translate:
Expand Down
2 changes: 1 addition & 1 deletion actix-cloud/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-cloud"
version = "0.4.9"
version = "0.4.10"
edition = "2021"
authors = ["MXWXZ <[email protected]>"]
description = "Actix Cloud is an all-in-one web framework based on Actix Web."
Expand Down
6 changes: 3 additions & 3 deletions actix-cloud/src/i18n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use actix_cloud_codegen::i18n;
/// ```no_run
/// use actix_cloud::{i18n::{i18n, Locale},t};
///
/// let mut locale = Locale::new(String::from("en-US")).add_locale(i18n!("locale"));
/// let mut locale = Locale::new("en-US").add_locale(i18n!("locale"));
///
/// // Get default locale's text
/// t!(locale, "greeting");
Expand Down Expand Up @@ -76,10 +76,10 @@ pub struct Locale {
}

impl Locale {
pub fn new(default: String) -> Self {
pub fn new<S: Into<String>>(default: S) -> Self {
Self {
locale: HashMap::new(),
default,
default: default.into(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/i18n/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use actix_cloud::{

#[actix_cloud::main]
async fn main() -> io::Result<()> {
let locale = Locale::new(String::from("en-US")).add_locale(i18n!("locale"));
let locale = Locale::new("en-US").add_locale(i18n!("locale"));

println!("Default: {}", t!(locale, "hello.world"));
println!("Translated: {}", t!(locale, "hello.world", "zh-CN"));
Expand Down
2 changes: 1 addition & 1 deletion examples/response/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async fn main() -> io::Result<()> {
let (logger, _guard) = LoggerBuilder::new().start();

// Init locale.
let locale = Locale::new(String::from("en-US")).add_locale(i18n!("locale"));
let locale = Locale::new("en-US").add_locale(i18n!("locale"));

// Init state.
let state = GlobalState {
Expand Down

0 comments on commit 8e863c9

Please sign in to comment.