@apitable/i18n
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -18,2 +18,4 @@ "use strict"; | ||
__exportStar(require("./i18n.class"), exports); | ||
__exportStar(require("./language_pack/loader.interface"), exports); | ||
__exportStar(require("./language_pack/packs.interface"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const i18n_class_1 = require("../lib/i18n.class"); | ||
const i18n_errors_1 = require("../lib/i18n.errors"); | ||
const lib_1 = require("../lib/"); | ||
const mockLanguagePacks = { | ||
@@ -16,3 +16,3 @@ 'en-US': { | ||
it('should get text ok', () => { | ||
const i18n = i18n_class_1.I18N.createByLanguagePacks(mockLanguagePacks); | ||
const i18n = lib_1.I18N.createByLanguagePacks(mockLanguagePacks); | ||
expect(i18n.getText('text1')).toBe('This is text 1'); | ||
@@ -27,3 +27,16 @@ i18n.setLanguage('zh-CN'); | ||
}); | ||
class CustomLoader { | ||
load(language) { | ||
return mockLanguagePacks[language]; | ||
} | ||
} | ||
it('should custom loader ok', () => { | ||
const i18n_error = lib_1.I18N.createByLoader(new CustomLoader(), 'any-any'); | ||
expect(() => i18n_error.getText('text1')).toThrow(i18n_errors_1.LanguagePackNotFoundError); | ||
const i18n = lib_1.I18N.createByLoader(new CustomLoader()); | ||
expect(i18n.getText('text1')).toBe('This is text 1'); | ||
i18n.setLanguage('zh-CN'); | ||
expect(i18n.getText('text1')).toBe('这是中文1'); | ||
}); | ||
}); | ||
//# sourceMappingURL=i18n.test.js.map |
{ | ||
"name": "@apitable/i18n", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "i18n Locales with APITable power.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/lib/index.js", |
export * from './i18n.class'; | ||
export * from './language_pack/loader.interface'; | ||
export * from './language_pack/packs.interface'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21131
336