Skip to content

Commit

Permalink
Support having two different LCID for the same locale (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwanago authored and sindresorhus committed Sep 22, 2019
1 parent 23105eb commit 7c7012a
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 204 deletions.
19 changes: 16 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,28 @@ exports.from = lcidCode => {
throw new TypeError('Expected a number');
}

return inverted[lcidCode];
return all[lcidCode];
};

exports.to = localeId => {
if (typeof localeId !== 'string') {
throw new TypeError('Expected a string');
}

return all[localeId];
const lcidCode = inverted[localeId];
if (lcidCode) {
return Number(inverted[localeId]);
}
};

exports.all = all;
exports.all = new Proxy(
inverted,
{
get(target, name) {
const lcid = target[name];
if (lcid) {
return Number(lcid);
}
}
}
);
Loading

0 comments on commit 7c7012a

Please sign in to comment.