Skip to content

Commit

Permalink
[api] Added 71 additional gender options
Browse files Browse the repository at this point in the history
  * Adds new gender options for `en` locality
  * Updates example page to use gender
  * Still needs translations for other locales
  • Loading branch information
Marak committed Sep 4, 2017
1 parent 3861880 commit 71e3eb0
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 3 deletions.
9 changes: 8 additions & 1 deletion examples/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
var dob = faker.date.past(50, new Date("Sat Sep 20 1992 21:35:02 GMT+0200 (CEST)"));
dob = dob.getFullYear() + "-" + (dob.getMonth()+1) + "-" + dob.getDate(); // First month is "1"
$('#inputName').attr("value", faker.name.findName(firstName, lastName));
$('#inputGender').attr("value", faker.name.gender());
$('#inputDob').attr("value", dob);
$('#inputStreetAddress').attr("value", faker.address.streetAddress());
$('#inputCityStateZip').attr("value", faker.address.city() + ", " + faker.address.stateAbbr() + " " + faker.address.zipCode());
Expand Down Expand Up @@ -189,7 +190,6 @@ <h2>Generate Person Example</h2>
<button id="generateName" type="button" class="btn btn-primary">Generate New</button>
</div>
</div>

<div class="form-group">
<label for="inputName" class="col-lg-2 control-label">Name:</label>
<div class="col-lg-10">
Expand Down Expand Up @@ -260,6 +260,13 @@ <h2>Generate Person Example</h2>
</div>
</div>

<div class="form-group">
<label for="inputGender" class="col-lg-2 control-label">Gender:</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputGender" placeholder="Gender">
</div>
</div>

</fieldset>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function Faker (opts) {
self.system = bindAll(new System(self));

var _definitions = {
"name": ["first_name", "last_name", "prefix", "suffix", "title", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"],
"name": ["first_name", "last_name", "prefix", "suffix", "gender", "title", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"],
"address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode"],
"company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"],
"lorem": ["words"],
Expand Down
73 changes: 73 additions & 0 deletions lib/locales/en/name/gender.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module["exports"] = [
"Asexual",
"Female to male trans man",
"Female to male transgender man",
"Female to male transsexual man",
"F2M",
"Gender neutral",
"Hermaphrodite",
"Intersex man",
"Intersex person",
"Intersex woman",
"Male to female trans woman",
"Male to female transgender woman",
"Male to female transsexual woman",
"Man",
"M2F",
"Polygender",
"T* man",
"T* woman",
"Two* person",
"Two-spirit person",
"Woman",
"Agender",
"Androgyne",
"Androgynes",
"Androgynous",
"Bigender",
"Cis",
"Cis Female",
"Cis Male",
"Cis Man",
"Cis Woman",
"Cisgender",
"Cisgender Female",
"Cisgender Male",
"Cisgender Man",
"Cisgender Woman",
"Female to Male",
"FTM",
"Gender Fluid",
"Gender Nonconforming",
"Gender Questioning",
"Gender Variant",
"Genderqueer",
"Intersex",
"Male to Female",
"MTF",
"Neither",
"Neutrois",
"Non-binary",
"Other",
"Pangender",
"Trans",
"Trans Female",
"Trans Male",
"Trans Man",
"Trans Person",
"Trans*Female",
"Trans*Male",
"Trans*Man",
"Trans*Person",
"Trans*Woman",
"Transexual",
"Transexual Female",
"Transexual Male",
"Transexual Man",
"Transexual Person",
"Transexual Woman",
"Transgender Female",
"Transgender Person",
"Transmasculine",
"Two-spirit"
];
3 changes: 2 additions & 1 deletion lib/locales/en/name/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var name = {};
module['exports'] = name;
name.first_name = require("./first_name");
name.last_name = require("./last_name");
name.gender = require("./gender");
name.prefix = require("./prefix");
name.suffix = require("./suffix");
name.title = require("./title");
name.name = require("./name");
name.name = require("./name");
11 changes: 11 additions & 0 deletions lib/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ function Name (faker) {
faker.name.jobArea() + " " +
faker.name.jobType();
};


/**
* gender
*
* @method gender
* @memberof faker.name
*/
this.gender = function () {
return faker.random.arrayElement(faker.locales[faker.locale].name.gender);
}

/**
* prefix
Expand Down

0 comments on commit 71e3eb0

Please sign in to comment.