Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ A Rust library and command line tool for generating fake data in different langu
| Portugese (Portugal) | pt_pt |
| German | de_de |
| Italian | it_it |
| Cymraeg (Welsh) | cy_gb |


## Installation
Expand Down
8 changes: 7 additions & 1 deletion fake/examples/fakers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use fake::locales::{EN, FR_FR, ZH_CN, ZH_TW};
use fake::locales::{CY_GB, EN, FR_FR, ZH_CN, ZH_TW};
use fake::Fake;

fn lorem_faker() {
Expand Down Expand Up @@ -44,6 +44,12 @@ fn name_faker() {
let val: String = NameWithTitle(EN).fake();
println!("{:?}", val);

let val: String = Name(CY_GB).fake();
println!("{:?}", val);

let val: String = NameWithTitle(CY_GB).fake();
println!("{:?}", val);

let val: String = Name(ZH_TW).fake();
println!("{:?}", val);

Expand Down
5 changes: 5 additions & 0 deletions fake/src/bin/cli/fake_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub enum AVAILABLE_LOCALES {
PT_PT,
DE_DE,
IT_IT,
CY_GB,
}

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

mod fake_gen;

const AVAILABLE_LOCALES: [&str; 10] = [
"en", "fr_fr", "zh_tw", "zh_cn", "ja_jp", "ar_sa", "pt_br", "pt_pt", "de_de", "it_it",
const AVAILABLE_LOCALES: [&str; 11] = [
"en", "fr_fr", "zh_tw", "zh_cn", "ja_jp", "ar_sa", "pt_br", "pt_pt", "de_de", "it_it", "cy_gb",
];

pub use fake_gen::{all_fakegen_commands, AVAILABLE_LOCALES};
Expand Down Expand Up @@ -41,6 +41,7 @@ impl TryFrom<&str> for AVAILABLE_LOCALES {
"pt_pt" => AVAILABLE_LOCALES::PT_PT,
"de_de" => AVAILABLE_LOCALES::DE_DE,
"it_it" => AVAILABLE_LOCALES::IT_IT,
"cy_gb" => AVAILABLE_LOCALES::CY_GB,
_=> 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: 1 addition & 0 deletions fake/src/faker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ macro_rules! def_fakers {
def_fakers!(@m pt_pt=>PT_PT {$($name$(< $($lts),* >)?($($arg:$typ),*);)+});
def_fakers!(@m de_de=>DE_DE {$($name$(< $($lts),* >)?($($arg:$typ),*);)+});
def_fakers!(@m it_it=>IT_IT {$($name$(< $($lts),* >)?($($arg:$typ),*);)+});
def_fakers!(@m cy_gb=>CY_GB {$($name$(< $($lts),* >)?($($arg:$typ),*);)+});

};
}
Expand Down
Loading
Loading