Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Usage:
- import Resx = require("i18n");
- let en = Resx("en");
- en.foo = "bar";
- let enUs = Resx("en-US");
- should.equal(en.foo, "bar");
- should.equal(enUs.foo, "bar");
- en.foo = "en-foo";
- should.equal(en.foo, "en-foo", "en test 1");
- should.equal(enUs.foo, "en-foo", "en-us test 1");
- enUs.foo = "en-us-foo";
- should.equal(en.foo, "en-foo", "en test 2");
- should.equal(enUs.foo, "en-us-foo", "en-us test 2");
- */
- class i18n {
- static get(locale: string) {
- let factory = i18n[locale];
- if (!factory) {
- switch (locale.length) {
- case 5:
- factory = i18n[locale] = Object.create(i18n.get(locale.substring(0, 2)));
- break;
- case 2:
- default:
- factory = i18n[locale] = {};
- break;
- }
- }
- return factory;
- }
- }
- export = i18n.get;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement