Skip to content

Commit

Permalink
add de_de for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
cksac committed Jan 6, 2025
1 parent 1612fea commit e34bb49
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelogs
## v3.1.0
## v3.1.1
- Add more french translation(@odarrouzet [#213](https://github.com/cksac/fake-rs/pull/213))
- Add de_de locale support in fake cli
- Enable Link-Time Optimization

## v3.1.0 (2024-12-27)
- Allow CityName implementation to be overrite by each locale
- Added DE_DE Locale (@xoryouyou [#75](https://github.com/cksac/fake-rs/pull/75))
- Added fake cli (@akhildevelops [#209](https://github.com/cksac/fake-rs/pull/209))
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ members = [
]

resolver = "2"

[profile.release]
lto = true
2 changes: 1 addition & 1 deletion fake/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fake"
version = "3.1.0"
version = "3.1.1"
authors = ["cksac <cs.cksac@gmail.com>"]
description = "An easy to use library and command line for generating fake data like name, number, address, lorem, dates, etc."
keywords = ["faker", "data", "generator", "random"]
Expand Down
12 changes: 5 additions & 7 deletions fake/src/bin/cli/fake_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum AVAILABLE_LOCALES {
JA_JP,
AR_SA,
PT_BR,
DE_DE,
}

macro_rules! fake_gen_on_return_type {
Expand All @@ -29,37 +30,34 @@ macro_rules! some_rules {
AVAILABLE_LOCALES::EN => {
let s = faker::$module::en::$fake($($arg)?);
Box::new(move |rng: &mut R| fake_gen_on_return_type!(s,rng$(,$return_type)?))

}
AVAILABLE_LOCALES::FR_FR => {
let s = faker::$module::fr_fr::$fake($($arg)?);
Box::new(move |rng: &mut R| fake_gen_on_return_type!(s,rng$(,$return_type)?))

}
AVAILABLE_LOCALES::ZH_TW => {
let s = faker::$module::zh_tw::$fake($($arg)?);
Box::new(move |rng: &mut R| fake_gen_on_return_type!(s,rng$(,$return_type)?))

}
AVAILABLE_LOCALES::ZH_CN => {
let s = faker::$module::zh_cn::$fake($($arg)?);
Box::new(move |rng: &mut R| fake_gen_on_return_type!(s,rng$(,$return_type)?))

}
AVAILABLE_LOCALES::AR_SA => {
let s = faker::$module::ar_sa::$fake($($arg)?);
Box::new(move |rng: &mut R| fake_gen_on_return_type!(s,rng$(,$return_type)?))

}
AVAILABLE_LOCALES::JA_JP => {
let s = faker::$module::ja_jp::$fake($($arg)?);
Box::new(move |rng: &mut R| fake_gen_on_return_type!(s,rng$(,$return_type)?))

}
AVAILABLE_LOCALES::PT_BR => {
let s = faker::$module::pt_br::$fake($($arg)?);
Box::new(move |rng: &mut R| fake_gen_on_return_type!(s,rng$(,$return_type)?))

}
AVAILABLE_LOCALES::DE_DE => {
let s = faker::$module::de_de::$fake($($arg)?);
Box::new(move |rng: &mut R| fake_gen_on_return_type!(s,rng$(,$return_type)?))
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions fake/src/bin/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use std::io::{self, Write};

mod fake_gen;

#[allow(non_upper_case_globals)]
mod names;

const AVAILABLE_LOCALES: [&str; 7] = ["en", "fr_fr", "zh_tw", "zh_cn", "ja_jp", "ar_sa", "pt_br"];
const AVAILABLE_LOCALES: [&str; 8] = [
"en", "fr_fr", "zh_tw", "zh_cn", "ja_jp", "ar_sa", "pt_br", "de_de",
];

pub use fake_gen::{all_fakegen_commands, AVAILABLE_LOCALES};
pub fn main() {
Expand Down Expand Up @@ -39,6 +38,7 @@ impl TryFrom<&str> for AVAILABLE_LOCALES {
"ja_jp" => AVAILABLE_LOCALES::JA_JP,
"ar_sa" => AVAILABLE_LOCALES::AR_SA,
"pt_br" => AVAILABLE_LOCALES::PT_BR,
"de_de" => AVAILABLE_LOCALES::DE_DE,
_=> return Err(format!("{} is either an invalid locale or not yet supported.\n The supported locales are: {:?}",str_val,AVAILABLE_LOCALES))
};
Ok(variant)
Expand Down
1 change: 0 additions & 1 deletion fake/src/bin/cli/names.rs

This file was deleted.

0 comments on commit e34bb49

Please sign in to comment.