i18n-keyless-core 1.14.11 → 1.14.12

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/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export type { Lang, PrimaryLang, Translations, LastUsedTranslations, HandleTranslateFunction, GetAllTranslationsFunction, SendTranslationsUsageFunction, GetAllTranslationsForAllLanguagesFunction, LanguagesConfig, LastRefresh, UniqueId, I18nKeylessRequestBody, I18nKeylessResponse, I18nKeylessTranslationsUsageRequestBody, I18nKeylessAllTranslationsResponse, FetchTranslationParams, TranslationOptions, } from "./types";
1
+ export type { Lang, PrimaryLang, Translations, TranslationsUsage, HandleTranslateFunction, GetAllTranslationsFunction, SendTranslationsUsageFunction, GetAllTranslationsForAllLanguagesFunction, LanguagesConfig, LastRefresh, UniqueId, I18nKeylessRequestBody, I18nKeylessResponse, I18nKeylessTranslationsUsageRequestBody, I18nKeylessAllTranslationsResponse, FetchTranslationParams, TranslationOptions, } from "./types";
2
2
  export { getTranslationCore, getAllTranslationsFromLanguage, sendTranslationsUsageToI18nKeyless, queue, } from "./service";
3
3
  export { api } from "./api";
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "i18n-keyless-core",
3
3
  "private": false,
4
- "version": "1.14.11",
4
+ "version": "1.14.12",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
package/dist/service.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Lang, TranslationOptions, I18nKeylessResponse, FetchTranslationParams, LastUsedTranslations } from "./types";
1
+ import type { Lang, TranslationOptions, I18nKeylessResponse, FetchTranslationParams, TranslationsUsage } from "./types";
2
2
  import MyPQueue from "./my-pqueue";
3
3
  export declare const queue: MyPQueue;
4
4
  /**
@@ -26,18 +26,18 @@ export declare function translateKey(key: string, store: FetchTranslationParams,
26
26
  */
27
27
  export declare function getAllTranslationsFromLanguage(targetLanguage: Lang, store: FetchTranslationParams): Promise<I18nKeylessResponse | void>;
28
28
  /**
29
- * Send the last used translations to i18n-keyless API
29
+ * Send the translations usage to i18n-keyless API
30
30
  *
31
31
  * This is used to clean up the translations database
32
32
  * and to avoid paying for translations that are not used anymore
33
33
  *
34
34
  * It's called on lib initialization
35
35
  * and everytime the language is set
36
- * @param lastUsedTranslations - The last used translations
36
+ * @param translationsUsage - The translations usage to send to the API
37
37
  * @param store - The translation store
38
38
  * @returns Promise resolving to the translation response or void if failed
39
39
  */
40
- export declare function sendTranslationsUsageToI18nKeyless(lastUsedTranslations: LastUsedTranslations, store: FetchTranslationParams): Promise<{
40
+ export declare function sendTranslationsUsageToI18nKeyless(translationsUsage: TranslationsUsage, store: FetchTranslationParams): Promise<{
41
41
  ok: boolean;
42
42
  message: string;
43
43
  } | void>;
package/dist/service.js CHANGED
@@ -162,29 +162,29 @@ export async function getAllTranslationsFromLanguage(targetLanguage, store) {
162
162
  }
163
163
  }
164
164
  /**
165
- * Send the last used translations to i18n-keyless API
165
+ * Send the translations usage to i18n-keyless API
166
166
  *
167
167
  * This is used to clean up the translations database
168
168
  * and to avoid paying for translations that are not used anymore
169
169
  *
170
170
  * It's called on lib initialization
171
171
  * and everytime the language is set
172
- * @param lastUsedTranslations - The last used translations
172
+ * @param translationsUsage - The translations usage to send to the API
173
173
  * @param store - The translation store
174
174
  * @returns Promise resolving to the translation response or void if failed
175
175
  */
176
- export async function sendTranslationsUsageToI18nKeyless(lastUsedTranslations, store) {
176
+ export async function sendTranslationsUsageToI18nKeyless(translationsUsage, store) {
177
177
  const config = store.config;
178
178
  if (!config.API_KEY) {
179
179
  console.error("i18n-keyless: No config found");
180
180
  return;
181
181
  }
182
- if (Object.keys(lastUsedTranslations).length === 0) {
182
+ if (Object.keys(translationsUsage).length === 0) {
183
183
  return;
184
184
  }
185
185
  try {
186
186
  const response = config.sendTranslationsUsage
187
- ? await config.sendTranslationsUsage(lastUsedTranslations)
187
+ ? await config.sendTranslationsUsage(translationsUsage)
188
188
  : await api
189
189
  .postLastUsedTranslations(`${config.API_URL || "https://api.i18n-keyless.com"}/translate/last-used-translations`, {
190
190
  method: "POST",
@@ -195,7 +195,7 @@ export async function sendTranslationsUsageToI18nKeyless(lastUsedTranslations, s
195
195
  },
196
196
  body: JSON.stringify({
197
197
  primaryLanguage: config.languages.primary,
198
- lastUsedTranslations,
198
+ translationsUsage,
199
199
  }),
200
200
  })
201
201
  .then((res) => res);
@@ -205,6 +205,6 @@ export async function sendTranslationsUsageToI18nKeyless(lastUsedTranslations, s
205
205
  return response;
206
206
  }
207
207
  catch (error) {
208
- console.error("i18n-keyless: send last used translation error:", error);
208
+ console.error("i18n-keyless: send translations usage error:", error);
209
209
  }
210
210
  }
package/dist/types.d.ts CHANGED
@@ -1,12 +1,17 @@
1
1
  export type PrimaryLang = "fr" | "en";
2
2
  export type Lang = "fr" | "en" | "nl" | "it" | "de" | "es" | "pl" | "pt" | "ro" | "sv" | "tr" | "ja" | "cn" | "ru" | "ko" | "ar";
3
+ /**
4
+ * The translations for a key
5
+ * { "un text": "a text" }
6
+ */
3
7
  export type Translations = Record<string, string>;
4
8
  /**
5
- * The last used translation for a key
9
+ * The translations usage for a key
6
10
  * Useful to clean up the translations database and to avoid paying for translations that are not used anymore
7
11
  * Record<string, YYYY-MM-DD>;
12
+ * { "un text": "2025-06-23" }
8
13
  */
9
- export type LastUsedTranslations = Record<string, string>;
14
+ export type TranslationsUsage = Record<string, string>;
10
15
  export type HandleTranslateFunction = (key: string) => Promise<{
11
16
  ok: boolean;
12
17
  message: string;
@@ -16,7 +21,7 @@ export type HandleTranslateFunction = (key: string) => Promise<{
16
21
  }>;
17
22
  export type GetAllTranslationsFunction = () => Promise<I18nKeylessResponse>;
18
23
  export type GetAllTranslationsForAllLanguagesFunction = () => Promise<I18nKeylessAllTranslationsResponse>;
19
- export type SendTranslationsUsageFunction = (lastUsedTranslations: LastUsedTranslations) => Promise<{
24
+ export type SendTranslationsUsageFunction = (translationsUsage: TranslationsUsage) => Promise<{
20
25
  ok: boolean;
21
26
  message: string;
22
27
  }>;
@@ -71,7 +76,7 @@ export interface I18nKeylessRequestBody {
71
76
  }
72
77
  export interface I18nKeylessTranslationsUsageRequestBody {
73
78
  primaryLanguage: LanguagesConfig["primary"];
74
- lastUsedTranslations: LastUsedTranslations;
79
+ translationsUsage: TranslationsUsage;
75
80
  }
76
81
  export interface I18nKeylessResponse {
77
82
  ok: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "i18n-keyless-core",
3
3
  "private": false,
4
- "version": "1.14.11",
4
+ "version": "1.14.12",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",