i18n-keyless-node 1.14.11 → 1.14.13

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "i18n-keyless-node",
3
3
  "private": false,
4
- "version": "1.14.11",
4
+ "version": "1.14.13",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "postpublish": "rm -rf ./dist && rm *.tgz"
16
16
  },
17
17
  "dependencies": {
18
- "i18n-keyless-core": "1.14.11"
18
+ "i18n-keyless-core": "1.14.13"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@eslint/js": "^9.9.0",
package/dist/service.d.ts CHANGED
@@ -7,14 +7,14 @@ import { I18nKeylessNodeConfig } from "types";
7
7
  */
8
8
  export declare function getAllTranslationsForAllLanguages(): Promise<I18nKeylessAllTranslationsResponse | void>;
9
9
  /**
10
- * Send the last used translations to i18n-keyless API
10
+ * Send the translations usage to i18n-keyless API
11
11
  *
12
12
  * This is used to clean up the translations database
13
13
  * and to avoid paying for translations that are not used anymore
14
14
  *
15
15
  * It's called on lib initialization
16
16
  * and everytime the language is set
17
- * @param lastUsedTranslations - The last used translations
17
+ * @param translationsUsage - The translations usage
18
18
  * @param store - The translation store
19
19
  * @returns Promise resolving to the translation response or void if failed
20
20
  */
package/dist/service.js CHANGED
@@ -19,7 +19,7 @@ const store = {
19
19
  ko: {},
20
20
  ar: {},
21
21
  },
22
- lastUsedTranslations: {},
22
+ translationsUsage: {},
23
23
  uniqueId: "",
24
24
  lastRefresh: "",
25
25
  config: {
@@ -73,14 +73,14 @@ export async function getAllTranslationsForAllLanguages() {
73
73
  }
74
74
  }
75
75
  /**
76
- * Send the last used translations to i18n-keyless API
76
+ * Send the translations usage to i18n-keyless API
77
77
  *
78
78
  * This is used to clean up the translations database
79
79
  * and to avoid paying for translations that are not used anymore
80
80
  *
81
81
  * It's called on lib initialization
82
82
  * and everytime the language is set
83
- * @param lastUsedTranslations - The last used translations
83
+ * @param translationsUsage - The translations usage
84
84
  * @param store - The translation store
85
85
  * @returns Promise resolving to the translation response or void if failed
86
86
  */
@@ -90,13 +90,13 @@ export async function sendTranslationsUsageToI18nKeyless() {
90
90
  console.error("i18n-keyless: No config found");
91
91
  return;
92
92
  }
93
- const lastUsedTranslations = store.lastUsedTranslations;
94
- if (Object.keys(lastUsedTranslations).length === 0) {
93
+ const translationsUsage = store.translationsUsage;
94
+ if (Object.keys(translationsUsage).length === 0) {
95
95
  return;
96
96
  }
97
97
  try {
98
98
  const response = config.sendTranslationsUsage
99
- ? await config.sendTranslationsUsage(lastUsedTranslations)
99
+ ? await config.sendTranslationsUsage(translationsUsage)
100
100
  : await api
101
101
  .postLastUsedTranslations(`${config.API_URL || "https://api.i18n-keyless.com"}/translate/last-used-translations`, {
102
102
  method: "POST",
@@ -107,7 +107,7 @@ export async function sendTranslationsUsageToI18nKeyless() {
107
107
  },
108
108
  body: JSON.stringify({
109
109
  primaryLanguage: config.languages.primary,
110
- lastUsedTranslations,
110
+ translationsUsage,
111
111
  }),
112
112
  })
113
113
  .then((res) => res);
@@ -117,7 +117,7 @@ export async function sendTranslationsUsageToI18nKeyless() {
117
117
  return response;
118
118
  }
119
119
  catch (error) {
120
- console.error("i18n-keyless: send last used translation error:", error);
120
+ console.error("i18n-keyless: send translations usage error:", error);
121
121
  }
122
122
  }
123
123
  queue.on("empty", () => {
@@ -177,10 +177,10 @@ async function awaitForTranslationFn(key, currentLanguage, options) {
177
177
  }
178
178
  const forceTemporaryLang = options?.forceTemporary?.[currentLanguage];
179
179
  const translationKey = context ? `${key}__${context}` : key;
180
- const lastUsedAt = store.lastUsedTranslations[translationKey];
180
+ const lastUsedAt = store.translationsUsage[translationKey];
181
181
  const newLastUsedAt = new Date().toISOString().split("T")[0];
182
182
  if (lastUsedAt !== newLastUsedAt) {
183
- store.lastUsedTranslations[translationKey] = newLastUsedAt;
183
+ store.translationsUsage[translationKey] = newLastUsedAt;
184
184
  }
185
185
  // Safe navigation for potentially undefined language store
186
186
  const translation = translations[currentLanguage]?.[translationKey];
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { HandleTranslateFunction, Lang, LastUsedTranslations, PrimaryLang, SendTranslationsUsageFunction } from "i18n-keyless-core";
1
+ import { HandleTranslateFunction, Lang, TranslationsUsage, PrimaryLang, SendTranslationsUsageFunction } from "i18n-keyless-core";
2
2
  export type Translations = Record<string, string>;
3
3
  export interface I18nKeylessNodeConfig {
4
4
  /**
@@ -88,9 +88,9 @@ export interface I18nKeylessNodeStore {
88
88
  */
89
89
  translations: Record<Lang, Translations>;
90
90
  /**
91
- * the last used translations
91
+ * the translations usage
92
92
  */
93
- lastUsedTranslations: LastUsedTranslations;
93
+ translationsUsage: TranslationsUsage;
94
94
  /**
95
95
  * i18n-keyless' config
96
96
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "i18n-keyless-node",
3
3
  "private": false,
4
- "version": "1.14.11",
4
+ "version": "1.14.13",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "postpublish": "rm -rf ./dist && rm *.tgz"
16
16
  },
17
17
  "dependencies": {
18
- "i18n-keyless-core": "1.14.11"
18
+ "i18n-keyless-core": "1.14.13"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@eslint/js": "^9.9.0",