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.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as defaultTimeout, t as intlCache } from "./IntlCache-
|
|
2
|
-
import { A as _standardizeLocale, C as _getLocaleEmoji, D as _isSameLanguage, E as _requiresTranslation, O as _isSameDialect, S as _getLocaleProperties, T as getRegionEmoji, _ as _formatRelativeTime, a as standardizeLocale, b as gtInstanceLogger, c as _resolveAliasLocale, d as _getLocaleName, f as _formatCurrency, g as _formatNum, h as _formatListToParts, i as resolveCanonicalLocale, k as _isValidLocale, l as _isSupersetLocale, m as _formatList, n as formatMessage, o as LocaleConfig, p as _formatDateTime, r as isValidLocale, s as _resolveCanonicalLocale, t as formatCutoff, u as _getLocaleDirection, v as _formatRelativeTimeFromDate, w as defaultEmoji, x as _determineLocale, y as fetchLogger } from "./core-
|
|
3
|
-
import { n as encode, r as validateFileFormatTransforms, t as decode } from "./base64-
|
|
1
|
+
import { n as defaultTimeout, t as intlCache } from "./IntlCache-WZk0rKvj.mjs";
|
|
2
|
+
import { A as _standardizeLocale, C as _getLocaleEmoji, D as _isSameLanguage, E as _requiresTranslation, O as _isSameDialect, S as _getLocaleProperties, T as getRegionEmoji, _ as _formatRelativeTime, a as standardizeLocale, b as gtInstanceLogger, c as _resolveAliasLocale, d as _getLocaleName, f as _formatCurrency, g as _formatNum, h as _formatListToParts, i as resolveCanonicalLocale, k as _isValidLocale, l as _isSupersetLocale, m as _formatList, n as formatMessage, o as LocaleConfig, p as _formatDateTime, r as isValidLocale, s as _resolveCanonicalLocale, t as formatCutoff, u as _getLocaleDirection, v as _formatRelativeTimeFromDate, w as defaultEmoji, x as _determineLocale, y as fetchLogger } from "./core-isLphYAZ.mjs";
|
|
3
|
+
import { n as encode, r as validateFileFormatTransforms, t as decode } from "./base64-DH0STixb.mjs";
|
|
4
4
|
import { t as ApiError } from "./ApiError-IYfaOR30.mjs";
|
|
5
|
-
import { n as hashSource } from "./id-
|
|
5
|
+
import { n as hashSource } from "./id-DbD7K-HL.mjs";
|
|
6
6
|
//#region src/logging/errors.ts
|
|
7
7
|
const GT_ERROR_PREFIX = "GT Error:";
|
|
8
8
|
const translationTimeoutError = (timeout) => `${GT_ERROR_PREFIX} Translation request timed out after ${timeout}ms.`;
|
|
@@ -109,10 +109,10 @@ function getRetryDelay(policy, attempt) {
|
|
|
109
109
|
* Encapsulates URL construction, fetch with timeout, error handling,
|
|
110
110
|
* response validation, and JSON parsing.
|
|
111
111
|
*
|
|
112
|
-
* @param config - The configuration for the API call
|
|
112
|
+
* @param config - The configuration for the API call.
|
|
113
113
|
* @param endpoint - The API endpoint path (e.g. '/v2/project/jobs/info')
|
|
114
|
-
* @param options - Optional request options
|
|
115
|
-
* @returns The parsed JSON response
|
|
114
|
+
* @param options - Optional request options.
|
|
115
|
+
* @returns The parsed JSON response.
|
|
116
116
|
*/
|
|
117
117
|
async function apiRequest(config, endpoint, options) {
|
|
118
118
|
const timeout = options?.timeout ?? 6e4;
|
|
@@ -157,7 +157,7 @@ async function _translateMany(requests, globalMetadata, config, timeout) {
|
|
|
157
157
|
const hash = key ?? metadata?.hash ?? hashSource({
|
|
158
158
|
source,
|
|
159
159
|
dataFormat: metadata?.dataFormat ?? "STRING",
|
|
160
|
-
...metadata
|
|
160
|
+
...metadata
|
|
161
161
|
});
|
|
162
162
|
hashOrder?.push(hash);
|
|
163
163
|
requestsObject[hash] = {
|
|
@@ -191,9 +191,9 @@ async function _translateMany(requests, globalMetadata, config, timeout) {
|
|
|
191
191
|
* @internal
|
|
192
192
|
* Enqueues files for project setup the General Translation API.
|
|
193
193
|
* @param files - References of files to translate (file content already uploaded)
|
|
194
|
-
* @param config - The configuration for the API call
|
|
194
|
+
* @param config - The configuration for the API call.
|
|
195
195
|
* @param timeoutMS - The timeout in milliseconds
|
|
196
|
-
* @returns The result of the API call
|
|
196
|
+
* @returns The result of the API call.
|
|
197
197
|
*/
|
|
198
198
|
async function _setupProject(files, config, options) {
|
|
199
199
|
return apiRequest(config, "/v2/project/setup/generate", {
|
|
@@ -213,9 +213,9 @@ async function _setupProject(files, config, options) {
|
|
|
213
213
|
//#region src/translate/utils/batch.ts
|
|
214
214
|
/**
|
|
215
215
|
* Splits an array into batches of a specified size.
|
|
216
|
-
* @param items - The array to split into batches
|
|
217
|
-
* @param batchSize - The maximum size of each batch
|
|
218
|
-
* @returns An array of batches
|
|
216
|
+
* @param items - The array to split into batches.
|
|
217
|
+
* @param batchSize - The maximum size of each batch.
|
|
218
|
+
* @returns An array of batches.
|
|
219
219
|
*/
|
|
220
220
|
function createBatches(items, batchSize) {
|
|
221
221
|
const batches = [];
|
|
@@ -225,10 +225,10 @@ function createBatches(items, batchSize) {
|
|
|
225
225
|
/**
|
|
226
226
|
* Processes items in batches using a provided processor function.
|
|
227
227
|
*
|
|
228
|
-
* @param items - The items to process
|
|
229
|
-
* @param processor - Async function that processes a single batch and returns items
|
|
230
|
-
* @param options - Optional configuration for batch processing
|
|
231
|
-
* @returns Promise that resolves to a BatchList containing all processed items
|
|
228
|
+
* @param items - The items to process.
|
|
229
|
+
* @param processor - Async function that processes a single batch and returns items.
|
|
230
|
+
* @param options - Optional configuration for batch processing.
|
|
231
|
+
* @returns Promise that resolves to a BatchList containing all processed items.
|
|
232
232
|
*
|
|
233
233
|
* @example
|
|
234
234
|
* ```typescript
|
|
@@ -274,9 +274,9 @@ async function processBatches(items, processor, options = {}) {
|
|
|
274
274
|
* @internal
|
|
275
275
|
* Enqueues files for translation in the General Translation API.
|
|
276
276
|
* @param files - References of files to translate (file content already uploaded)
|
|
277
|
-
* @param options - The options for the API call
|
|
278
|
-
* @param config - The configuration for the API call
|
|
279
|
-
* @returns The result of the API call
|
|
277
|
+
* @param options - The options for the API call.
|
|
278
|
+
* @param config - The configuration for the API call.
|
|
279
|
+
* @returns The result of the API call.
|
|
280
280
|
*/
|
|
281
281
|
async function _enqueueFiles(files, options, config) {
|
|
282
282
|
validateFileFormatTransforms(files);
|
|
@@ -311,9 +311,9 @@ async function _enqueueFiles(files, options, config) {
|
|
|
311
311
|
/**
|
|
312
312
|
* @internal
|
|
313
313
|
* Creates or upserts a file tag in the General Translation API.
|
|
314
|
-
* @param options - The tag creation options
|
|
315
|
-
* @param config - The configuration for the API call
|
|
316
|
-
* @returns The created or updated tag
|
|
314
|
+
* @param options - The tag creation options.
|
|
315
|
+
* @param config - The configuration for the API call.
|
|
316
|
+
* @returns The created or updated tag.
|
|
317
317
|
*/
|
|
318
318
|
async function _createTag(options, config) {
|
|
319
319
|
return await apiRequest(config, "/v2/project/tags/create", { body: {
|
|
@@ -328,8 +328,8 @@ async function _createTag(options, config) {
|
|
|
328
328
|
* @internal
|
|
329
329
|
* Downloads multiple translation files in batches.
|
|
330
330
|
* @param files - Array of files to download
|
|
331
|
-
* @param options - The options for the API call
|
|
332
|
-
* @param config - The configuration for the request
|
|
331
|
+
* @param options - The options for the API call.
|
|
332
|
+
* @param config - The configuration for the request.
|
|
333
333
|
* @returns Promise resolving to a BatchList with all downloaded files
|
|
334
334
|
*/
|
|
335
335
|
async function _downloadFileBatch(requests, options, config) {
|
|
@@ -419,9 +419,9 @@ function _getRegionProperties(region, defaultLocale = "en", customMapping) {
|
|
|
419
419
|
/**
|
|
420
420
|
* @internal
|
|
421
421
|
* Uploads source files to the General Translation API in batches.
|
|
422
|
-
* @param files - The files to upload
|
|
423
|
-
* @param options - The options for the API call
|
|
424
|
-
* @param config - The configuration for the API call
|
|
422
|
+
* @param files - The files to upload.
|
|
423
|
+
* @param options - The options for the API call.
|
|
424
|
+
* @param config - The configuration for the API call.
|
|
425
425
|
* @returns Promise resolving to a BatchList with all uploaded files
|
|
426
426
|
*/
|
|
427
427
|
async function _uploadSourceFiles(files, options, config) {
|
|
@@ -453,8 +453,8 @@ async function _uploadSourceFiles(files, options, config) {
|
|
|
453
453
|
* @internal
|
|
454
454
|
* Uploads multiple translations to the General Translation API in batches.
|
|
455
455
|
* @param files - Translations to upload with their source
|
|
456
|
-
* @param options - The options for the API call
|
|
457
|
-
* @param config - The configuration for the API call
|
|
456
|
+
* @param options - The options for the API call.
|
|
457
|
+
* @param config - The configuration for the API call.
|
|
458
458
|
* @returns Promise resolving to a BatchList with all uploaded files
|
|
459
459
|
*/
|
|
460
460
|
async function _uploadTranslations(files, options, config) {
|
|
@@ -498,8 +498,8 @@ async function _uploadTranslations(files, options, config) {
|
|
|
498
498
|
* @internal
|
|
499
499
|
* Gets the source file and translation information for a given file ID and version ID.
|
|
500
500
|
* @param query - The file ID and version ID to get the source file and translation information for
|
|
501
|
-
* @param options - The options for the API call
|
|
502
|
-
* @param config - The configuration for the request
|
|
501
|
+
* @param options - The options for the API call.
|
|
502
|
+
* @param config - The configuration for the request.
|
|
503
503
|
* @returns The source file and translation information for the given file ID and version ID
|
|
504
504
|
*/
|
|
505
505
|
async function _querySourceFile(query, options, config) {
|
|
@@ -520,9 +520,9 @@ async function _querySourceFile(query, options, config) {
|
|
|
520
520
|
* @internal
|
|
521
521
|
* Gets the project data for a given project ID.
|
|
522
522
|
* @param projectId - The project ID to get the project data for
|
|
523
|
-
* @param options - The options for the API call
|
|
524
|
-
* @param config - The configuration for the request
|
|
525
|
-
* @returns The project data for the given project ID
|
|
523
|
+
* @param options - The options for the API call.
|
|
524
|
+
* @param config - The configuration for the request.
|
|
525
|
+
* @returns The project data for the given project ID.
|
|
526
526
|
*/
|
|
527
527
|
async function _getProjectData(projectId, options, config) {
|
|
528
528
|
const { baseUrl } = config;
|
|
@@ -544,11 +544,11 @@ async function _getProjectData(projectId, options, config) {
|
|
|
544
544
|
//#region src/translate/checkJobStatus.ts
|
|
545
545
|
/**
|
|
546
546
|
* @internal
|
|
547
|
-
* Queries job statuses for a project
|
|
548
|
-
* @param jobIds - Job IDs
|
|
549
|
-
* @param config - The configuration for the API call
|
|
550
|
-
* @param
|
|
551
|
-
* @returns The result of the API call
|
|
547
|
+
* Queries job statuses for a project.
|
|
548
|
+
* @param jobIds - Job IDs.
|
|
549
|
+
* @param config - The configuration for the API call.
|
|
550
|
+
* @param timeoutMs - The timeout in milliseconds.
|
|
551
|
+
* @returns The result of the API call.
|
|
552
552
|
*/
|
|
553
553
|
async function _checkJobStatus(jobIds, config, timeoutMs) {
|
|
554
554
|
return apiRequest(config, "/v2/project/jobs/info", {
|
|
@@ -561,10 +561,10 @@ async function _checkJobStatus(jobIds, config, timeoutMs) {
|
|
|
561
561
|
/**
|
|
562
562
|
* @internal
|
|
563
563
|
* Polls job statuses until all jobs are finished or the timeout is reached.
|
|
564
|
-
* @param enqueueResult - The result from enqueueFiles
|
|
565
|
-
* @param options - Polling configuration
|
|
566
|
-
* @param config - API credentials and configuration
|
|
567
|
-
* @returns The final status of all jobs
|
|
564
|
+
* @param enqueueResult - The result from enqueueFiles.
|
|
565
|
+
* @param options - Polling configuration.
|
|
566
|
+
* @param config - API credentials and configuration.
|
|
567
|
+
* @returns The final status of all jobs.
|
|
568
568
|
*/
|
|
569
569
|
async function _awaitJobs(enqueueResult, options, config) {
|
|
570
570
|
const pollingInterval = (options?.pollingIntervalSeconds ?? 5) * 1e3;
|
|
@@ -608,9 +608,9 @@ async function _awaitJobs(enqueueResult, options, config) {
|
|
|
608
608
|
* @internal
|
|
609
609
|
* Queries data about one or more source or translation files.
|
|
610
610
|
* @param data - Object mapping source or translation file information
|
|
611
|
-
* @param options - The options for the API call
|
|
612
|
-
* @param config - The configuration for the API call
|
|
613
|
-
* @returns The file data
|
|
611
|
+
* @param options - The options for the API call.
|
|
612
|
+
* @param config - The configuration for the API call.
|
|
613
|
+
* @returns The file data.
|
|
614
614
|
*/
|
|
615
615
|
async function _queryFileData(data, options = {}, config) {
|
|
616
616
|
return apiRequest(config, "/v2/project/files/info", {
|
|
@@ -636,8 +636,8 @@ async function _queryFileData(data, options = {}, config) {
|
|
|
636
636
|
* @internal
|
|
637
637
|
* Queries branch information from the API.
|
|
638
638
|
* @param query - Object mapping the current branch and incoming branches
|
|
639
|
-
* @param config - The configuration for the API call
|
|
640
|
-
* @returns The branch information
|
|
639
|
+
* @param config - The configuration for the API call.
|
|
640
|
+
* @returns The branch information.
|
|
641
641
|
*/
|
|
642
642
|
async function _queryBranchData(query, config) {
|
|
643
643
|
return apiRequest(config, "/v2/project/branches/info", { body: query });
|
|
@@ -648,8 +648,8 @@ async function _queryBranchData(query, config) {
|
|
|
648
648
|
* @internal
|
|
649
649
|
* Creates a new branch in the API.
|
|
650
650
|
* @param query - Object mapping the branch name and default branch flag
|
|
651
|
-
* @param config - The configuration for the API call
|
|
652
|
-
* @returns The created branch information
|
|
651
|
+
* @param config - The configuration for the API call.
|
|
652
|
+
* @returns The created branch information.
|
|
653
653
|
*/
|
|
654
654
|
async function _createBranch(query, config) {
|
|
655
655
|
return apiRequest(config, "/v2/project/branches/create", { body: query });
|
|
@@ -662,7 +662,7 @@ async function _createBranch(query, config) {
|
|
|
662
662
|
* Called when the CLI detects that files have been moved/renamed.
|
|
663
663
|
* @param moves - Array of move mappings (old fileId to new fileId)
|
|
664
664
|
* @param options - Options including branchId and timeout
|
|
665
|
-
* @param config - The configuration for the API call
|
|
665
|
+
* @param config - The configuration for the API call.
|
|
666
666
|
* @returns Promise resolving to the move results
|
|
667
667
|
*/
|
|
668
668
|
async function _processFileMoves(moves, options, config) {
|
|
@@ -735,8 +735,8 @@ async function _getOrphanedFiles(branchId, fileIds, options = {}, config) {
|
|
|
735
735
|
* @internal
|
|
736
736
|
* Publishes or unpublishes files on the CDN.
|
|
737
737
|
* @param files - Array of file entries with publish flags
|
|
738
|
-
* @param config - The configuration for the API call
|
|
739
|
-
* @returns The result of the API call
|
|
738
|
+
* @param config - The configuration for the API call.
|
|
739
|
+
* @returns The result of the API call.
|
|
740
740
|
*/
|
|
741
741
|
async function _publishFiles(files, config) {
|
|
742
742
|
return await apiRequest(config, "/v2/project/files/publish", { body: { files } });
|
|
@@ -842,7 +842,7 @@ var GT = class {
|
|
|
842
842
|
* Queries branch information from the API.
|
|
843
843
|
*
|
|
844
844
|
* @param {BranchQuery} query - Object mapping the current branch and incoming branches
|
|
845
|
-
* @returns {Promise<BranchDataResult>} The branch information
|
|
845
|
+
* @returns {Promise<BranchDataResult>} The branch information.
|
|
846
846
|
*/
|
|
847
847
|
async queryBranchData(query) {
|
|
848
848
|
this._validateAuth("queryBranchData");
|
|
@@ -852,7 +852,7 @@ var GT = class {
|
|
|
852
852
|
* Creates a new branch in the API. If the branch already exists, it will be returned.
|
|
853
853
|
*
|
|
854
854
|
* @param {CreateBranchQuery} query - Object mapping the branch name and default branch flag
|
|
855
|
-
* @returns {Promise<CreateBranchResult>} The created branch information
|
|
855
|
+
* @returns {Promise<CreateBranchResult>} The created branch information.
|
|
856
856
|
*/
|
|
857
857
|
async createBranch(query) {
|
|
858
858
|
this._validateAuth("createBranch");
|
|
@@ -864,7 +864,7 @@ var GT = class {
|
|
|
864
864
|
*
|
|
865
865
|
* @param {MoveMapping[]} moves - Array of move mappings (old fileId to new fileId)
|
|
866
866
|
* @param {ProcessMovesOptions} options - Options including branchId and timeout
|
|
867
|
-
* @returns {Promise<ProcessMovesResponse>} The move processing results
|
|
867
|
+
* @returns {Promise<ProcessMovesResponse>} The move processing results.
|
|
868
868
|
*
|
|
869
869
|
* @example
|
|
870
870
|
* const result = await gt.processFileMoves([
|
|
@@ -880,10 +880,10 @@ var GT = class {
|
|
|
880
880
|
* but whose fileIds are not in the provided list.
|
|
881
881
|
* Used for move detection.
|
|
882
882
|
*
|
|
883
|
-
* @param {string} branchId - The branch to check for orphaned files
|
|
883
|
+
* @param {string} branchId - The branch to check for orphaned files.
|
|
884
884
|
* @param {string[]} fileIds - List of current file IDs (files that are NOT orphaned)
|
|
885
|
-
* @param {Object} options - Options including timeout
|
|
886
|
-
* @returns {Promise<GetOrphanedFilesResult>} The orphaned files
|
|
885
|
+
* @param {Object} options - Options including timeout.
|
|
886
|
+
* @returns {Promise<GetOrphanedFilesResult>} The orphaned files.
|
|
887
887
|
*
|
|
888
888
|
* @example
|
|
889
889
|
* const result = await gt.getOrphanedFiles('branch-id', ['file-1', 'file-2']);
|
|
@@ -901,7 +901,7 @@ var GT = class {
|
|
|
901
901
|
* for processing and will generate a project setup based on the source files.
|
|
902
902
|
*
|
|
903
903
|
* @param {FileReference[]} files - Array of file references containing IDs of previously uploaded source files
|
|
904
|
-
* @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout
|
|
904
|
+
* @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout.
|
|
905
905
|
* @returns {Promise<SetupProjectResult>} Object containing the jobId and status
|
|
906
906
|
*/
|
|
907
907
|
async setupProject(files, options) {
|
|
@@ -918,9 +918,9 @@ var GT = class {
|
|
|
918
918
|
* This method polls the API to determine whether one or more jobs are still running,
|
|
919
919
|
* have completed successfully, or have failed. Jobs are created after calling either enqueueFiles or setupProject.
|
|
920
920
|
*
|
|
921
|
-
* @param {string[]} jobIds - The unique identifiers of the jobs to check
|
|
922
|
-
* @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request
|
|
923
|
-
* @returns {Promise<CheckJobStatusResult>} Object containing the job status
|
|
921
|
+
* @param {string[]} jobIds - The unique identifiers of the jobs to check.
|
|
922
|
+
* @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request.
|
|
923
|
+
* @returns {Promise<CheckJobStatusResult>} Object containing the job status.
|
|
924
924
|
*
|
|
925
925
|
* @example
|
|
926
926
|
* const result = await gt.checkJobStatus([
|
|
@@ -937,9 +937,9 @@ var GT = class {
|
|
|
937
937
|
/**
|
|
938
938
|
* Polls job statuses until all jobs from enqueueFiles are finished or the timeout is reached.
|
|
939
939
|
*
|
|
940
|
-
* @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles
|
|
941
|
-
* @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout)
|
|
942
|
-
* @returns {Promise<AwaitJobsResult>} The final status of all jobs and whether they all completed
|
|
940
|
+
* @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles.
|
|
941
|
+
* @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout).
|
|
942
|
+
* @returns {Promise<AwaitJobsResult>} The final status of all jobs and whether they all completed.
|
|
943
943
|
*/
|
|
944
944
|
async awaitJobs(enqueueResult, options) {
|
|
945
945
|
this._validateAuth("awaitJobs");
|
|
@@ -955,8 +955,8 @@ var GT = class {
|
|
|
955
955
|
* generate translated content based on the source files and target locales provided.
|
|
956
956
|
*
|
|
957
957
|
* @param {FileReferenceIds[]} files - Array of file references containing IDs of previously uploaded source files
|
|
958
|
-
* @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings
|
|
959
|
-
* @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information
|
|
958
|
+
* @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings.
|
|
959
|
+
* @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information.
|
|
960
960
|
*/
|
|
961
961
|
async enqueueFiles(files, options) {
|
|
962
962
|
this._validateAuth("enqueueFiles");
|
|
@@ -986,7 +986,7 @@ var GT = class {
|
|
|
986
986
|
* with a user-defined tag ID and optional message.
|
|
987
987
|
*
|
|
988
988
|
* @param {CreateTagOptions} options - Tag creation options including tagId, sourceFileIds, and optional message
|
|
989
|
-
* @returns {Promise<CreateTagResult>} The created or updated tag
|
|
989
|
+
* @returns {Promise<CreateTagResult>} The created or updated tag.
|
|
990
990
|
*/
|
|
991
991
|
async createTag(options) {
|
|
992
992
|
this._validateAuth("createTag");
|
|
@@ -1223,8 +1223,8 @@ var GT = class {
|
|
|
1223
1223
|
* translations through the translation workflow.
|
|
1224
1224
|
*
|
|
1225
1225
|
* @param {Array<{source: FileUpload}>} files - Array of objects containing source file data to upload
|
|
1226
|
-
* @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings
|
|
1227
|
-
* @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status
|
|
1226
|
+
* @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings.
|
|
1227
|
+
* @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status.
|
|
1228
1228
|
*/
|
|
1229
1229
|
async uploadSourceFiles(files, options) {
|
|
1230
1230
|
this._validateAuth("uploadSourceFiles");
|
|
@@ -1255,10 +1255,10 @@ var GT = class {
|
|
|
1255
1255
|
* that you want to upload directly rather than generating them through the translation service.
|
|
1256
1256
|
*
|
|
1257
1257
|
* @param {Array<{source: FileUpload, translations: FileUpload[]}>} files - Array of file objects where:
|
|
1258
|
-
* - `source`: Reference to the existing source file (contains IDs but no content)
|
|
1258
|
+
* - `source`: Reference to the existing source file (contains IDs but no content).
|
|
1259
1259
|
* - `translations`: Array of translated files, each containing content, locale, and reference IDs
|
|
1260
|
-
* @param {UploadFilesOptions} options - Configuration options including source locale and upload settings
|
|
1261
|
-
* @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information
|
|
1260
|
+
* @param {UploadFilesOptions} options - Configuration options including source locale and upload settings.
|
|
1261
|
+
* @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information.
|
|
1262
1262
|
*/
|
|
1263
1263
|
async uploadTranslations(files, options) {
|
|
1264
1264
|
this._validateAuth("uploadTranslations");
|
|
@@ -1338,11 +1338,11 @@ var GT = class {
|
|
|
1338
1338
|
/**
|
|
1339
1339
|
* Formats a number according to the specified locales and options.
|
|
1340
1340
|
*
|
|
1341
|
-
* @param {number} number - The number to format
|
|
1342
|
-
* @param {Object} [options] - Additional options for number formatting
|
|
1343
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1344
|
-
* @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options
|
|
1345
|
-
* @returns {string} The formatted number
|
|
1341
|
+
* @param {number} number - The number to format.
|
|
1342
|
+
* @param {Object} [options] - Additional options for number formatting.
|
|
1343
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1344
|
+
* @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options.
|
|
1345
|
+
* @returns {string} The formatted number.
|
|
1346
1346
|
*
|
|
1347
1347
|
* @example
|
|
1348
1348
|
* gt.formatNum(1234.56, { style: 'currency', currency: 'USD' });
|
|
@@ -1354,11 +1354,11 @@ var GT = class {
|
|
|
1354
1354
|
/**
|
|
1355
1355
|
* Formats a date according to the specified locales and options.
|
|
1356
1356
|
*
|
|
1357
|
-
* @param {Date} date - The date to format
|
|
1358
|
-
* @param {Object} [options] - Additional options for date formatting
|
|
1359
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1360
|
-
* @param {Intl.DateTimeFormatOptions} [options] - Additional Intl.DateTimeFormat options
|
|
1361
|
-
* @returns {string} The formatted date
|
|
1357
|
+
* @param {Date} date - The date to format.
|
|
1358
|
+
* @param {Object} [options] - Additional options for date formatting.
|
|
1359
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1360
|
+
* @param {Intl.DateTimeFormatOptions} [options] - Additional Intl.DateTimeFormat options.
|
|
1361
|
+
* @returns {string} The formatted date.
|
|
1362
1362
|
*
|
|
1363
1363
|
* @example
|
|
1364
1364
|
* gt.formatDateTime(new Date(), { dateStyle: 'full', timeStyle: 'long' });
|
|
@@ -1370,12 +1370,12 @@ var GT = class {
|
|
|
1370
1370
|
/**
|
|
1371
1371
|
* Formats a currency value according to the specified locales and options.
|
|
1372
1372
|
*
|
|
1373
|
-
* @param {number} value - The currency value to format
|
|
1373
|
+
* @param {number} value - The currency value to format.
|
|
1374
1374
|
* @param {string} currency - The currency code (e.g., 'USD', 'EUR')
|
|
1375
|
-
* @param {Object} [options] - Additional options for currency formatting
|
|
1376
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1377
|
-
* @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options
|
|
1378
|
-
* @returns {string} The formatted currency value
|
|
1375
|
+
* @param {Object} [options] - Additional options for currency formatting.
|
|
1376
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1377
|
+
* @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options.
|
|
1378
|
+
* @returns {string} The formatted currency value.
|
|
1379
1379
|
*
|
|
1380
1380
|
* @example
|
|
1381
1381
|
* gt.formatCurrency(1234.56, 'USD', { style: 'currency' });
|
|
@@ -1387,11 +1387,11 @@ var GT = class {
|
|
|
1387
1387
|
/**
|
|
1388
1388
|
* Formats a list of items according to the specified locales and options.
|
|
1389
1389
|
*
|
|
1390
|
-
* @param {Array<string | number>} array - The list of items to format
|
|
1391
|
-
* @param {Object} [options] - Additional options for list formatting
|
|
1392
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1393
|
-
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
|
|
1394
|
-
* @returns {string} The formatted list
|
|
1390
|
+
* @param {Array<string | number>} array - The list of items to format.
|
|
1391
|
+
* @param {Object} [options] - Additional options for list formatting.
|
|
1392
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1393
|
+
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
|
|
1394
|
+
* @returns {string} The formatted list.
|
|
1395
1395
|
*
|
|
1396
1396
|
* @example
|
|
1397
1397
|
* gt.formatList(['apple', 'banana', 'orange'], { type: 'conjunction' });
|
|
@@ -1402,11 +1402,11 @@ var GT = class {
|
|
|
1402
1402
|
}
|
|
1403
1403
|
/**
|
|
1404
1404
|
* Formats a list of items according to the specified locales and options.
|
|
1405
|
-
* @param {Array<T>} array - The list of items to format
|
|
1406
|
-
* @param {Object} [options] - Additional options for list formatting
|
|
1407
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1408
|
-
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
|
|
1409
|
-
* @returns {Array<T | string>} The formatted list parts
|
|
1405
|
+
* @param {Array<T>} array - The list of items to format.
|
|
1406
|
+
* @param {Object} [options] - Additional options for list formatting.
|
|
1407
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1408
|
+
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
|
|
1409
|
+
* @returns {Array<T | string>} The formatted list parts.
|
|
1410
1410
|
*
|
|
1411
1411
|
* @example
|
|
1412
1412
|
* gt.formatListToParts(['apple', 42, { foo: 'bar' }], { type: 'conjunction', style: 'short', locales: ['en'] });
|
|
@@ -1418,12 +1418,12 @@ var GT = class {
|
|
|
1418
1418
|
/**
|
|
1419
1419
|
* Formats a relative time value according to the specified locales and options.
|
|
1420
1420
|
*
|
|
1421
|
-
* @param {number} value - The relative time value to format
|
|
1421
|
+
* @param {number} value - The relative time value to format.
|
|
1422
1422
|
* @param {Intl.RelativeTimeFormatUnit} unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year')
|
|
1423
|
-
* @param {Object} options - Additional options for relative time formatting
|
|
1424
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1425
|
-
* @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options
|
|
1426
|
-
* @returns {string} The formatted relative time string
|
|
1423
|
+
* @param {Object} options - Additional options for relative time formatting.
|
|
1424
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1425
|
+
* @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options.
|
|
1426
|
+
* @returns {string} The formatted relative time string.
|
|
1427
1427
|
*
|
|
1428
1428
|
* @example
|
|
1429
1429
|
* gt.formatRelativeTime(-1, 'day', { locales: ['en-US'], numeric: 'auto' });
|
|
@@ -1435,9 +1435,9 @@ var GT = class {
|
|
|
1435
1435
|
/**
|
|
1436
1436
|
* Formats a relative time string from a Date, automatically selecting the best unit.
|
|
1437
1437
|
*
|
|
1438
|
-
* @param {Date} date - The date to format relative to now
|
|
1439
|
-
* @param {Object} [options] - Additional options for relative time formatting
|
|
1440
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1438
|
+
* @param {Date} date - The date to format relative to now.
|
|
1439
|
+
* @param {Object} [options] - Additional options for relative time formatting.
|
|
1440
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1441
1441
|
* @returns {string} The formatted relative time string (e.g., "2 hours ago", "in 3 days")
|
|
1442
1442
|
*
|
|
1443
1443
|
* @example
|
|
@@ -1450,9 +1450,9 @@ var GT = class {
|
|
|
1450
1450
|
/**
|
|
1451
1451
|
* Retrieves the display name of a locale code using Intl.DisplayNames, returning an empty string if no name is found.
|
|
1452
1452
|
*
|
|
1453
|
-
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code
|
|
1454
|
-
* @returns {string} The display name corresponding to the code
|
|
1455
|
-
* @throws {Error} If no target locale is provided
|
|
1453
|
+
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code.
|
|
1454
|
+
* @returns {string} The display name corresponding to the code.
|
|
1455
|
+
* @throws {Error} If no target locale is provided.
|
|
1456
1456
|
*
|
|
1457
1457
|
* @example
|
|
1458
1458
|
* gt.getLocaleName('es-ES');
|
|
@@ -1467,8 +1467,8 @@ var GT = class {
|
|
|
1467
1467
|
* Uses the locale's region (if present) to select an emoji or falls back on default emojis.
|
|
1468
1468
|
*
|
|
1469
1469
|
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code (e.g., 'en-US', 'fr-CA')
|
|
1470
|
-
* @returns {string} The emoji representing the locale or its region
|
|
1471
|
-
* @throws {Error} If no target locale is provided
|
|
1470
|
+
* @returns {string} The emoji representing the locale or its region.
|
|
1471
|
+
* @throws {Error} If no target locale is provided.
|
|
1472
1472
|
*
|
|
1473
1473
|
* @example
|
|
1474
1474
|
* gt.getLocaleEmoji('es-ES');
|
|
@@ -1572,12 +1572,12 @@ var GT = class {
|
|
|
1572
1572
|
/**
|
|
1573
1573
|
* Determines whether a translation is required based on the source and target locales.
|
|
1574
1574
|
*
|
|
1575
|
-
* @param {string} [sourceLocale=this.sourceLocale] - The locale code for the original content
|
|
1576
|
-
* @param {string} [targetLocale=this.targetLocale] - The locale code to translate into
|
|
1577
|
-
* @param {string[]} [approvedLocales=this.locales] - Optional array of approved target locales
|
|
1575
|
+
* @param {string} [sourceLocale=this.sourceLocale] - The locale code for the original content.
|
|
1576
|
+
* @param {string} [targetLocale=this.targetLocale] - The locale code to translate into.
|
|
1577
|
+
* @param {string[]} [approvedLocales=this.locales] - Optional array of approved target locales.
|
|
1578
1578
|
* @returns {boolean} True if translation is required, false otherwise
|
|
1579
|
-
* @throws {Error} If no source locale is provided
|
|
1580
|
-
* @throws {Error} If no target locale is provided
|
|
1579
|
+
* @throws {Error} If no source locale is provided.
|
|
1580
|
+
* @throws {Error} If no target locale is provided.
|
|
1581
1581
|
*
|
|
1582
1582
|
* @example
|
|
1583
1583
|
* gt.requiresTranslation('en-US', 'es-ES');
|
|
@@ -1592,9 +1592,9 @@ var GT = class {
|
|
|
1592
1592
|
/**
|
|
1593
1593
|
* Determines the best matching locale from the provided approved locales list.
|
|
1594
1594
|
*
|
|
1595
|
-
* @param {string | string[]} locales - A single locale or array of locales in preference order
|
|
1596
|
-
* @param {string[]} [approvedLocales=this.locales] - Array of approved locales in preference order
|
|
1597
|
-
* @returns {string | undefined} The best matching locale or undefined if no match is found
|
|
1595
|
+
* @param {string | string[]} locales - A single locale or array of locales in preference order.
|
|
1596
|
+
* @param {string[]} [approvedLocales=this.locales] - Array of approved locales in preference order.
|
|
1597
|
+
* @returns {string | undefined} The best matching locale, or undefined if no match is found.
|
|
1598
1598
|
*
|
|
1599
1599
|
* @example
|
|
1600
1600
|
* gt.determineLocale(['fr-CA', 'fr-FR'], ['en-US', 'fr-FR', 'es-ES']);
|
|
@@ -1607,9 +1607,9 @@ var GT = class {
|
|
|
1607
1607
|
/**
|
|
1608
1608
|
* Gets the text direction for a given locale code.
|
|
1609
1609
|
*
|
|
1610
|
-
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code
|
|
1611
|
-
* @returns {'ltr' | 'rtl'} 'rtl' if the locale is right-to-left
|
|
1612
|
-
* @throws {Error} If no target locale is provided
|
|
1610
|
+
* @param {string} [locale=this.targetLocale] - A BCP-47 locale code.
|
|
1611
|
+
* @returns {'ltr' | 'rtl'} 'rtl' if the locale is right-to-left; otherwise 'ltr'.
|
|
1612
|
+
* @throws {Error} If no target locale is provided.
|
|
1613
1613
|
*
|
|
1614
1614
|
* @example
|
|
1615
1615
|
* gt.getLocaleDirection('ar-SA');
|
|
@@ -1622,10 +1622,10 @@ var GT = class {
|
|
|
1622
1622
|
/**
|
|
1623
1623
|
* Checks if a given BCP 47 locale code is valid.
|
|
1624
1624
|
*
|
|
1625
|
-
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate
|
|
1626
|
-
* @param {
|
|
1625
|
+
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate.
|
|
1626
|
+
* @param {CustomMapping} [customMapping=this.customMapping] - The custom mapping to use for validation.
|
|
1627
1627
|
* @returns {boolean} True if the locale code is valid, false otherwise
|
|
1628
|
-
* @throws {Error} If no target locale is provided
|
|
1628
|
+
* @throws {Error} If no target locale is provided.
|
|
1629
1629
|
*
|
|
1630
1630
|
* @example
|
|
1631
1631
|
* gt.isValidLocale('en-US');
|
|
@@ -1640,7 +1640,7 @@ var GT = class {
|
|
|
1640
1640
|
* Resolves the canonical locale for a given locale.
|
|
1641
1641
|
* @param locale - The locale to resolve the canonical locale for
|
|
1642
1642
|
* @param customMapping - The custom mapping to use for resolving the canonical locale
|
|
1643
|
-
* @returns The canonical locale
|
|
1643
|
+
* @returns The canonical locale, or the input locale when no canonical mapping exists.
|
|
1644
1644
|
*/
|
|
1645
1645
|
resolveCanonicalLocale(locale = this.targetLocale, customMapping = this.customMapping) {
|
|
1646
1646
|
if (!locale) throw new Error(noTargetLocaleProvidedError("resolveCanonicalLocale"));
|
|
@@ -1651,7 +1651,7 @@ var GT = class {
|
|
|
1651
1651
|
* Resolves the alias locale for a given locale.
|
|
1652
1652
|
* @param locale - The locale to resolve the alias locale for
|
|
1653
1653
|
* @param customMapping - The custom mapping to use for resolving the alias locale
|
|
1654
|
-
* @returns The alias locale
|
|
1654
|
+
* @returns The configured alias for a canonical locale, or the input locale when already an alias or no alias mapping exists.
|
|
1655
1655
|
*/
|
|
1656
1656
|
resolveAliasLocale(locale, customMapping = this.customMapping) {
|
|
1657
1657
|
if (!locale) throw new Error(noTargetLocaleProvidedError("resolveAliasLocale"));
|
|
@@ -1661,9 +1661,9 @@ var GT = class {
|
|
|
1661
1661
|
/**
|
|
1662
1662
|
* Standardizes a BCP 47 locale code to ensure correct formatting.
|
|
1663
1663
|
*
|
|
1664
|
-
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to standardize
|
|
1665
|
-
* @returns {string} The standardized locale code or
|
|
1666
|
-
* @throws {Error} If no target locale is provided
|
|
1664
|
+
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to standardize.
|
|
1665
|
+
* @returns {string} The standardized locale code, or the input string if it cannot be standardized.
|
|
1666
|
+
* @throws {Error} If no target locale is provided.
|
|
1667
1667
|
*
|
|
1668
1668
|
* @example
|
|
1669
1669
|
* gt.standardizeLocale('en_us');
|
|
@@ -1676,7 +1676,7 @@ var GT = class {
|
|
|
1676
1676
|
/**
|
|
1677
1677
|
* Checks if multiple BCP 47 locale codes represent the same dialect.
|
|
1678
1678
|
*
|
|
1679
|
-
* @param {...(string | string[])} locales - The BCP 47 locale codes to compare
|
|
1679
|
+
* @param {...(string | string[])} locales - The BCP 47 locale codes to compare.
|
|
1680
1680
|
* @returns {boolean} True if all codes represent the same dialect, false otherwise
|
|
1681
1681
|
*
|
|
1682
1682
|
* @example
|
|
@@ -1692,7 +1692,7 @@ var GT = class {
|
|
|
1692
1692
|
/**
|
|
1693
1693
|
* Checks if multiple BCP 47 locale codes represent the same language.
|
|
1694
1694
|
*
|
|
1695
|
-
* @param {...(string | string[])} locales - The BCP 47 locale codes to compare
|
|
1695
|
+
* @param {...(string | string[])} locales - The BCP 47 locale codes to compare.
|
|
1696
1696
|
* @returns {boolean} True if all codes represent the same language, false otherwise
|
|
1697
1697
|
*
|
|
1698
1698
|
* @example
|
|
@@ -1784,11 +1784,11 @@ function formatList(array, options) {
|
|
|
1784
1784
|
}
|
|
1785
1785
|
/**
|
|
1786
1786
|
* Formats a list of items according to the specified locales and options.
|
|
1787
|
-
* @param {Array<T>} array - The list of items to format
|
|
1788
|
-
* @param {Object} [options] - Additional options for list formatting
|
|
1789
|
-
* @param {string | string[]} [options.locales] - The locales to use for formatting
|
|
1790
|
-
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
|
|
1791
|
-
* @returns {Array<T | string>} The formatted list parts
|
|
1787
|
+
* @param {Array<T>} array - The list of items to format.
|
|
1788
|
+
* @param {Object} [options] - Additional options for list formatting.
|
|
1789
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1790
|
+
* @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
|
|
1791
|
+
* @returns {Array<T | string>} The formatted list parts.
|
|
1792
1792
|
*/
|
|
1793
1793
|
function formatListToParts(array, options) {
|
|
1794
1794
|
return _formatListToParts({
|
|
@@ -1958,7 +1958,7 @@ function determineLocale(locales, approvedLocales = [], customMapping = void 0)
|
|
|
1958
1958
|
* Get the text direction for a given locale code using the Intl.Locale API.
|
|
1959
1959
|
*
|
|
1960
1960
|
* @param {string} locale - A BCP-47 locale code.
|
|
1961
|
-
* @returns {string}
|
|
1961
|
+
* @returns {string} 'rtl' if the locale is right-to-left; otherwise 'ltr'.
|
|
1962
1962
|
*/
|
|
1963
1963
|
function getLocaleDirection(locale) {
|
|
1964
1964
|
return _getLocaleDirection(locale);
|