i18n-keyless-core 1.14.3 → 1.14.5
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 +1 -1
- package/dist/package.json +1 -1
- package/dist/service.d.ts +3 -3
- package/dist/service.js +5 -5
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { Lang, PrimaryLang, Translations,
|
|
1
|
+
export type { Lang, PrimaryLang, Translations, LastUsedTranslations, HandleTranslateFunction, GetAllTranslationsFunction, SendTranslationsUsageFunction, GetAllTranslationsForAllLanguagesFunction, LanguagesConfig, LastRefresh, UniqueId, I18nKeylessRequestBody, I18nKeylessResponse, I18nKeylessTranslationsUsageRequestBody, I18nKeylessAllTranslationsResponse, FetchTranslationParams, TranslationOptions, } from "./types";
|
|
2
2
|
export { getTranslationCore, getAllTranslationsFromLanguage, queue } from "./service";
|
|
3
3
|
export { api } from "./api";
|
package/dist/package.json
CHANGED
package/dist/service.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Lang, TranslationOptions, I18nKeylessResponse, FetchTranslationParams,
|
|
1
|
+
import type { Lang, TranslationOptions, I18nKeylessResponse, FetchTranslationParams, LastUsedTranslations } from "./types";
|
|
2
2
|
import MyPQueue from "./my-pqueue";
|
|
3
3
|
export declare const queue: MyPQueue;
|
|
4
4
|
/**
|
|
@@ -33,11 +33,11 @@ export declare function getAllTranslationsFromLanguage(targetLanguage: Lang, sto
|
|
|
33
33
|
*
|
|
34
34
|
* It's called on lib initialization
|
|
35
35
|
* and everytime the language is set
|
|
36
|
-
* @param
|
|
36
|
+
* @param lastUsedTranslations - The last used translations
|
|
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(
|
|
40
|
+
export declare function sendTranslationsUsageToI18nKeyless(lastUsedTranslations: LastUsedTranslations, store: FetchTranslationParams): Promise<{
|
|
41
41
|
ok: boolean;
|
|
42
42
|
message: string;
|
|
43
43
|
} | void>;
|
package/dist/service.js
CHANGED
|
@@ -169,22 +169,22 @@ export async function getAllTranslationsFromLanguage(targetLanguage, store) {
|
|
|
169
169
|
*
|
|
170
170
|
* It's called on lib initialization
|
|
171
171
|
* and everytime the language is set
|
|
172
|
-
* @param
|
|
172
|
+
* @param lastUsedTranslations - The last used translations
|
|
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(
|
|
176
|
+
export async function sendTranslationsUsageToI18nKeyless(lastUsedTranslations, 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(
|
|
182
|
+
if (Object.keys(lastUsedTranslations).length === 0) {
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
try {
|
|
186
186
|
const response = config.sendTranslationsUsage
|
|
187
|
-
? await config.sendTranslationsUsage(
|
|
187
|
+
? await config.sendTranslationsUsage(lastUsedTranslations)
|
|
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(lastUsedTranslation, st
|
|
|
195
195
|
},
|
|
196
196
|
body: JSON.stringify({
|
|
197
197
|
primaryLanguage: config.languages.primary,
|
|
198
|
-
|
|
198
|
+
lastUsedTranslations,
|
|
199
199
|
}),
|
|
200
200
|
})
|
|
201
201
|
.then((res) => res);
|
package/dist/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type Translations = Record<string, string>;
|
|
|
6
6
|
* Useful to clean up the translations database and to avoid paying for translations that are not used anymore
|
|
7
7
|
* Record<string, YYYY-MM-DD>;
|
|
8
8
|
*/
|
|
9
|
-
export type
|
|
9
|
+
export type LastUsedTranslations = Record<string, string>;
|
|
10
10
|
export type HandleTranslateFunction = (key: string) => Promise<{
|
|
11
11
|
ok: boolean;
|
|
12
12
|
message: string;
|
|
@@ -16,7 +16,7 @@ export type HandleTranslateFunction = (key: string) => Promise<{
|
|
|
16
16
|
}>;
|
|
17
17
|
export type GetAllTranslationsFunction = () => Promise<I18nKeylessResponse>;
|
|
18
18
|
export type GetAllTranslationsForAllLanguagesFunction = () => Promise<I18nKeylessAllTranslationsResponse>;
|
|
19
|
-
export type SendTranslationsUsageFunction = (
|
|
19
|
+
export type SendTranslationsUsageFunction = (lastUsedTranslations: LastUsedTranslations) => Promise<{
|
|
20
20
|
ok: boolean;
|
|
21
21
|
message: string;
|
|
22
22
|
}>;
|
|
@@ -71,7 +71,7 @@ export interface I18nKeylessRequestBody {
|
|
|
71
71
|
}
|
|
72
72
|
export interface I18nKeylessTranslationsUsageRequestBody {
|
|
73
73
|
primaryLanguage: LanguagesConfig["primary"];
|
|
74
|
-
|
|
74
|
+
lastUsedTranslations: LastUsedTranslations;
|
|
75
75
|
}
|
|
76
76
|
export interface I18nKeylessResponse {
|
|
77
77
|
ok: boolean;
|