Skip to content

Commit

Permalink
feat::Add multilanguage sexes (Issue #251) 101b
Browse files Browse the repository at this point in the history
  • Loading branch information
qmohitsingh committed Nov 25, 2023
1 parent bf04c0e commit 9e9d902
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/faker-cxx/Person.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Person
* Person::sex() // "Male"
* @endcode
*/
static std::string sex();
static std::string sex(Language language = Language::English);

/**
* @brief Returns a random gender.
Expand Down
6 changes: 0 additions & 6 deletions include/faker-cxx/types/Sex.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ inline std::string toString(Sex sex, Language language = Language::English)
return translateSex(sex, language);
}

// inline std::string toString(Sex sex,const std::string& language = "English")
//{
// std::map<Sex, std::string> sexToStringMapping{{Sex::Male, "Male"}, {Sex::Female, "Female"}};
//
// return sexToStringMapping.at(sex);
// }

inline std::ostream& operator<<(std::ostream& os, Sex sex)
{
Expand Down
8 changes: 6 additions & 2 deletions src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,13 @@ std::string Person::suffix()
return Helper::arrayElement<std::string>(allSuffixes);
}

std::string Person::sex()
std::string Person::sex(Language language)
{
return Helper::arrayElement<std::string>(sexes);
std::string chosenSex = Helper::arrayElement<std::string>(sexes);

Sex sexEnum = chosenSex == "Male" ? Sex::Male : Sex::Female;

return translateSex(sexEnum, language);
}

std::string Person::gender()
Expand Down

0 comments on commit 9e9d902

Please sign in to comment.