@tolgee/core 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tolgee.cjs.js +15 -13
- package/dist/tolgee.cjs.js.map +1 -1
- package/dist/tolgee.cjs.min.js +1 -1
- package/dist/tolgee.cjs.min.js.map +1 -1
- package/dist/tolgee.esm.js +1 -1
- package/dist/tolgee.esm.js.map +1 -1
- package/dist/tolgee.umd.js +15 -13
- package/dist/tolgee.umd.js.map +1 -1
- package/dist/tolgee.umd.min.js +1 -1
- package/dist/tolgee.umd.min.js.map +1 -1
- package/lib/Properties.d.ts +2 -1
- package/lib/TolgeeConfig.d.ts +7 -1
- package/package.json +3 -3
package/dist/tolgee.umd.js
CHANGED
|
@@ -701,7 +701,7 @@
|
|
|
701
701
|
return TranslationService.translationByValue(message, defaultValue);
|
|
702
702
|
};
|
|
703
703
|
TranslationService.prototype.isFetchNeeded = function (lang) {
|
|
704
|
-
var isDevMode = this.properties.
|
|
704
|
+
var isDevMode = this.properties.mode === 'development';
|
|
705
705
|
var dataPresent = this.translationsCache.get(lang) !== undefined;
|
|
706
706
|
var devFetched = Boolean(this.fetchedDev[lang]);
|
|
707
707
|
return (isDevMode && !devFetched) || !dataPresent;
|
|
@@ -712,7 +712,7 @@
|
|
|
712
712
|
return __generator(this, function (_a) {
|
|
713
713
|
switch (_a.label) {
|
|
714
714
|
case 0:
|
|
715
|
-
isDevMode = this.properties.
|
|
715
|
+
isDevMode = this.properties.mode === 'development';
|
|
716
716
|
if (!isDevMode) return [3 /*break*/, 2];
|
|
717
717
|
return [4 /*yield*/, this.fetchTranslationsDevelopment(lang)];
|
|
718
718
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1311,7 +1311,7 @@
|
|
|
1311
1311
|
!element._tolgee.wrappedWithElementOnlyKey) {
|
|
1312
1312
|
return;
|
|
1313
1313
|
}
|
|
1314
|
-
if (this.properties.
|
|
1314
|
+
if (this.properties.mode === 'development' &&
|
|
1315
1315
|
!this.registeredElements.has(element)) {
|
|
1316
1316
|
this.translationHighlighter.listen(element);
|
|
1317
1317
|
}
|
|
@@ -1602,7 +1602,7 @@
|
|
|
1602
1602
|
console.error(e_1);
|
|
1603
1603
|
// eslint-disable-next-line no-console
|
|
1604
1604
|
console.error('Error getting scopes. Trying to switch to production mode!');
|
|
1605
|
-
this.properties.
|
|
1605
|
+
this.properties.mode = 'production';
|
|
1606
1606
|
return [3 /*break*/, 3];
|
|
1607
1607
|
case 3: return [2 /*return*/];
|
|
1608
1608
|
}
|
|
@@ -1709,10 +1709,9 @@
|
|
|
1709
1709
|
if (this._targetElement === undefined) {
|
|
1710
1710
|
this._targetElement = DEFAULT_TARGET_ELEMENT_SUPPLIER();
|
|
1711
1711
|
}
|
|
1712
|
-
this.mode = this.mode || (this.apiKey ? 'development' : 'production');
|
|
1713
1712
|
this.fallbackLanguage = this.fallbackLanguage || this.defaultLanguage;
|
|
1714
1713
|
if (this.watch === undefined) {
|
|
1715
|
-
this.watch = this.
|
|
1714
|
+
this.watch = Boolean(this.apiKey && this.apiUrl);
|
|
1716
1715
|
}
|
|
1717
1716
|
if (this.availableLanguages === undefined && this.staticData) {
|
|
1718
1717
|
this.availableLanguages = Object.keys(this.staticData);
|
|
@@ -1774,7 +1773,7 @@
|
|
|
1774
1773
|
this.handshake = function () {
|
|
1775
1774
|
var sharedConfiguration = __assign(__assign({}, _this.properties), { config: __assign(__assign({}, _this.properties.config), {
|
|
1776
1775
|
//remove properties, which cannot be sent by window.postMessage
|
|
1777
|
-
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.
|
|
1776
|
+
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.5.0" });
|
|
1778
1777
|
var timer = null;
|
|
1779
1778
|
var ping = function () {
|
|
1780
1779
|
_this.messages.send('TOLGEE_READY', sharedConfiguration);
|
|
@@ -3087,6 +3086,9 @@
|
|
|
3087
3086
|
};
|
|
3088
3087
|
Tolgee.prototype.init = function (config) {
|
|
3089
3088
|
this.dependencyService.init(config);
|
|
3089
|
+
var _a = this.dependencyService.properties.config, apiKey = _a.apiKey, apiUrl = _a.apiUrl;
|
|
3090
|
+
this.dependencyService.properties.mode =
|
|
3091
|
+
apiKey && apiUrl ? 'development' : 'production';
|
|
3090
3092
|
return this;
|
|
3091
3093
|
};
|
|
3092
3094
|
Tolgee.prototype.run = function () {
|
|
@@ -3096,7 +3098,7 @@
|
|
|
3096
3098
|
switch (_a.label) {
|
|
3097
3099
|
case 0:
|
|
3098
3100
|
this.dependencyService.run();
|
|
3099
|
-
if (!(this.properties.
|
|
3101
|
+
if (!(this.properties.mode === 'development')) return [3 /*break*/, 4];
|
|
3100
3102
|
_a.label = 1;
|
|
3101
3103
|
case 1:
|
|
3102
3104
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -3107,10 +3109,10 @@
|
|
|
3107
3109
|
case 3:
|
|
3108
3110
|
e_1 = _a.sent();
|
|
3109
3111
|
// eslint-disable-next-line no-console
|
|
3110
|
-
console.error("Couldn't connect to
|
|
3112
|
+
console.error("Couldn't connect to Tolgee");
|
|
3111
3113
|
// eslint-disable-next-line no-console
|
|
3112
3114
|
console.error(e_1);
|
|
3113
|
-
this.properties.
|
|
3115
|
+
this.properties.mode = 'production';
|
|
3114
3116
|
return [3 /*break*/, 4];
|
|
3115
3117
|
case 4: return [4 /*yield*/, this.dependencyService.translationService.loadTranslations()];
|
|
3116
3118
|
case 5:
|
|
@@ -3165,7 +3167,7 @@
|
|
|
3165
3167
|
return [4 /*yield*/, this.dependencyService.textService.translate(key, params, undefined, orEmpty, defaultValue)];
|
|
3166
3168
|
case 1:
|
|
3167
3169
|
translation = _a.sent();
|
|
3168
|
-
if (!(this.properties.
|
|
3170
|
+
if (!(this.properties.mode === 'development' && !noWrap)) return [3 /*break*/, 3];
|
|
3169
3171
|
return [4 /*yield*/, this.coreService.loadApiKeyDetails()];
|
|
3170
3172
|
case 2:
|
|
3171
3173
|
_a.sent();
|
|
@@ -3176,7 +3178,7 @@
|
|
|
3176
3178
|
});
|
|
3177
3179
|
};
|
|
3178
3180
|
Tolgee.prototype.wrap = function (key, params, defaultValue, translation) {
|
|
3179
|
-
if (this.properties.
|
|
3181
|
+
if (this.properties.mode === 'development') {
|
|
3180
3182
|
return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
|
|
3181
3183
|
}
|
|
3182
3184
|
else {
|
|
@@ -3198,7 +3200,7 @@
|
|
|
3198
3200
|
orEmpty = props.orEmpty !== undefined ? props.orEmpty : orEmpty;
|
|
3199
3201
|
}
|
|
3200
3202
|
var translation = this.dependencyService.textService.instant(key, params, undefined, orEmpty, defaultValue);
|
|
3201
|
-
if (this.properties.
|
|
3203
|
+
if (this.properties.mode === 'development' && !noWrap) {
|
|
3202
3204
|
return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
|
|
3203
3205
|
}
|
|
3204
3206
|
return translation;
|