Skip to content

Commit

Permalink
[fix] [api] Add title and separator properties to locales. Allow for …
Browse files Browse the repository at this point in the history
…mapping of string properties. Add missing categories property.
  • Loading branch information
Marak committed Jul 7, 2015
1 parent 6692d78 commit 5414b79
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ exports.localeFallback = "en";

exports.definitions = {};

var _stringDefinitions = ["title", "separator"];

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"],
Expand All @@ -53,22 +52,22 @@ var _definitions = {
"phone_number": ["formats"],
"finance": ["account_type", "transaction_type", "currency"],
"internet": ["avatar_uri", "domain_suffix", "free_email", "password"],
"commerce": ["color", "department", "product_name", "price"]
"commerce": ["color", "department", "product_name", "price", "categories"],
"title": "",
"separator": ""
};

_stringDefinitions.forEach(function(d) {
if (typeof locales[exports.locale][d] === "undefined") {
exports.definitions[d] = locales[exports.localeFallback][d];
} else {
exports.definitions[d] = locales[exports.locale][d];
}
});

// Create a Getter for all definitions.foo.bar propetries
Object.keys(_definitions).forEach(function(d){
if (typeof exports.definitions[d] === "undefined") {
exports.definitions[d] = {};
}

if (typeof _definitions[d] === "string") {
exports.definitions[d] = locales[exports.locale][d];
return;
}

_definitions[d].forEach(function(p){
Object.defineProperty(exports.definitions[d], p, {
get: function () {
Expand Down

0 comments on commit 5414b79

Please sign in to comment.