Skip to content

Commit

Permalink
add swedish person names (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal authored Nov 15, 2023
1 parent 0f7998c commit c2d0a1f
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 9 deletions.
13 changes: 7 additions & 6 deletions include/faker-cxx/types/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ enum class Language
Czech,
Slovak,
Ukrainian,
Danish
Danish,
Swedish
};

const std::vector<Language> languages{Language::English, Language::Polish, Language::Italian, Language::French,
Language::German, Language::Russian, Language::Romanian, Language::Hindi,
Language::Finnish, Language::Nepali, Language::Spanish, Language::Turkish,
Language::Czech, Language::Slovak, Language::Ukrainian, Language::Danish};
const std::vector<Language> languages{
Language::English, Language::Polish, Language::Italian, Language::French, Language::German, Language::Russian,
Language::Romanian, Language::Hindi, Language::Finnish, Language::Nepali, Language::Spanish, Language::Turkish,
Language::Czech, Language::Slovak, Language::Ukrainian, Language::Danish, Language::Swedish};

inline std::string toString(Language language)
{
Expand All @@ -38,7 +39,7 @@ inline std::string toString(Language language)
{Language::Romanian, "Romanian"}, {Language::Hindi, "Hindi"}, {Language::Finnish, "Finnish"},
{Language::Nepali, "Nepali"}, {Language::Spanish, "Spanish"}, {Language::Turkish, "Turkish"},
{Language::Czech, "Czech"}, {Language::Slovak, "Slovak"}, {Language::Ukrainian, "Ukrainian"},
{Language::Danish, "Danish"}};
{Language::Danish, "Danish"}, {Language::Swedish, "Swedish"}};

return languageToStringMapping.at(language);
}
Expand Down
4 changes: 3 additions & 1 deletion src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "data/russian/RussianPeopleNames.h"
#include "data/slovak/SlovakPeopleNames.h"
#include "data/spanish/SpanishPeopleNames.h"
#include "data/swedish/SwedishPeopleNames.h"
#include "data/turkish/TurkishPeopleNames.h"
#include "data/ukrainian/UkrainianPeopleNames.h"
#include "data/ZodiacSigns.h"
Expand All @@ -42,7 +43,8 @@ const std::map<Language, PeopleNames> languageToPeopleNamesMapping{
{Language::Finnish, finnishPeopleNames}, {Language::Nepali, nepalesePeopleNames},
{Language::Spanish, spanishPeopleNames}, {Language::Turkish, turkishPeopleNames},
{Language::Czech, czechPeopleNames}, {Language::Slovak, slovakPeopleNames},
{Language::Ukrainian, ukrainianPeopleNames}, {Language::Danish, danishPeopleNames}};
{Language::Ukrainian, ukrainianPeopleNames}, {Language::Danish, danishPeopleNames},
{Language::Swedish, swedishPeopleNames}};

std::string middleNameForLanguage(Language language, std::optional<Sex> sex);
std::string prefixForLanguage(Language language, std::optional<Sex> sex);
Expand Down
7 changes: 5 additions & 2 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "data/russian/RussianPeopleNames.h"
#include "data/slovak/SlovakPeopleNames.h"
#include "data/spanish/SpanishPeopleNames.h"
#include "data/swedish/SwedishPeopleNames.h"
#include "data/turkish/TurkishPeopleNames.h"
#include "data/ukrainian/UkrainianPeopleNames.h"
#include "data/ZodiacSigns.h"
Expand All @@ -43,7 +44,8 @@ const std::map<Language, PeopleNames> languageToPeopleNamesMapping{
{Language::Finnish, finnishPeopleNames}, {Language::Nepali, nepalesePeopleNames},
{Language::Spanish, spanishPeopleNames}, {Language::Turkish, turkishPeopleNames},
{Language::Czech, czechPeopleNames}, {Language::Slovak, slovakPeopleNames},
{Language::Ukrainian, ukrainianPeopleNames}, {Language::Danish, danishPeopleNames}};
{Language::Ukrainian, ukrainianPeopleNames}, {Language::Danish, danishPeopleNames},
{Language::Swedish, swedishPeopleNames}};

const std::map<Language, std::string> generatedTestName{
{Language::English, "shouldGenerateEnglishName"}, {Language::French, "shouldGenerateFrenchName"},
Expand All @@ -53,7 +55,8 @@ const std::map<Language, std::string> generatedTestName{
{Language::Finnish, "shouldGenerateFinnishName"}, {Language::Nepali, "shouldGenerateNepaleseName"},
{Language::Spanish, "shouldGenerateSpanishName"}, {Language::Turkish, "shouldGenerateTurkishName"},
{Language::Czech, "shouldGenerateCzechName"}, {Language::Slovak, "shouldGenerateSlovakName"},
{Language::Ukrainian, "shouldGenerateUkrainianName"}, {Language::Danish, "shouldGenerateDanishName"}};
{Language::Ukrainian, "shouldGenerateUkrainianName"}, {Language::Danish, "shouldGenerateDanishName"},
{Language::Swedish, "shouldGenerateSwedishName"}};
}

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

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> swedishMalesFirstNames = {
"Lars", "Mikael", "Anders", "Johan", "Erik", "Per", "Peter", "Karl", "Thomas",
"Jan", "Daniel", "Fredrik", "Andreas", "Hans", "Stefan", "Mohamed", "Mats", "Marcus",
"Mattias", "Magnus", "Jonas", "Oskar", "Alexander", "Niklas", "Bengt", "Martin", "Bo",
"Nils", "Viktor", "Patrik", "Björn", "David", "Leif", "Filip", "Henrik", "Joakim",
"Emil", "Christer", "Ulf", "Sven", "Simon", "Christoffer", "Anton", "Gustav", "Robert",
"Christian", "William", "Tommy", "Kjell", "Lucas", "Rickard", "Håkan", "Adam", "Göran",
"Jakob", "Jonathan", "Rolf", "Lennart", "Robin", "Sebastian", "Elias", "Tobias", "John",
"Stig", "Axel", "Linus", "Oliver", "Kent", "Hugo", "Isak", "Roger", "Jesper",
"Claes", "Albin", "Ludvig", "Jörgen", "Rasmus", "Max", "Ali", "Jimmy", "Kenneth",
"Joel", "Gunnar", "Dennis", "Josef", "Johnny", "Olle", "Liam", "Leo", "Olof",
"Pontus", "Åke", "Kurt", "Kevin", "Samuel", "Edvin", "Gabriel", "Torbjörn", "Arvid",
"Felix"};

const std::vector<std::string> swedishFemalesFirstNames = {
"Anna", "Eva", "Maria", "Karin", "Sara", "Kristina", "Lena", "Emma",
"Kerstin", "Marie", "Malin", "Ingrid", "Jenny", "Hanna", "Linda", "Annika",
"Susanne", "Elin", "Monica", "Birgitta", "Sofia", "Johanna", "Inger", "Carina",
"Elisabeth", "Julia", "Ulla", "Katarina", "Linnéa", "Emelie", "Ida", "Helena",
"Camilla", "Åsa", "Anette", "Sandra", "Gunilla", "Anita", "Maja", "Marianne",
"Margareta", "Amanda", "Anneli", "Therese", "Ann", "Josefin", "Cecilia", "Jessica",
"Helen", "Lisa", "Matilda", "Caroline", "Alice", "Frida", "Ulrika", "Elsa",
"Barbro", "Siv", "Rebecca", "Madeleine", "Klara", "Ebba", "Sofie", "Isabelle",
"Agneta", "Gun", "Wilma", "Lina", "Berit", "Pia", "Ella", "Ellen",
"Yvonne", "Louise", "Astrid", "Moa", "Olivia", "Nathalie", "Mona", "Agnes",
"Emilia", "Alexandra", "Alva", "Britt", "Erika", "Viktoria", "Ann-Christin", "Felicia",
"Ann-Marie", "Sonja", "Britt-Marie", "Pernilla", "Lovisa", "Charlotte", "Linn", "Gunnel",
"Nina", "Mikaela", "Karolina", "Lisbeth"};
}
22 changes: 22 additions & 0 deletions src/modules/person/data/swedish/SwedishLastNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> swedishLastNames = {
"Andersson", "Johansson", "Karlsson", "Nilsson", "Eriksson", "Larsson", "Olsson", "Persson",
"Svensson", "Gustafsson", "Pettersson", "Jonsson", "Jansson", "Hansson", "Bengtsson", "Jönsson",
"Lindberg", "Jakobsson", "Magnusson", "Olofsson", "Lindström", "Lindqvist", "Lindgren", "Berg",
"Axelsson", "Bergström", "Lundberg", "Lind", "Lundgren", "Lundqvist", "Mattsson", "Berglund",
"Fredriksson", "Sandberg", "Henriksson", "Forsberg", "Sjöberg", "Ali", "Wallin", "Mohamed",
"Engström", "Eklund", "Danielsson", "Lundin", "Håkansson", "Björk", "Bergman", "Gunnarsson",
"Holm", "Wikström", "Samuelsson", "Isaksson", "Fransson", "Bergqvist", "Nyström", "Holmberg",
"Arvidsson", "Löfgren", "Söderberg", "Nyberg", "Blomqvist", "Claesson", "Nordström", "Ahmed",
"Mårtensson", "Lundström", "Hassan", "Viklund", "Björklund", "Eliasson", "Pålsson", "Berggren",
"Sandström", "Lund", "Nordin", "Ström", "Åberg", "Falk", "Ekström", "Hermansson",
"Holmgren", "Hellström", "Dahlberg", "Hedlund", "Sundberg", "Sjögren", "Ek", "Blom",
"Abrahamsson", "Martinsson", "Öberg", "Andreasson", "Strömberg", "Månsson", "Hansen", "Åkesson",
"Dahl", "Lindholm", "Norberg", "Holmqvist"};
}
17 changes: 17 additions & 0 deletions src/modules/person/data/swedish/SwedishPeopleNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "../NameFormats.h"
#include "../PeopleNames.h"
#include "SwedishFirstNames.h"
#include "SwedishLastNames.h"
#include "SwedishPrefixes.h"

namespace faker
{
const NameFormats swedishPersonNameFormats{{{"{firstName} {lastName}", 10}, {"{prefix} {firstName} {lastName}", 1}}};

const PeopleNames swedishPeopleNames{{swedishMalesFirstNames, {}, swedishLastNames, swedishPrefixes, {}},
{swedishFemalesFirstNames, {}, swedishLastNames, swedishPrefixes, {}},
swedishPersonNameFormats};

}
9 changes: 9 additions & 0 deletions src/modules/person/data/swedish/SwedishPrefixes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> swedishPrefixes{"Dr.", "Prof.", "PhD."};
}

0 comments on commit c2d0a1f

Please sign in to comment.