-
-
Notifications
You must be signed in to change notification settings - Fork 517
Creating Locales
Locales are simple .js
JavaScript files. Bogus is using a direct copy of locales from faker.js, so keeping up with the format original node.js
format is necessary for comparability between both projects. Ideally, we'd like to keep both faker.js and Bogus locales in sync so both projects can benefit from the community locale contributions.
You can edit or add locales in:
Source\Bogus\locales
When Bogus is compiled, these .js
files are executed in a JavaScript VM and the result locale is converted to Json saved in Source\Bogus\data
which is the basis for the Bogus
dataset database.
The format of a locale should look like:
var en = {};
module["exports"] = en;
en.title = "English";
en.separator = " & ";
en.address = {
"city_prefix":[
"North","East","South"
],
"city_suffix":[
"town","ville","fort"
]
};
en.name = {
"first_name":[
"Brian", "Sandra", "Alex", "Dave"
],
"last_name":[
"Chavez", "Smith", "Tate", "Jones"
]
}
Again, these are not json files, these are really JavaScript files. So, in theory, you could execute any valid JavaScript code inside these files if you really wanted to. For example, checkout how we populate the avatars for the internet category:
en.internet = {
"free_email": [
"gmail.com",
"yahoo.com",
"hotmail.com"
],
"domain_suffix": [
"com",
"biz",
"info",
"name",
"net",
"org"
]
};
//All this avatar have been authorized by its awesome users to be use on live websites (not just mockups)
//For more information, please visit: http://uifaces.com/authorized
var avatarUri = ["jarjan/128.jpg",
"mahdif/128.jpg",
"akashsharma39/128.jpg",
"falling_soul/128.jpg",
"sainraja/128.jpg",
... ]
en.internet.avatar_uri = [];
for (var i = 0; i < avatarUri.length; i++) {
en.internet.avatar_uri.push("https://s3.amazonaws.com/uifaces/faces/twitter/" + avatarUri[i]);
};
If you're updating a locale be sure to add items at the end of an array not the beginning of an array. Adding items at the beginning of an array might break some unit tests based on our seeded test value. Ideally, please run all unit tests before submitting a pull request for maximum acceptance awesomeness.