diff --git a/include/faker-cxx/Person.h b/include/faker-cxx/Person.h index dd0708aa..e38d274e 100644 --- a/include/faker-cxx/Person.h +++ b/include/faker-cxx/Person.h @@ -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. diff --git a/include/faker-cxx/types/Sex.h b/include/faker-cxx/types/Sex.h index b7afbe5b..dec1a34a 100644 --- a/include/faker-cxx/types/Sex.h +++ b/include/faker-cxx/types/Sex.h @@ -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 sexToStringMapping{{Sex::Male, "Male"}, {Sex::Female, "Female"}}; -// -// return sexToStringMapping.at(sex); -// } inline std::ostream& operator<<(std::ostream& os, Sex sex) { diff --git a/src/modules/person/Person.cpp b/src/modules/person/Person.cpp index e5ab7fb4..c025f936 100644 --- a/src/modules/person/Person.cpp +++ b/src/modules/person/Person.cpp @@ -288,9 +288,13 @@ std::string Person::suffix() return Helper::arrayElement(allSuffixes); } -std::string Person::sex() +std::string Person::sex(Language language) { - return Helper::arrayElement(sexes); + std::string chosenSex = Helper::arrayElement(sexes); + + Sex sexEnum = chosenSex == "Male" ? Sex::Male : Sex::Female; + + return translateSex(sexEnum, language); } std::string Person::gender()