@tolgee/core
Advanced tools
Comparing version 1.0.0-alpha.33 to 1.0.0-alpha.34
@@ -5,3 +5,3 @@ import { TolgeeConfig } from './TolgeeConfig'; | ||
config: TolgeeConfig; | ||
scopes: Scope[]; | ||
scopes?: Scope[]; | ||
set preferredLanguages(languages: Set<string>); | ||
@@ -8,0 +8,0 @@ get preferredLanguages(): Set<string>; |
@@ -15,3 +15,2 @@ "use strict"; | ||
function Properties() { | ||
this.scopes = []; | ||
} | ||
@@ -31,2 +30,8 @@ Object.defineProperty(Properties.prototype, "preferredLanguages", { | ||
var result = localStorage.getItem(CURRENT_LANGUAGE_LOCAL_STORAGE_KEY); | ||
if (this.config.availableLanguages) { | ||
var isSavedLanguageAvailable = this.config.availableLanguages.indexOf(result) > -1; | ||
if (!isSavedLanguageAvailable) { | ||
result = undefined; | ||
} | ||
} | ||
if (!result) { | ||
@@ -45,3 +50,3 @@ result = this.getLanguageByNavigator(); | ||
Properties.prototype.getLanguageByNavigator = function () { | ||
if (window) { | ||
if (window && this.config.availableLanguages) { | ||
var preferred_1 = window.navigator.language; | ||
@@ -48,0 +53,0 @@ var exactMatch = this.config.availableLanguages.find(function (l) { return l === preferred_1; }); |
@@ -27,3 +27,4 @@ import { CoreService } from './services/CoreService'; | ||
get onLangLoaded(): import("./services/EventEmitter").EventEmitter<string>; | ||
private loadScopes; | ||
} | ||
export default Tolgee; |
@@ -68,6 +68,14 @@ "use strict"; | ||
return __generator(this, function (_a) { | ||
if (this.properties.config.mode === 'development' && !noWrap) { | ||
return [2 /*return*/, this.textService.wrap(key, params)]; | ||
switch (_a.label) { | ||
case 0: | ||
if (!(this.properties.config.mode === 'development' && !noWrap)) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, this.loadScopes()]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, this.translationService.loadTranslations()]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, this.textService.wrap(key, params)]; | ||
case 3: return [2 /*return*/, this.textService.translate(key, params)]; | ||
} | ||
return [2 /*return*/, this.textService.translate(key, params)]; | ||
}); | ||
@@ -112,18 +120,16 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!(this.properties.config.mode === "development")) return [3 /*break*/, 2]; | ||
_a = this.properties; | ||
return [4 /*yield*/, this.coreService.getScopes()]; | ||
return [4 /*yield*/, this.loadScopes()]; | ||
case 1: | ||
_a.scopes = _b.sent(); | ||
_b.label = 2; | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: return [4 /*yield*/, this.translationService.loadTranslations()]; | ||
case 3: | ||
_b.sent(); | ||
_a.sent(); | ||
return [4 /*yield*/, this.refresh()]; | ||
case 4: | ||
_b.sent(); | ||
_a.sent(); | ||
if (this.properties.config.watch) { | ||
@@ -165,2 +171,19 @@ this.observer.observe(); | ||
}); | ||
Tolgee.prototype.loadScopes = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(this.properties.scopes === undefined)) return [3 /*break*/, 2]; | ||
_a = this.properties; | ||
return [4 /*yield*/, this.coreService.getScopes()]; | ||
case 1: | ||
_a.scopes = _b.sent(); | ||
_b.label = 2; | ||
case 2: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return Tolgee; | ||
@@ -167,0 +190,0 @@ }()); |
@@ -13,3 +13,2 @@ "use strict"; | ||
this.defaultLanguage = 'en'; | ||
this.availableLanguages = ['en']; | ||
this.filesUrlPrefix = "i18n/"; | ||
@@ -16,0 +15,0 @@ this.tagAttributes = { |
{ | ||
"name": "@tolgee/core", | ||
"version": "1.0.0-alpha.33", | ||
"version": "1.0.0-alpha.34", | ||
"description": "Library providing ability to translate messages directly in context of developed application.", | ||
@@ -11,3 +11,10 @@ "main": "dist/tolgee.umd.js", | ||
}, | ||
"readme": "", | ||
"keywords": [ | ||
"localization", | ||
"internationalization", | ||
"l10n", | ||
"i18n", | ||
"translation", | ||
"languages" | ||
], | ||
"declaration": true, | ||
@@ -46,4 +53,2 @@ "directories": { | ||
"@types/node": "^14.14.22", | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"babel-loader": "^8.1.0", | ||
@@ -62,5 +67,2 @@ "babel-plugin-import": "^1.13.1", | ||
"jest-fetch-mock": "^3.0.3", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"react-multi-select-component": "^3.0.4", | ||
"reflect-metadata": "^0.1.13", | ||
@@ -77,3 +79,3 @@ "regenerator-runtime": "^0.13.7", | ||
}, | ||
"gitHead": "001778b88684d747940c966da74cf664f22d1b92", | ||
"gitHead": "5c3c60440fb2465f339e4f1e97f7320dee274e45", | ||
"publishConfig": { | ||
@@ -80,0 +82,0 @@ "access": "public" |
@@ -5,4 +5,4 @@ # Tolgee core library | ||
Core library of Tolgee localization toolkit. For more information about Tolgee, visit our documentation website | ||
[https://toolkit.tolgee.io](toolkit.tolgee.io). | ||
Core library of Tolgee localization toolkit. For more information about Tolgee Toolkit, visit our documentation website | ||
[toolkit.tolgee.io](https://toolkit.tolgee.io). | ||
@@ -9,0 +9,0 @@ ## Installation |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1231066
37
4253