Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add japanese people names #269

Merged
merged 2 commits into from
Nov 17, 2023
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ CMakeSettings.json
out/
build-linux-gxx
build-linux-clang
#clangd index files
.cache/
17 changes: 10 additions & 7 deletions include/faker-cxx/types/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ enum class Country
Denmark,
Sweden,
Brazil,
Norway
Norway,
Japan,
};

const std::vector<Country> countries{Country::Usa, Country::England, Country::Poland, Country::Italy,
Country::France, Country::Germany, Country::Russia, Country::Romania,
Country::India, Country::Finland, Country::Nepal, Country::Spain,
Country::Turkey, Country::Czech, Country::Slovakia, Country::Ukraine,
Country::Denmark, Country::Sweden, Country::Brazil, Country::Norway};
const std::vector<Country> countries{
Country::Usa, Country::England, Country::Poland, Country::Italy, Country::France, Country::Germany,
Country::Russia, Country::Romania, Country::India, Country::Finland, Country::Nepal, Country::Spain,
Country::Turkey, Country::Czech, Country::Slovakia, Country::Ukraine, Country::Denmark, Country::Sweden,
Country::Brazil, Country::Norway, Country::Japan,
};

inline std::string toString(Country country)
{
Expand All @@ -45,7 +47,8 @@ inline std::string toString(Country country)
{Country::Finland, "Finland"}, {Country::Nepal, "Nepal"}, {Country::Spain, "Spain"},
{Country::Turkey, "Turkey"}, {Country::Czech, "Czech"}, {Country::Slovakia, "Slovakia"},
{Country::Ukraine, "Ukraine"}, {Country::Denmark, "Denmark"}, {Country::Sweden, "Sweden"},
{Country::Brazil, "Brazil"}, {Country::Norway, "Norway"}};
{Country::Brazil, "Brazil"}, {Country::Norway, "Norway"}, {Country::Japan, "Japan"},
};

return countryToStringMapping.at(country);
}
Expand Down
5 changes: 4 additions & 1 deletion src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "data/Hobbies.h"
#include "data/india/IndianPeopleNames.h"
#include "data/italy/ItalianPeopleNames.h"
#include "data/japan/JapanesePeopleNames.h"
#include "data/JobTitles.h"
#include "data/Languages.h"
#include "data/Nationalities.h"
Expand Down Expand Up @@ -50,7 +51,9 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames}};
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames},
{Country::Japan, japanesePeopleNames},
};

std::string middleNameForCountry(Country country, std::optional<Sex> sex);
std::string prefixForCountry(Country country, std::optional<Sex> sex);
Expand Down
9 changes: 7 additions & 2 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "data/Hobbies.h"
#include "data/india/IndianPeopleNames.h"
#include "data/italy/ItalianPeopleNames.h"
#include "data/japan/JapanesePeopleNames.h"
#include "data/JobTitles.h"
#include "data/Languages.h"
#include "data/Nationalities.h"
Expand Down Expand Up @@ -50,7 +51,9 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames}};
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames},
{Country::Japan, japanesePeopleNames},
};

const std::map<Country, std::string> generatedTestName{
{Country::England, "shouldGenerateEnglishName"}, {Country::France, "shouldGenerateFrenchName"},
Expand All @@ -62,7 +65,9 @@ const std::map<Country, std::string> generatedTestName{
{Country::Czech, "shouldGenerateCzechName"}, {Country::Slovakia, "shouldGenerateSlovakName"},
{Country::Ukraine, "shouldGenerateUkrainianName"}, {Country::Denmark, "shouldGenerateDanishName"},
{Country::Sweden, "shouldGenerateSwedishName"}, {Country::Usa, "shouldGenerateAmericanName"},
{Country::Brazil, "shouldGenerateBrazilianName"}, {Country::Norway, "shouldGenerateNorwegianName"}};
{Country::Brazil, "shouldGenerateBrazilianName"}, {Country::Norway, "shouldGenerateNorwegianName"},
{Country::Japan, "shouldGenerateJapaneseName"},
};
}

class PersonTest : public TestWithParam<Country>
Expand Down
35 changes: 35 additions & 0 deletions src/modules/person/data/japan/JapaneseFirstNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> japaneseMaleFirstNames{
"正一", "正二", "正三", "清", "辰雄", "三郎", "昭二", "昭三", "茂", "勇", "明", "弘", "勝", "稔",
"博", "隆", "誠", "浩", "健一", "大輔", "達也", "翔太", "拓也", "健太", "大輝", "翔", "駿", "蓮",
"大翔", "陸", "悠真", "蒼", "昭", "実", "進", "和夫", "修", "浩一", "哲也", "剛", "大介", "海斗",
"拓海", "颯太", "悠斗", "陽翔", "湊", "新", "樹", "正雄", "勝利", "豊", "和彦", "学", "直樹", "健太郎",
"大和", "陽向", "瑛太", "陽太", "正", "一郎", "勲", "徹", "浩二", "亮", "大樹", "翼", "義雄", "昭一",
"功", "武", "淳", "和也", "大地", "匠", "悠人", "朝陽", "律", "武雄", "英樹", "秀樹", "祐介", "雄太",
"翔平", "大貴", "太陽", "颯", "陽斗", "颯真", "蒼空", "優斗", "正治", "昇", "竜也", "聡", "貴大", "直人",
"輝", "優太", "悠太", "陸斗", "太一", "悠", "浩之", "健", "博之", "亮太", "一輝", "空", "陽大", "正夫",
"秀雄", "幸雄", "勉", "崇", "洋平", "拓哉", "涼太", "大雅", "海翔", "龍生", "結翔", "悠翔", "葵", "正男",
"辰男", "一男", "優", "雄大", "康平", "智也", "竜", "悠希", "歩夢",
};
const std::vector<std::string> japaneseFemaleFirstNames{
"千代子", "静子", "文子", "キヨ", "千代", "ハル", "キミ", "久子", "ヨシ", "清子", "正子", "貞子",
"八重子", "きよ", "フミ", "ハナ", "和子", "愛子", "きみ", "トミ", "はる", "マサ", "美代子", "光子",
"幸子", "照子", "芳子", "節子", "昭子", "信子", "敏子", "典子", "君子", "弘子", "洋子", "美智子",
"京子", "悦子", "栄子", "孝子", "良子", "恵子", "勝子", "紀子", "恵美子", "啓子", "久美子", "由美子",
"裕子", "順子", "智子", "明美", "愛", "恵", "麻衣", "麻美", "香織", "美穂", "彩", "沙織",
"愛美", "絵美", "舞", "恵美", "陽子", "成美", "あゆみ", "美香", "理恵", "友美", "智美", "明日香",
"由佳", "瞳", "麻衣子", "彩香", "真由美", "純子", "直美", "優子", "裕美", "由美", "直子", "めぐみ",
"美紀", "浩子", "ゆかり", "さくら", "美咲", "陽菜", "葵", "七海", "美羽", "結衣", "美月", "凛",
"美優", "未来", "優奈", "萌", "優花", "美桜", "莉子", "菜月", "結愛", "結菜", "花音", "心優",
"真央", "玲奈", "ひなた", "彩乃", "彩花", "優衣", "琴音", "百花", "遥", "里奈", "茜", "千尋",
"楓", "亜美", "佳奈", "真由", "桃子", "菜々子", "千夏", "菜摘", "奈々", "早紀", "杏", "陽葵",
"芽依", "結月", "咲良", "凜", "紬", "心愛", "花", "心春", "愛莉", "愛菜", "桜", "心結",
"美結",
};
}
12 changes: 12 additions & 0 deletions src/modules/person/data/japan/JapaneseLastNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> japaneseLastNames{
"佐藤", "鈴木", "高橋", "田中", "渡辺", "伊藤", "山本", "中村", "小林", "加藤",
"吉田", "山田", "佐々木", "山口", "斎藤", "松本", "井上", "木村", "林", "清水",
};
}
14 changes: 14 additions & 0 deletions src/modules/person/data/japan/JapanesePeopleNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "../NameFormats.h"
#include "../PeopleNames.h"
#include "JapaneseFirstNames.h"
#include "JapaneseLastNames.h"

namespace faker
{
const NameFormats japanesePeopleNameFormats{{"{lastName} {firstName}", 1}};
const PeopleNames japanesePeopleNames{{japaneseMaleFirstNames, {}, japaneseLastNames, {}, {}},
{japaneseFemaleFirstNames, {}, japaneseLastNames, {}, {}},
japanesePeopleNameFormats};
}