generaltranslation 8.2.11 → 8.2.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/CHANGELOG.md +15 -0
- package/dist/{IntlCache-k2qfrDqB.cjs → IntlCache-CAW8tKhd.cjs} +12 -12
- package/dist/IntlCache-CAW8tKhd.cjs.map +1 -0
- package/dist/{IntlCache-Ccg_cQPR.mjs → IntlCache-WZk0rKvj.mjs} +12 -12
- package/dist/IntlCache-WZk0rKvj.mjs.map +1 -0
- package/dist/LocaleConfig.d.ts +59 -0
- package/dist/LocaleConfig.js +225 -0
- package/dist/backwards-compatability/dataConversion.d.ts +23 -0
- package/dist/backwards-compatability/dataConversion.js +207 -0
- package/dist/backwards-compatability/oldHashJsxChildren.d.ts +23 -0
- package/dist/backwards-compatability/oldHashJsxChildren.js +79 -0
- package/dist/backwards-compatability/oldTypes.d.ts +21 -0
- package/dist/backwards-compatability/oldTypes.js +1 -0
- package/dist/backwards-compatability/typeChecking.d.ts +21 -0
- package/dist/backwards-compatability/typeChecking.js +61 -0
- package/dist/{base64-CUcEPEC5.cjs → base64-2fu94Klt.cjs} +3 -3
- package/dist/base64-2fu94Klt.cjs.map +1 -0
- package/dist/{base64-C1sogiix.mjs → base64-DH0STixb.mjs} +3 -3
- package/dist/base64-DH0STixb.mjs.map +1 -0
- package/dist/cache/IntlCache.d.ts +26 -0
- package/dist/cache/IntlCache.js +84 -0
- package/dist/cache/types.d.ts +32 -0
- package/dist/cache/types.js +1 -0
- package/dist/{core-3SOQ5ND6.cjs → core-7RP541eY.cjs} +18 -20
- package/dist/core-7RP541eY.cjs.map +1 -0
- package/dist/{core-6rY3oy32.d.cts → core-I9pWGafA.d.mts} +8 -8
- package/dist/{core-BYVWty_t.d.mts → core-TLJoDpJP.d.cts} +8 -8
- package/dist/{core-Bx0m6GOp.mjs → core-isLphYAZ.mjs} +18 -20
- package/dist/core-isLphYAZ.mjs.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +128 -0
- package/dist/core.js +137 -0
- package/dist/core.mjs +1 -1
- package/dist/derive/condenseVars.d.ts +7 -0
- package/dist/derive/condenseVars.js +30 -0
- package/dist/derive/declareVar.d.ts +26 -0
- package/dist/derive/declareVar.js +38 -0
- package/dist/derive/decodeVars.d.ts +9 -0
- package/dist/derive/decodeVars.js +52 -0
- package/dist/derive/derive.d.ts +53 -0
- package/dist/derive/derive.js +55 -0
- package/dist/derive/extractVars.d.ts +9 -0
- package/dist/derive/extractVars.js +34 -0
- package/dist/derive/index.d.ts +7 -0
- package/dist/derive/index.js +7 -0
- package/dist/derive/indexVars.d.ts +6 -0
- package/dist/derive/indexVars.js +52 -0
- package/dist/derive/utils/constants.d.ts +2 -0
- package/dist/derive/utils/constants.js +2 -0
- package/dist/derive/utils/regex.d.ts +2 -0
- package/dist/derive/utils/regex.js +4 -0
- package/dist/derive/utils/sanitizeVar.d.ts +12 -0
- package/dist/derive/utils/sanitizeVar.js +38 -0
- package/dist/derive/utils/traverseHelpers.d.ts +4 -0
- package/dist/derive/utils/traverseHelpers.js +22 -0
- package/dist/derive/utils/traverseIcu.d.ts +20 -0
- package/dist/derive/utils/traverseIcu.js +49 -0
- package/dist/derive/utils/types.d.ts +23 -0
- package/dist/derive/utils/types.js +1 -0
- package/dist/errors/ApiError.d.ts +7 -0
- package/dist/errors/ApiError.js +33 -0
- package/dist/errors/formattingErrors.d.ts +1 -0
- package/dist/errors/formattingErrors.js +3 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +1 -0
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +59 -0
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.js +147 -0
- package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +4 -0
- package/dist/formatting/custom-formats/CutoffFormat/constants.js +30 -0
- package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +48 -0
- package/dist/formatting/custom-formats/CutoffFormat/types.js +2 -0
- package/dist/formatting/format.d.ts +1 -0
- package/dist/formatting/format.js +257 -0
- package/dist/id/hashSource.d.ts +25 -0
- package/dist/id/hashSource.js +98 -0
- package/dist/id/hashTemplate.d.ts +4 -0
- package/dist/id/hashTemplate.js +6 -0
- package/dist/id/types.d.ts +7 -0
- package/dist/id/types.js +1 -0
- package/dist/{id-COlX5v3V.cjs → id-CyiXsQrY.cjs} +9 -9
- package/dist/id-CyiXsQrY.cjs.map +1 -0
- package/dist/{id-BmOyfaug.mjs → id-DbD7K-HL.mjs} +9 -9
- package/dist/id-DbD7K-HL.mjs.map +1 -0
- package/dist/id.cjs +1 -1
- package/dist/id.d.cts +9 -9
- package/dist/id.d.mts +9 -9
- package/dist/id.d.ts +3 -0
- package/dist/id.js +3 -0
- package/dist/id.mjs +1 -1
- package/dist/index.cjs +140 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -88
- package/dist/index.d.mts +88 -88
- package/dist/index.d.ts +1019 -0
- package/dist/index.js +1664 -0
- package/dist/index.mjs +140 -140
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +41 -26
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +38 -23
- package/dist/internal.d.mts +38 -23
- package/dist/internal.d.ts +19 -0
- package/dist/internal.js +17 -0
- package/dist/internal.mjs +41 -26
- package/dist/internal.mjs.map +1 -1
- package/dist/locales/customLocaleMapping.d.ts +11 -0
- package/dist/locales/customLocaleMapping.js +23 -0
- package/dist/locales/determineLocale.d.ts +1 -0
- package/dist/locales/determineLocale.js +72 -0
- package/dist/locales/getLocaleDirection.d.ts +1 -0
- package/dist/locales/getLocaleDirection.js +89 -0
- package/dist/locales/getLocaleEmoji.d.ts +2 -0
- package/dist/locales/getLocaleEmoji.js +319 -0
- package/dist/locales/getLocaleName.d.ts +1 -0
- package/dist/locales/getLocaleName.js +45 -0
- package/dist/locales/getLocaleProperties.d.ts +32 -0
- package/dist/locales/getLocaleProperties.js +220 -0
- package/dist/locales/getPluralForm.d.ts +9 -0
- package/dist/locales/getPluralForm.js +63 -0
- package/dist/locales/getRegionProperties.d.ts +7 -0
- package/dist/locales/getRegionProperties.js +61 -0
- package/dist/locales/isSameDialect.d.ts +1 -0
- package/dist/locales/isSameDialect.js +41 -0
- package/dist/locales/isSameLanguage.d.ts +1 -0
- package/dist/locales/isSameLanguage.js +20 -0
- package/dist/locales/isSupersetLocale.d.ts +1 -0
- package/dist/locales/isSupersetLocale.js +22 -0
- package/dist/locales/isValidLocale.d.ts +1 -0
- package/dist/locales/isValidLocale.js +75 -0
- package/dist/locales/requiresTranslation.d.ts +1 -0
- package/dist/locales/requiresTranslation.js +32 -0
- package/dist/locales/resolveAliasLocale.d.ts +8 -0
- package/dist/locales/resolveAliasLocale.js +21 -0
- package/dist/locales/resolveCanonicalLocale.d.ts +8 -0
- package/dist/locales/resolveCanonicalLocale.js +13 -0
- package/dist/logging/errors.d.ts +10 -0
- package/dist/logging/errors.js +29 -0
- package/dist/logging/logger.d.ts +121 -0
- package/dist/logging/logger.js +259 -0
- package/dist/logging/warnings.d.ts +2 -0
- package/dist/logging/warnings.js +2 -0
- package/dist/projects/getProjectData.d.ts +1 -0
- package/dist/projects/getProjectData.js +87 -0
- package/dist/settings/plurals.d.ts +3 -0
- package/dist/settings/plurals.js +14 -0
- package/dist/settings/settings.d.ts +2 -0
- package/dist/settings/settings.js +2 -0
- package/dist/settings/settingsUrls.d.ts +3 -0
- package/dist/settings/settingsUrls.js +3 -0
- package/dist/translate/api.d.ts +1 -0
- package/dist/translate/api.js +1 -0
- package/dist/translate/awaitJobs.d.ts +19 -0
- package/dist/translate/awaitJobs.js +112 -0
- package/dist/translate/checkJobStatus.d.ts +8 -0
- package/dist/translate/checkJobStatus.js +55 -0
- package/dist/translate/createBranch.d.ts +10 -0
- package/dist/translate/createBranch.js +53 -0
- package/dist/translate/createTag.d.ts +19 -0
- package/dist/translate/createTag.js +67 -0
- package/dist/translate/downloadFileBatch.d.ts +1 -0
- package/dist/translate/downloadFileBatch.js +77 -0
- package/dist/translate/enqueueFiles.d.ts +8 -0
- package/dist/translate/enqueueFiles.js +96 -0
- package/dist/translate/getOrphanedFiles.d.ts +8 -0
- package/dist/translate/getOrphanedFiles.js +97 -0
- package/dist/translate/processFileMoves.d.ts +25 -0
- package/dist/translate/processFileMoves.js +90 -0
- package/dist/translate/publishFiles.d.ts +17 -0
- package/dist/translate/publishFiles.js +56 -0
- package/dist/translate/queryBranchData.d.ts +3 -0
- package/dist/translate/queryBranchData.js +53 -0
- package/dist/translate/queryFileData.d.ts +42 -0
- package/dist/translate/queryFileData.js +71 -0
- package/dist/translate/querySourceFile.d.ts +1 -0
- package/dist/translate/querySourceFile.js +67 -0
- package/dist/translate/setupProject.d.ts +11 -0
- package/dist/translate/setupProject.js +63 -0
- package/dist/translate/submitUserEditDiffs.d.ts +12 -0
- package/dist/translate/submitUserEditDiffs.js +68 -0
- package/dist/translate/translateMany.d.ts +1 -0
- package/dist/translate/translateMany.js +103 -0
- package/dist/translate/uploadSourceFiles.d.ts +1 -0
- package/dist/translate/uploadSourceFiles.js +87 -0
- package/dist/translate/uploadTranslations.d.ts +1 -0
- package/dist/translate/uploadTranslations.js +101 -0
- package/dist/translate/utils/apiRequest.d.ts +1 -0
- package/dist/translate/utils/apiRequest.js +130 -0
- package/dist/translate/utils/batch.d.ts +52 -0
- package/dist/translate/utils/batch.js +126 -0
- package/dist/translate/utils/fetchWithTimeout.d.ts +1 -0
- package/dist/translate/utils/fetchWithTimeout.js +93 -0
- package/dist/translate/utils/generateRequestHeaders.d.ts +2 -0
- package/dist/translate/utils/generateRequestHeaders.js +26 -0
- package/dist/translate/utils/handleFetchError.d.ts +1 -0
- package/dist/translate/utils/handleFetchError.js +12 -0
- package/dist/translate/utils/validateFileFormatTransform.d.ts +16 -0
- package/dist/translate/utils/validateFileFormatTransform.js +29 -0
- package/dist/translate/utils/validateResponse.d.ts +1 -0
- package/dist/translate/utils/validateResponse.js +72 -0
- package/dist/{types-Cy8q2XZX.d.mts → types-AHtYZIP-.d.mts} +63 -40
- package/dist/{types-NKhpChvT.d.cts → types-Bf8_Apq_.d.cts} +63 -40
- package/dist/types-dir/api/branch.d.ts +10 -0
- package/dist/types-dir/api/branch.js +1 -0
- package/dist/types-dir/api/checkFileTranslations.d.ts +37 -0
- package/dist/types-dir/api/checkFileTranslations.js +1 -0
- package/dist/types-dir/api/downloadFile.d.ts +3 -0
- package/dist/types-dir/api/downloadFile.js +1 -0
- package/dist/types-dir/api/downloadFileBatch.d.ts +35 -0
- package/dist/types-dir/api/downloadFileBatch.js +1 -0
- package/dist/types-dir/api/enqueueEntries.d.ts +21 -0
- package/dist/types-dir/api/enqueueEntries.js +1 -0
- package/dist/types-dir/api/enqueueFiles.d.ts +70 -0
- package/dist/types-dir/api/enqueueFiles.js +1 -0
- package/dist/types-dir/api/entry.d.ts +39 -0
- package/dist/types-dir/api/entry.js +1 -0
- package/dist/types-dir/api/fetchTranslations.d.ts +12 -0
- package/dist/types-dir/api/fetchTranslations.js +1 -0
- package/dist/types-dir/api/file.d.ts +57 -0
- package/dist/types-dir/api/file.js +1 -0
- package/dist/types-dir/api/json.d.ts +5 -0
- package/dist/types-dir/api/json.js +1 -0
- package/dist/types-dir/api/project.d.ts +7 -0
- package/dist/types-dir/api/project.js +1 -0
- package/dist/types-dir/api/translate.d.ts +34 -0
- package/dist/types-dir/api/translate.js +1 -0
- package/dist/types-dir/api/translateMany.d.ts +5 -0
- package/dist/types-dir/api/translateMany.js +1 -0
- package/dist/types-dir/api/translationStatus.d.ts +9 -0
- package/dist/types-dir/api/translationStatus.js +1 -0
- package/dist/types-dir/api/uploadFiles.d.ts +44 -0
- package/dist/types-dir/api/uploadFiles.js +1 -0
- package/dist/types-dir/jsx/content.d.ts +61 -0
- package/dist/types-dir/jsx/content.js +11 -0
- package/dist/types-dir/jsx/variables.d.ts +9 -0
- package/dist/types-dir/jsx/variables.js +1 -0
- package/dist/types-dir/transformations.d.ts +8 -0
- package/dist/types-dir/transformations.js +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +129 -0
- package/dist/types.js +2 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/base64.d.ts +2 -0
- package/dist/utils/base64.js +28 -0
- package/dist/utils/isSupportedFileFormatTransform.d.ts +8 -0
- package/dist/utils/isSupportedFileFormatTransform.js +26 -0
- package/dist/utils/isVariable.d.ts +2 -0
- package/dist/utils/isVariable.js +22 -0
- package/dist/utils/minify.d.ts +2 -0
- package/dist/utils/minify.js +10 -0
- package/dist/utils/stableStringify.d.ts +1 -0
- package/dist/utils/stableStringify.js +40 -0
- package/package.json +5 -6
- package/dist/IntlCache-Ccg_cQPR.mjs.map +0 -1
- package/dist/IntlCache-k2qfrDqB.cjs.map +0 -1
- package/dist/base64-C1sogiix.mjs.map +0 -1
- package/dist/base64-CUcEPEC5.cjs.map +0 -1
- package/dist/core-3SOQ5ND6.cjs.map +0 -1
- package/dist/core-Bx0m6GOp.mjs.map +0 -1
- package/dist/id-BmOyfaug.mjs.map +0 -1
- package/dist/id-COlX5v3V.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_IntlCache = require("./IntlCache-
|
|
3
|
-
const require_core = require("./core-
|
|
4
|
-
const require_base64 = require("./base64-
|
|
2
|
+
const require_IntlCache = require("./IntlCache-CAW8tKhd.cjs");
|
|
3
|
+
const require_core = require("./core-7RP541eY.cjs");
|
|
4
|
+
const require_base64 = require("./base64-2fu94Klt.cjs");
|
|
5
5
|
const require_ApiError = require("./ApiError-CZ45tkW6.cjs");
|
|
6
|
-
const require_id = require("./id-
|
|
6
|
+
const require_id = require("./id-CyiXsQrY.cjs");
|
|
7
7
|
//#region src/logging/errors.ts
|
|
8
8
|
const GT_ERROR_PREFIX = "GT Error:";
|
|
9
9
|
const translationTimeoutError = (timeout) => `${GT_ERROR_PREFIX} Translation request timed out after ${timeout}ms.`;
|
|
@@ -110,10 +110,10 @@ function getRetryDelay(policy, attempt) {
|
|
|
110
110
|
* Encapsulates URL construction, fetch with timeout, error handling,
|
|
111
111
|
* response validation, and JSON parsing.
|
|
112
112
|
*
|
|
113
|
-
* @param config - The configuration for the API call
|
|
113
|
+
* @param config - The configuration for the API call.
|
|
114
114
|
* @param endpoint - The API endpoint path (e.g. '/v2/project/jobs/info')
|
|
115
|
-
* @param options - Optional request options
|
|
116
|
-
* @returns The parsed JSON response
|
|
115
|
+
* @param options - Optional request options.
|
|
116
|
+
* @returns The parsed JSON response.
|
|
117
117
|
*/
|
|
118
118
|
async function apiRequest(config, endpoint, options) {
|
|
119
119
|
const timeout = options?.timeout ?? 6e4;
|
|
@@ -158,7 +158,7 @@ async function _translateMany(requests, globalMetadata, config, timeout) {
|
|
|
158
158
|
const hash = key ?? metadata?.hash ?? require_id.hashSource({
|
|
159
159
|
source,
|
|
160
160
|
dataFormat: metadata?.dataFormat ?? "STRING",
|
|
161
|
-
...metadata
|
|
161
|
+
...metadata
|
|
162
162
|
});
|
|
163
163
|
hashOrder?.push(hash);
|
|
164
164
|
requestsObject[hash] = {
|
|
@@ -192,9 +192,9 @@ async function _translateMany(requests, globalMetadata, config, timeout) {
|
|
|
192
192
|
* @internal
|
|
193
193
|
* Enqueues files for project setup the General Translation API.
|
|
194
194
|
* @param files - References of files to translate (file content already uploaded)
|
|
195
|
-
* @param config - The configuration for the API call
|
|
195
|
+
* @param config - The configuration for the API call.
|
|
196
196
|
* @param timeoutMS - The timeout in milliseconds
|
|
197
|
-
* @returns The result of the API call
|
|
197
|
+
* @returns The result of the API call.
|
|
198
198
|
*/
|
|
199
199
|
async function _setupProject(files, config, options) {
|
|
200
200
|
return apiRequest(config, "/v2/project/setup/generate", {
|
|
@@ -214,9 +214,9 @@ async function _setupProject(files, config, options) {
|
|
|
214
214
|
//#region src/translate/utils/batch.ts
|
|
215
215
|
/**
|
|
216
216
|
* Splits an array into batches of a specified size.
|
|
217
|
-
* @param items - The array to split into batches
|
|
218
|
-
* @param batchSize - The maximum size of each batch
|
|
219
|
-
* @returns An array of batches
|
|
217
|
+
* @param items - The array to split into batches.
|
|
218
|
+
* @param batchSize - The maximum size of each batch.
|
|
219
|
+
* @returns An array of batches.
|
|
220
220
|
*/
|
|
221
221
|
function createBatches(items, batchSize) {
|
|
222
222
|
const batches = [];
|
|
@@ -226,10 +226,10 @@ function createBatches(items, batchSize) {
|
|
|
226
226
|
/**
|
|
227
227
|
* Processes items in batches using a provided processor function.
|
|
228
228
|
*
|
|
229
|
-
* @param items - The items to process
|
|
230
|
-
* @param processor - Async function that processes a single batch and returns items
|
|
231
|
-
* @param options - Optional configuration for batch processing
|
|
232
|
-
* @returns Promise that resolves to a BatchList containing all processed items
|
|
229
|
+
* @param items - The items to process.
|
|
230
|
+
* @param processor - Async function that processes a single batch and returns items.
|
|
231
|
+
* @param options - Optional configuration for batch processing.
|
|
232
|
+
* @returns Promise that resolves to a BatchList containing all processed items.
|
|
233
233
|
*
|
|
234
234
|
* @example
|
|
235
235
|
* ```typescript
|
|
@@ -275,9 +275,9 @@ async function processBatches(items, processor, options = {}) {
|
|
|
275
275
|
* @internal
|
|
276
276
|
* Enqueues files for translation in the General Translation API.
|
|
277
277
|
* @param files - References of files to translate (file content already uploaded)
|
|
278
|
-
* @param options - The options for the API call
|
|
279
|
-
* @param config - The configuration for the API call
|
|
280
|
-
* @returns The result of the API call
|
|
278
|
+
* @param options - The options for the API call.
|
|
279
|
+
* @param config - The configuration for the API call.
|
|
280
|
+
* @returns The result of the API call.
|
|
281
281
|
*/
|
|
282
282
|
async function _enqueueFiles(files, options, config) {
|
|
283
283
|
require_base64.validateFileFormatTransforms(files);
|
|
@@ -312,9 +312,9 @@ async function _enqueueFiles(files, options, config) {
|
|
|
312
312
|
/**
|
|
313
313
|
* @internal
|
|
314
314
|
* Creates or upserts a file tag in the General Translation API.
|
|
315
|
-
* @param options - The tag creation options
|
|
316
|
-
* @param config - The configuration for the API call
|
|
317
|
-
* @returns The created or updated tag
|
|
315
|
+
* @param options - The tag creation options.
|
|
316
|
+
* @param config - The configuration for the API call.
|
|
317
|
+
* @returns The created or updated tag.
|
|
318
318
|
*/
|
|
319
319
|
async function _createTag(options, config) {
|
|
320
320
|
return await apiRequest(config, "/v2/project/tags/create", { body: {
|
|
@@ -329,8 +329,8 @@ async function _createTag(options, config) {
|
|
|
329
329
|
* @internal
|
|
330
330
|
* Downloads multiple translation files in batches.
|
|
331
331
|
* @param files - Array of files to download
|
|
332
|
-
* @param options - The options for the API call
|
|
333
|
-
* @param config - The configuration for the request
|
|
332
|
+
* @param options - The options for the API call.
|
|
333
|
+
* @param config - The configuration for the request.
|
|
334
334
|
* @returns Promise resolving to a BatchList with all downloaded files
|
|
335
335
|
*/
|
|
336
336
|
async function _downloadFileBatch(requests, options, config) {
|
|
@@ -420,9 +420,9 @@ function _getRegionProperties(region, defaultLocale = "en", customMapping) {
|
|
|
420
420
|
/**
|
|
421
421
|
* @internal
|
|
422
422
|
* Uploads source files to the General Translation API in batches.
|
|
423
|
-
* @param files - The files to upload
|
|
424
|
-
* @param options - The options for the API call
|
|
425
|
-
* @param config - The configuration for the API call
|
|
423
|
+
* @param files - The files to upload.
|
|
424
|
+
* @param options - The options for the API call.
|
|
425
|
+
* @param config - The configuration for the API call.
|
|
426
426
|
* @returns Promise resolving to a BatchList with all uploaded files
|
|
427
427
|
*/
|
|
428
428
|
async function _uploadSourceFiles(files, options, config) {
|
|
@@ -454,8 +454,8 @@ async function _uploadSourceFiles(files, options, config) {
|
|
|
454
454
|
* @internal
|
|
455
455
|
* Uploads multiple translations to the General Translation API in batches.
|
|
456
456
|
* @param files - Translations to upload with their source
|
|
457
|
-
* @param options - The options for the API call
|
|
458
|
-
* @param config - The configuration for the API call
|
|
457
|
+
* @param options - The options for the API call.
|
|
458
|
+
* @param config - The configuration for the API call.
|
|
459
459
|
* @returns Promise resolving to a BatchList with all uploaded files
|
|
460
460
|
*/
|
|
461
461
|
async function _uploadTranslations(files, options, config) {
|
|
@@ -499,8 +499,8 @@ async function _uploadTranslations(files, options, config) {
|
|
|
499
499
|
* @internal
|
|
500
500
|
* Gets the source file and translation information for a given file ID and version ID.
|
|
501
501
|
* @param query - The file ID and version ID to get the source file and translation information for
|
|
502
|
-
* @param options - The options for the API call
|
|
503
|
-
* @param config - The configuration for the request
|
|
502
|
+
* @param options - The options for the API call.
|
|
503
|
+
* @param config - The configuration for the request.
|
|
504
504
|
* @returns The source file and translation information for the given file ID and version ID
|
|
505
505
|
*/
|
|
506
506
|
async function _querySourceFile(query, options, config) {
|
|
@@ -521,9 +521,9 @@ async function _querySourceFile(query, options, config) {
|
|
|
521
521
|
* @internal
|
|
522
522
|
* Gets the project data for a given project ID.
|
|
523
523
|
* @param projectId - The project ID to get the project data for
|
|
524
|
-
* @param options - The options for the API call
|
|
525
|
-
* @param config - The configuration for the request
|
|
526
|
-
* @returns The project data for the given project ID
|
|
524
|
+
* @param options - The options for the API call.
|
|
525
|
+
* @param config - The configuration for the request.
|
|
526
|
+
* @returns The project data for the given project ID.
|
|
527
527
|
*/
|
|
528
528
|
async function _getProjectData(projectId, options, config) {
|
|
529
529
|
const { baseUrl } = config;
|
|
@@ -545,11 +545,11 @@ async function _getProjectData(projectId, options, config) {
|
|
|
545
545
|
//#region src/translate/checkJobStatus.ts
|
|
546
546
|
/**
|
|
547
547
|
* @internal
|
|
548
|
-
* Queries job statuses for a project
|
|
549
|
-
* @param jobIds - Job IDs
|
|
550
|
-
* @param config - The configuration for the API call
|
|
551
|
-
* @param
|
|
552
|
-
* @returns The result of the API call
|
|
548
|
+
* Queries job statuses for a project.
|
|
549
|
+
* @param jobIds - Job IDs.
|
|
550
|
+
* @param config - The configuration for the API call.
|
|
551
|
+
* @param timeoutMs - The timeout in milliseconds.
|
|
552
|
+
* @returns The result of the API call.
|
|
553
553
|
*/
|
|
554
554
|
async function _checkJobStatus(jobIds, config, timeoutMs) {
|
|
555
555
|
return apiRequest(config, "/v2/project/jobs/info", {
|
|
@@ -562,10 +562,10 @@ async function _checkJobStatus(jobIds, config, timeoutMs) {
|
|
|
562
562
|
/**
|
|
563
563
|
* @internal
|
|
564
564
|
* Polls job statuses until all jobs are finished or the timeout is reached.
|
|
565
|
-
* @param enqueueResult - The result from enqueueFiles
|
|
566
|
-
* @param options - Polling configuration
|
|
567
|
-
* @param config - API credentials and configuration
|
|
568
|
-
* @returns The final status of all jobs
|
|
565
|
+
* @param enqueueResult - The result from enqueueFiles.
|
|
566
|
+
* @param options - Polling configuration.
|
|
567
|
+
* @param config - API credentials and configuration.
|
|
568
|
+
* @returns The final status of all jobs.
|
|
569
569
|
*/
|
|
570
570
|
async function _awaitJobs(enqueueResult, options, config) {
|
|
571
571
|
const pollingInterval = (options?.pollingIntervalSeconds ?? 5) * 1e3;
|
|
@@ -609,9 +609,9 @@ async function _awaitJobs(enqueueResult, options, config) {
|
|
|
609
609
|
* @internal
|
|
610
610
|
* Queries data about one or more source or translation files.
|
|
611
611
|
* @param data - Object mapping source or translation file information
|
|
612
|
-
* @param options - The options for the API call
|
|
613
|
-
* @param config - The configuration for the API call
|
|
614
|
-
* @returns The file data
|
|
612
|
+
* @param options - The options for the API call.
|
|
613
|
+
* @param config - The configuration for the API call.
|
|
614
|
+
* @returns The file data.
|
|
615
615
|
*/
|
|
616
616
|
async function _queryFileData(data, options = {}, config) {
|
|
617
617
|
return apiRequest(config, "/v2/project/files/info", {
|
|
@@ -637,8 +637,8 @@ async function _queryFileData(data, options = {}, config) {
|
|
|
637
637
|
* @internal
|
|
638
638
|
* Queries branch information from the API.
|
|
639
639
|
* @param query - Object mapping the current branch and incoming branches
|
|
640
|
-
* @param config - The configuration for the API call
|
|
641
|
-
* @returns The branch information
|
|
640
|
+
* @param config - The configuration for the API call.
|
|
641
|
+
* @returns The branch information.
|
|
642
642
|
*/
|
|
643
643
|
async function _queryBranchData(query, config) {
|
|
644
644
|
return apiRequest(config, "/v2/project/branches/info", { body: query });
|
|
@@ -649,8 +649,8 @@ async function _queryBranchData(query, config) {
|
|
|
649
649
|
* @internal
|
|
650
650
|
* Creates a new branch in the API.
|
|
651
651
|
* @param query - Object mapping the branch name and default branch flag
|
|
652
|
-
* @param config - The configuration for the API call
|
|
653
|
-
* @returns The created branch information
|
|
652
|
+
* @param config - The configuration for the API call.
|
|
653
|
+
* @returns The created branch information.
|
|
654
654
|
*/
|
|
655
655
|
async function _createBranch(query, config) {
|
|
656
656
|
return apiRequest(config, "/v2/project/branches/create", { body: query });
|
|
@@ -663,7 +663,7 @@ async function _createBranch(query, config) {
|
|
|
663
663
|
* Called when the CLI detects that files have been moved/renamed.
|
|
664
664
|
* @param moves - Array of move mappings (old fileId to new fileId)
|
|
665
665
|
* @param options - Options including branchId and timeout
|
|
666
|
-
* @param config - The configuration for the API call
|
|
666
|
+
* @param config - The configuration for the API call.
|
|
667
667
|
* @returns Promise resolving to the move results
|
|
668
668
|
*/
|
|
669
669
|
async function _processFileMoves(moves, options, config) {
|
|
@@ -736,8 +736,8 @@ async function _getOrphanedFiles(branchId, fileIds, options = {}, config) {
|
|
|
736
736
|
* @internal
|
|
737
737
|
* Publishes or unpublishes files on the CDN.
|
|
738
738
|
* @param files - Array of file entries with publish flags
|
|
739
|
-
* @param config - The configuration for the API call
|
|
740
|
-
* @returns The result of the API call
|
|
739
|
+
* @param config - The configuration for the API call.
|
|
740
|
+
* @returns The result of the API call.
|
|
741
741
|
*/
|
|
742
742
|
async function _publishFiles(files, config) {
|
|
743
743
|
return await apiRequest(config, "/v2/project/files/publish", { body: { files } });
|
|
@@ -843,7 +843,7 @@ var GT = class {
|
|
|
843
843
|
* Queries branch information from the API.
|
|
844
844
|
*
|
|
845
845
|
* @param {BranchQuery} query - Object mapping the current branch and incoming branches
|
|
846
|
-
* @returns {Promise<BranchDataResult>} The branch information
|
|
846
|
+
* @returns {Promise<BranchDataResult>} The branch information.
|
|
847
847
|
*/
|
|
848
848
|
async queryBranchData(query) {
|
|
849
849
|
this._validateAuth("queryBranchData");
|
|
@@ -853,7 +853,7 @@ var GT = class {
|
|
|
853
853
|
* Creates a new branch in the API. If the branch already exists, it will be returned.
|
|
854
854
|
*
|
|
855
855
|
* @param {CreateBranchQuery} query - Object mapping the branch name and default branch flag
|
|
856
|
-
* @returns {Promise<CreateBranchResult>} The created branch information
|
|
856
|
+
* @returns {Promise<CreateBranchResult>} The created branch information.
|
|
857
857
|
*/
|
|
858
858
|
async createBranch(query) {
|
|
859
859
|
this._validateAuth("createBranch");
|
|
@@ -865,7 +865,7 @@ var GT = class {
|
|
|
865
865
|
*
|
|
866
866
|
* @param {MoveMapping[]} moves - Array of move mappings (old fileId to new fileId)
|
|
867
867
|
* @param {ProcessMovesOptions} options - Options including branchId and timeout
|
|
868
|
-
* @returns {Promise<ProcessMovesResponse>} The move processing results
|
|
868
|
+
* @returns {Promise<ProcessMovesResponse>} The move processing results.
|
|
869
869
|
*
|
|
870
870
|
* @example
|
|
871
871
|
* const result = await gt.processFileMoves([
|
|
@@ -881,10 +881,10 @@ var GT = class {
|
|
|
881
881
|
* but whose fileIds are not in the provided list.
|
|
882
882
|
* Used for move detection.
|
|
883
883
|
*
|
|
884
|
-
* @param {string} branchId - The branch to check for orphaned files
|
|
884
|
+
* @param {string} branchId - The branch to check for orphaned files.
|
|
885
885
|
* @param {string[]} fileIds - List of current file IDs (files that are NOT orphaned)
|
|
886
|
-
* @param {Object} options - Options including timeout
|
|
887
|
-
* @returns {Promise<GetOrphanedFilesResult>} The orphaned files
|
|
886
|
+
* @param {Object} options - Options including timeout.
|
|
887
|
+
* @returns {Promise<GetOrphanedFilesResult>} The orphaned files.
|
|
888
888
|
*
|
|
889
889
|
* @example
|
|
890
890
|
* const result = await gt.getOrphanedFiles('branch-id', ['file-1', 'file-2']);
|
|
@@ -902,7 +902,7 @@ var GT = class {
|
|
|
902
902
|
* for processing and will generate a project setup based on the source files.
|
|
903
903
|
*
|
|
904
904
|
* @param {FileReference[]} files - Array of file references containing IDs of previously uploaded source files
|
|
905
|
-
* @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout
|
|
905
|
+
* @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout.
|
|
906
906
|
* @returns {Promise<SetupProjectResult>} Object containing the jobId and status
|
|
907
907
|
*/
|
|
908
908
|
async setupProject(files, options) {
|
|
@@ -919,9 +919,9 @@ var GT = class {
|
|
|
919
919
|
* This method polls the API to determine whether one or more jobs are still running,
|
|
920
920
|
* have completed successfully, or have failed. Jobs are created after calling either enqueueFiles or setupProject.
|
|
921
921
|
*
|
|
922
|
-
* @param {string[]} jobIds - The unique identifiers of the jobs to check
|
|
923
|
-
* @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request
|
|
924
|
-
* @returns {Promise<CheckJobStatusResult>} Object containing the job status
|
|
922
|
+
* @param {string[]} jobIds - The unique identifiers of the jobs to check.
|
|
923
|
+
* @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request.
|
|
924
|
+
* @returns {Promise<CheckJobStatusResult>} Object containing the job status.
|
|
925
925
|
*
|
|
926
926
|
* @example
|
|
927
927
|
* const result = await gt.checkJobStatus([
|
|
@@ -938,9 +938,9 @@ var GT = class {
|
|
|
938
938
|
/**
|
|
939
939
|
* Polls job statuses until all jobs from enqueueFiles are finished or the timeout is reached.
|
|
940
940
|
*
|
|
941
|
-
* @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles
|
|
942
|
-
* @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout)
|
|
943
|
-
* @returns {Promise<AwaitJobsResult>} The final status of all jobs and whether they all completed
|
|
941
|
+
* @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles.
|
|
942
|
+
* @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout).
|
|
943
|
+
* @returns {Promise<AwaitJobsResult>} The final status of all jobs and whether they all completed.
|
|
944
944
|
*/
|
|
945
945
|
async awaitJobs(enqueueResult, options) {
|
|
946
946
|
this._validateAuth("awaitJobs");
|
|
@@ -956,8 +956,8 @@ var GT = class {
|
|
|
956
956
|
* generate translated content based on the source files and target locales provided.
|
|
957
957
|
*
|
|
958
958
|
* @param {FileReferenceIds[]} files - Array of file references containing IDs of previously uploaded source files
|
|
959
|
-
* @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings
|
|
960
|
-
* @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information
|
|
959
|
+
* @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings.
|
|
960
|
+
* @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information.
|
|
961
961
|
*/
|
|
962
962
|
async enqueueFiles(files, options) {
|
|
963
963
|
this._validateAuth("enqueueFiles");
|
|
@@ -987,7 +987,7 @@ var GT = class {
|
|
|
987
987
|
* with a user-defined tag ID and optional message.
|
|
988
988
|
*
|
|
989
989
|
* @param {CreateTagOptions} options - Tag creation options including tagId, sourceFileIds, and optional message
|
|
990
|
-
* @returns {Promise<CreateTagResult>} The created or updated tag
|
|
990
|
+
* @returns {Promise<CreateTagResult>} The created or updated tag.
|
|
991
991
|
*/
|
|
992
992
|
async createTag(options) {
|
|
993
993
|
this._validateAuth("createTag");
|
|
@@ -1224,8 +1224,8 @@ var GT = class {
|
|
|
1224
1224
|
* translations through the translation workflow.
|
|
1225
1225
|
*
|
|
1226
1226
|
* @param {Array<{source: FileUpload}>} files - Array of objects containing source file data to upload
|
|
1227
|
-
* @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings
|
|
1228
|
-
* @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status
|
|
1227
|
+
* @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings.
|
|
1228
|
+
* @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status.
|
|
1229
1229
|
*/
|
|
1230
1230
|
async uploadSourceFiles(files, options) {
|
|
1231
1231
|
this._validateAuth("uploadSourceFiles");
|
|
@@ -1256,10 +1256,10 @@ var GT = class {
|
|
|
1256
1256
|
* that you want to upload directly rather than generating them through the translation service.
|
|
1257
1257
|
*
|
|
1258
1258
|
* @param {Array<{source: FileUpload, translations: FileUpload[]}>} files - Array of file objects where:
|
|
1259
|
-
* - `source`: Reference to the existing source file (contains IDs but no content)
|
|
1259
|
+
* - `source`: Reference to the existing source file (contains IDs but no content).
|
|
1260
1260
|
* - `translations`: Array of translated files, each containing content, locale, and reference IDs
|
|
1261
|
-
* @param {UploadFilesOptions} options - Configuration options including source locale and upload settings
|
|
1262
|
-
* @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information
|
|
1261
|
+
* @param {UploadFilesOptions} options - Configuration options including source locale and upload settings.
|
|
1262
|
+
* @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information.
|
|
1263
1263
|
*/
|
|
1264
1264
|
async uploadTranslations(files, options) {
|
|
1265
1265
|
this._validateAuth("uploadTranslations");
|
|
@@ -1339,11 +1339,11 @@ var GT = class {
|
|
|
1339
1339
|
/**
|
|
1340
1340
|
* Formats a number according to the specified locales and options.
|
|
1341
1341
|
*
|
|
1342
|
-
* @param {number} number - The number to format
|
|
1343
|
-
* @param {Object} [options] - Additional options for number formatting
|
|
1344
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1345
|
-
* @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options
|
|
1346
|
-
* @returns {string} The formatted number
|
|
1342
|
+
* @param {number} number - The number to format.
|
|
1343
|
+
* @param {Object} [options] - Additional options for number formatting.
|
|
1344
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1345
|
+
* @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options.
|
|
1346
|
+
* @returns {string} The formatted number.
|
|
1347
1347
|
*
|
|
1348
1348
|
* @example
|
|
1349
1349
|
* gt.formatNum(1234.56, { style: 'currency', currency: 'USD' });
|
|
@@ -1355,11 +1355,11 @@ var GT = class {
|
|
|
1355
1355
|
/**
|
|
1356
1356
|
* Formats a date according to the specified locales and options.
|
|
1357
1357
|
*
|
|
1358
|
-
* @param {Date} date - The date to format
|
|
1359
|
-
* @param {Object} [options] - Additional options for date formatting
|
|
1360
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1361
|
-
* @param {Intl.DateTimeFormatOptions} [options] - Additional Intl.DateTimeFormat options
|
|
1362
|
-
* @returns {string} The formatted date
|
|
1358
|
+
* @param {Date} date - The date to format.
|
|
1359
|
+
* @param {Object} [options] - Additional options for date formatting.
|
|
1360
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1361
|
+
* @param {Intl.DateTimeFormatOptions} [options] - Additional Intl.DateTimeFormat options.
|
|
1362
|
+
* @returns {string} The formatted date.
|
|
1363
1363
|
*
|
|
1364
1364
|
* @example
|
|
1365
1365
|
* gt.formatDateTime(new Date(), { dateStyle: 'full', timeStyle: 'long' });
|
|
@@ -1371,12 +1371,12 @@ var GT = class {
|
|
|
1371
1371
|
/**
|
|
1372
1372
|
* Formats a currency value according to the specified locales and options.
|
|
1373
1373
|
*
|
|
1374
|
-
* @param {number} value - The currency value to format
|
|
1374
|
+
* @param {number} value - The currency value to format.
|
|
1375
1375
|
* @param {string} currency - The currency code (e.g., 'USD', 'EUR')
|
|
1376
|
-
* @param {Object} [options] - Additional options for currency formatting
|
|
1377
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1378
|
-
* @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options
|
|
1379
|
-
* @returns {string} The formatted currency value
|
|
1376
|
+
* @param {Object} [options] - Additional options for currency formatting.
|
|
1377
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1378
|
+
* @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options.
|
|
1379
|
+
* @returns {string} The formatted currency value.
|
|
1380
1380
|
*
|
|
1381
1381
|
* @example
|
|
1382
1382
|
* gt.formatCurrency(1234.56, 'USD', { style: 'currency' });
|
|
@@ -1388,11 +1388,11 @@ var GT = class {
|
|
|
1388
1388
|
/**
|
|
1389
1389
|
* Formats a list of items according to the specified locales and options.
|
|
1390
1390
|
*
|
|
1391
|
-
* @param {Array<string | number>} array - The list of items to format
|
|
1392
|
-
* @param {Object} [options] - Additional options for list formatting
|
|
1393
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1394
|
-
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
|
|
1395
|
-
* @returns {string} The formatted list
|
|
1391
|
+
* @param {Array<string | number>} array - The list of items to format.
|
|
1392
|
+
* @param {Object} [options] - Additional options for list formatting.
|
|
1393
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1394
|
+
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
|
|
1395
|
+
* @returns {string} The formatted list.
|
|
1396
1396
|
*
|
|
1397
1397
|
* @example
|
|
1398
1398
|
* gt.formatList(['apple', 'banana', 'orange'], { type: 'conjunction' });
|
|
@@ -1403,11 +1403,11 @@ var GT = class {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
/**
|
|
1405
1405
|
* Formats a list of items according to the specified locales and options.
|
|
1406
|
-
* @param {Array<T>} array - The list of items to format
|
|
1407
|
-
* @param {Object} [options] - Additional options for list formatting
|
|
1408
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1409
|
-
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
|
|
1410
|
-
* @returns {Array<T | string>} The formatted list parts
|
|
1406
|
+
* @param {Array<T>} array - The list of items to format.
|
|
1407
|
+
* @param {Object} [options] - Additional options for list formatting.
|
|
1408
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1409
|
+
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
|
|
1410
|
+
* @returns {Array<T | string>} The formatted list parts.
|
|
1411
1411
|
*
|
|
1412
1412
|
* @example
|
|
1413
1413
|
* gt.formatListToParts(['apple', 42, { foo: 'bar' }], { type: 'conjunction', style: 'short', locales: ['en'] });
|
|
@@ -1419,12 +1419,12 @@ var GT = class {
|
|
|
1419
1419
|
/**
|
|
1420
1420
|
* Formats a relative time value according to the specified locales and options.
|
|
1421
1421
|
*
|
|
1422
|
-
* @param {number} value - The relative time value to format
|
|
1422
|
+
* @param {number} value - The relative time value to format.
|
|
1423
1423
|
* @param {Intl.RelativeTimeFormatUnit} unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year')
|
|
1424
|
-
* @param {Object} options - Additional options for relative time formatting
|
|
1425
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1426
|
-
* @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options
|
|
1427
|
-
* @returns {string} The formatted relative time string
|
|
1424
|
+
* @param {Object} options - Additional options for relative time formatting.
|
|
1425
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1426
|
+
* @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options.
|
|
1427
|
+
* @returns {string} The formatted relative time string.
|
|
1428
1428
|
*
|
|
1429
1429
|
* @example
|
|
1430
1430
|
* gt.formatRelativeTime(-1, 'day', { locales: ['en-US'], numeric: 'auto' });
|
|
@@ -1436,9 +1436,9 @@ var GT = class {
|
|
|
1436
1436
|
/**
|
|
1437
1437
|
* Formats a relative time string from a Date, automatically selecting the best unit.
|
|
1438
1438
|
*
|
|
1439
|
-
* @param {Date} date - The date to format relative to now
|
|
1440
|
-
* @param {Object} [options] - Additional options for relative time formatting
|
|
1441
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1439
|
+
* @param {Date} date - The date to format relative to now.
|
|
1440
|
+
* @param {Object} [options] - Additional options for relative time formatting.
|
|
1441
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1442
1442
|
* @returns {string} The formatted relative time string (e.g., "2 hours ago", "in 3 days")
|
|
1443
1443
|
*
|
|
1444
1444
|
* @example
|
|
@@ -1451,9 +1451,9 @@ var GT = class {
|
|
|
1451
1451
|
/**
|
|
1452
1452
|
* Retrieves the display name of a locale code using Intl.DisplayNames, returning an empty string if no name is found.
|
|
1453
1453
|
*
|
|
1454
|
-
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code
|
|
1455
|
-
* @returns {string} The display name corresponding to the code
|
|
1456
|
-
* @throws {Error} If no target locale is provided
|
|
1454
|
+
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code.
|
|
1455
|
+
* @returns {string} The display name corresponding to the code.
|
|
1456
|
+
* @throws {Error} If no target locale is provided.
|
|
1457
1457
|
*
|
|
1458
1458
|
* @example
|
|
1459
1459
|
* gt.getLocaleName('es-ES');
|
|
@@ -1468,8 +1468,8 @@ var GT = class {
|
|
|
1468
1468
|
* Uses the locale's region (if present) to select an emoji or falls back on default emojis.
|
|
1469
1469
|
*
|
|
1470
1470
|
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code (e.g., 'en-US', 'fr-CA')
|
|
1471
|
-
* @returns {string} The emoji representing the locale or its region
|
|
1472
|
-
* @throws {Error} If no target locale is provided
|
|
1471
|
+
* @returns {string} The emoji representing the locale or its region.
|
|
1472
|
+
* @throws {Error} If no target locale is provided.
|
|
1473
1473
|
*
|
|
1474
1474
|
* @example
|
|
1475
1475
|
* gt.getLocaleEmoji('es-ES');
|
|
@@ -1573,12 +1573,12 @@ var GT = class {
|
|
|
1573
1573
|
/**
|
|
1574
1574
|
* Determines whether a translation is required based on the source and target locales.
|
|
1575
1575
|
*
|
|
1576
|
-
* @param {string} [sourceLocale=this.sourceLocale] - The locale code for the original content
|
|
1577
|
-
* @param {string} [targetLocale=this.targetLocale] - The locale code to translate into
|
|
1578
|
-
* @param {string[]} [approvedLocales=this.locales] - Optional array of approved target locales
|
|
1576
|
+
* @param {string} [sourceLocale=this.sourceLocale] - The locale code for the original content.
|
|
1577
|
+
* @param {string} [targetLocale=this.targetLocale] - The locale code to translate into.
|
|
1578
|
+
* @param {string[]} [approvedLocales=this.locales] - Optional array of approved target locales.
|
|
1579
1579
|
* @returns {boolean} True if translation is required, false otherwise
|
|
1580
|
-
* @throws {Error} If no source locale is provided
|
|
1581
|
-
* @throws {Error} If no target locale is provided
|
|
1580
|
+
* @throws {Error} If no source locale is provided.
|
|
1581
|
+
* @throws {Error} If no target locale is provided.
|
|
1582
1582
|
*
|
|
1583
1583
|
* @example
|
|
1584
1584
|
* gt.requiresTranslation('en-US', 'es-ES');
|
|
@@ -1593,9 +1593,9 @@ var GT = class {
|
|
|
1593
1593
|
/**
|
|
1594
1594
|
* Determines the best matching locale from the provided approved locales list.
|
|
1595
1595
|
*
|
|
1596
|
-
* @param {string | string[]} locales - A single locale or array of locales in preference order
|
|
1597
|
-
* @param {string[]} [approvedLocales=this.locales] - Array of approved locales in preference order
|
|
1598
|
-
* @returns {string | undefined} The best matching locale or undefined if no match is found
|
|
1596
|
+
* @param {string | string[]} locales - A single locale or array of locales in preference order.
|
|
1597
|
+
* @param {string[]} [approvedLocales=this.locales] - Array of approved locales in preference order.
|
|
1598
|
+
* @returns {string | undefined} The best matching locale, or undefined if no match is found.
|
|
1599
1599
|
*
|
|
1600
1600
|
* @example
|
|
1601
1601
|
* gt.determineLocale(['fr-CA', 'fr-FR'], ['en-US', 'fr-FR', 'es-ES']);
|
|
@@ -1608,9 +1608,9 @@ var GT = class {
|
|
|
1608
1608
|
/**
|
|
1609
1609
|
* Gets the text direction for a given locale code.
|
|
1610
1610
|
*
|
|
1611
|
-
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code
|
|
1612
|
-
* @returns {'ltr' | 'rtl'} 'rtl' if the locale is right-to-left
|
|
1613
|
-
* @throws {Error} If no target locale is provided
|
|
1611
|
+
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code.
|
|
1612
|
+
* @returns {'ltr' | 'rtl'} 'rtl' if the locale is right-to-left; otherwise 'ltr'.
|
|
1613
|
+
* @throws {Error} If no target locale is provided.
|
|
1614
1614
|
*
|
|
1615
1615
|
* @example
|
|
1616
1616
|
* gt.getLocaleDirection('ar-SA');
|
|
@@ -1623,10 +1623,10 @@ var GT = class {
|
|
|
1623
1623
|
/**
|
|
1624
1624
|
* Checks if a given BCP 47 locale code is valid.
|
|
1625
1625
|
*
|
|
1626
|
-
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate
|
|
1627
|
-
* @param {
|
|
1626
|
+
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate.
|
|
1627
|
+
* @param {CustomMapping} [customMapping=this.customMapping] - The custom mapping to use for validation.
|
|
1628
1628
|
* @returns {boolean} True if the locale code is valid, false otherwise
|
|
1629
|
-
* @throws {Error} If no target locale is provided
|
|
1629
|
+
* @throws {Error} If no target locale is provided.
|
|
1630
1630
|
*
|
|
1631
1631
|
* @example
|
|
1632
1632
|
* gt.isValidLocale('en-US');
|
|
@@ -1641,7 +1641,7 @@ var GT = class {
|
|
|
1641
1641
|
* Resolves the canonical locale for a given locale.
|
|
1642
1642
|
* @param locale - The locale to resolve the canonical locale for
|
|
1643
1643
|
* @param customMapping - The custom mapping to use for resolving the canonical locale
|
|
1644
|
-
* @returns The canonical locale
|
|
1644
|
+
* @returns The canonical locale, or the input locale when no canonical mapping exists.
|
|
1645
1645
|
*/
|
|
1646
1646
|
resolveCanonicalLocale(locale = this.targetLocale, customMapping = this.customMapping) {
|
|
1647
1647
|
if (!locale) throw new Error(noTargetLocaleProvidedError("resolveCanonicalLocale"));
|
|
@@ -1652,7 +1652,7 @@ var GT = class {
|
|
|
1652
1652
|
* Resolves the alias locale for a given locale.
|
|
1653
1653
|
* @param locale - The locale to resolve the alias locale for
|
|
1654
1654
|
* @param customMapping - The custom mapping to use for resolving the alias locale
|
|
1655
|
-
* @returns The alias locale
|
|
1655
|
+
* @returns The configured alias for a canonical locale, or the input locale when already an alias or no alias mapping exists.
|
|
1656
1656
|
*/
|
|
1657
1657
|
resolveAliasLocale(locale, customMapping = this.customMapping) {
|
|
1658
1658
|
if (!locale) throw new Error(noTargetLocaleProvidedError("resolveAliasLocale"));
|
|
@@ -1662,9 +1662,9 @@ var GT = class {
|
|
|
1662
1662
|
/**
|
|
1663
1663
|
* Standardizes a BCP 47 locale code to ensure correct formatting.
|
|
1664
1664
|
*
|
|
1665
|
-
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to standardize
|
|
1666
|
-
* @returns {string} The standardized locale code or
|
|
1667
|
-
* @throws {Error} If no target locale is provided
|
|
1665
|
+
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to standardize.
|
|
1666
|
+
* @returns {string} The standardized locale code, or the input string if it cannot be standardized.
|
|
1667
|
+
* @throws {Error} If no target locale is provided.
|
|
1668
1668
|
*
|
|
1669
1669
|
* @example
|
|
1670
1670
|
* gt.standardizeLocale('en_us');
|
|
@@ -1677,7 +1677,7 @@ var GT = class {
|
|
|
1677
1677
|
/**
|
|
1678
1678
|
* Checks if multiple BCP 47 locale codes represent the same dialect.
|
|
1679
1679
|
*
|
|
1680
|
-
* @param {...(string | string[])} locales - The BCP 47 locale codes to compare
|
|
1680
|
+
* @param {...(string | string[])} locales - The BCP 47 locale codes to compare.
|
|
1681
1681
|
* @returns {boolean} True if all codes represent the same dialect, false otherwise
|
|
1682
1682
|
*
|
|
1683
1683
|
* @example
|
|
@@ -1693,7 +1693,7 @@ var GT = class {
|
|
|
1693
1693
|
/**
|
|
1694
1694
|
* Checks if multiple BCP 47 locale codes represent the same language.
|
|
1695
1695
|
*
|
|
1696
|
-
* @param {...(string | string[])} locales - The BCP 47 locale codes to compare
|
|
1696
|
+
* @param {...(string | string[])} locales - The BCP 47 locale codes to compare.
|
|
1697
1697
|
* @returns {boolean} True if all codes represent the same language, false otherwise
|
|
1698
1698
|
*
|
|
1699
1699
|
* @example
|
|
@@ -1785,11 +1785,11 @@ function formatList(array, options) {
|
|
|
1785
1785
|
}
|
|
1786
1786
|
/**
|
|
1787
1787
|
* Formats a list of items according to the specified locales and options.
|
|
1788
|
-
* @param {Array<T>} array - The list of items to format
|
|
1789
|
-
* @param {Object} [options] - Additional options for list formatting
|
|
1790
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1791
|
-
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
|
|
1792
|
-
* @returns {Array<T | string>} The formatted list parts
|
|
1788
|
+
* @param {Array<T>} array - The list of items to format.
|
|
1789
|
+
* @param {Object} [options] - Additional options for list formatting.
|
|
1790
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1791
|
+
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
|
|
1792
|
+
* @returns {Array<T | string>} The formatted list parts.
|
|
1793
1793
|
*/
|
|
1794
1794
|
function formatListToParts(array, options) {
|
|
1795
1795
|
return require_core._formatListToParts({
|
|
@@ -1959,7 +1959,7 @@ function determineLocale(locales, approvedLocales = [], customMapping = void 0)
|
|
|
1959
1959
|
* Get the text direction for a given locale code using the Intl.Locale API.
|
|
1960
1960
|
*
|
|
1961
1961
|
* @param {string} locale - A BCP-47 locale code.
|
|
1962
|
-
* @returns {string}
|
|
1962
|
+
* @returns {string} 'rtl' if the locale is right-to-left; otherwise 'ltr'.
|
|
1963
1963
|
*/
|
|
1964
1964
|
function getLocaleDirection(locale) {
|
|
1965
1965
|
return require_core._getLocaleDirection(locale);
|