@tolgee/core 3.1.1 → 3.1.2

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.
@@ -521,7 +521,7 @@ var TranslationService = /** @class */ (function () {
521
521
  _a.label = 2;
522
522
  case 2:
523
523
  this.fetchPromises[lang] = undefined;
524
- return [2 /*return*/];
524
+ return [2 /*return*/, this.translationsCache.get(lang)];
525
525
  }
526
526
  });
527
527
  });
@@ -2904,13 +2904,6 @@ var Tolgee = /** @class */ (function () {
2904
2904
  enumerable: false,
2905
2905
  configurable: true
2906
2906
  });
2907
- Object.defineProperty(Tolgee.prototype, "translationService", {
2908
- get: function () {
2909
- return this.dependencyService.translationService;
2910
- },
2911
- enumerable: false,
2912
- configurable: true
2913
- });
2914
2907
  Object.defineProperty(Tolgee.prototype, "lang", {
2915
2908
  get: function () {
2916
2909
  return this.properties.currentLanguage;
@@ -2921,12 +2914,14 @@ var Tolgee = /** @class */ (function () {
2921
2914
  * Using this setter can behave buggy when you change languages
2922
2915
  * too fast, since it changes the language property before
2923
2916
  * translations are actually loaded.
2924
- * @Deprecated use asynchronous changeLanguage method.
2917
+ * @deprecated use asynchronous changeLanguage method.
2925
2918
  */
2926
2919
  set: function (newLanguage) {
2927
2920
  var _this = this;
2928
2921
  this.properties.currentLanguage = newLanguage;
2929
- this.translationService.loadTranslations(newLanguage).then(function () {
2922
+ this.dependencyService.translationService
2923
+ .loadTranslations(newLanguage)
2924
+ .then(function () {
2930
2925
  _this.emitLangChangeEvent(newLanguage);
2931
2926
  });
2932
2927
  },
@@ -3015,7 +3010,7 @@ var Tolgee = /** @class */ (function () {
3015
3010
  return __awaiter(this, void 0, void 0, function () {
3016
3011
  return __generator(this, function (_a) {
3017
3012
  switch (_a.label) {
3018
- case 0: return [4 /*yield*/, this.translationService.loadTranslations(newLanguage)];
3013
+ case 0: return [4 /*yield*/, this.dependencyService.translationService.loadTranslations(newLanguage)];
3019
3014
  case 1:
3020
3015
  _a.sent();
3021
3016
  this.properties.currentLanguage = newLanguage;
@@ -3044,14 +3039,14 @@ var Tolgee = /** @class */ (function () {
3044
3039
  case 1:
3045
3040
  _a.sent();
3046
3041
  _a.label = 2;
3047
- case 2: return [4 /*yield*/, this.translationService.loadTranslations()];
3042
+ case 2: return [4 /*yield*/, this.dependencyService.translationService.loadTranslations()];
3048
3043
  case 3:
3049
3044
  _a.sent();
3050
3045
  return [4 /*yield*/, this.dependencyService.pluginManager.run()];
3051
3046
  case 4:
3052
3047
  _a.sent();
3053
3048
  if (!this.properties.config.preloadFallback) return [3 /*break*/, 6];
3054
- return [4 /*yield*/, this.translationService.loadTranslations(this.properties.config.fallbackLanguage)];
3049
+ return [4 /*yield*/, this.dependencyService.translationService.loadTranslations(this.properties.config.fallbackLanguage)];
3055
3050
  case 5:
3056
3051
  _a.sent();
3057
3052
  _a.label = 6;
@@ -3135,6 +3130,19 @@ var Tolgee = /** @class */ (function () {
3135
3130
  }
3136
3131
  return translation;
3137
3132
  };
3133
+ /**
3134
+ * Get currently cached translations for all languages
3135
+ */
3136
+ Tolgee.prototype.getCachedTranslations = function () {
3137
+ return this.dependencyService.translationService.getCachedTranslations();
3138
+ };
3139
+ /**
3140
+ * Loads translations for given language or returns them from cache
3141
+ * @returns Loaded translations
3142
+ */
3143
+ Tolgee.prototype.loadTranslations = function (lang) {
3144
+ return this.dependencyService.translationService.loadTranslations(lang);
3145
+ };
3138
3146
  Tolgee.prototype.emitLangChangeEvent = function (value) {
3139
3147
  var langChangedEmitter = this.onLangChange;
3140
3148
  langChangedEmitter.emit(value);