generaltranslation 8.2.12 → 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 +8 -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/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-CST4J4WU.cjs → core-7RP541eY.cjs} +2 -2
- package/dist/core-7RP541eY.cjs.map +1 -0
- package/dist/{core-D-E8qhLn.d.cts → core-I9pWGafA.d.mts} +2 -2
- package/dist/{core-CGhlXrrK.d.mts → core-TLJoDpJP.d.cts} +2 -2
- package/dist/{core-7RJsqw6c.mjs → core-isLphYAZ.mjs} +2 -2
- 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.d.cts +1 -1
- package/dist/id.d.mts +1 -1
- package/dist/id.d.ts +3 -0
- package/dist/id.js +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +1019 -0
- package/dist/index.js +1664 -0
- package/dist/index.mjs +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +19 -0
- package/dist/internal.js +17 -0
- package/dist/internal.mjs +1 -1
- 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-BsGsgJWF.d.mts → types-AHtYZIP-.d.mts} +34 -11
- package/dist/{types-V5rqd1WR.d.cts → types-Bf8_Apq_.d.cts} +34 -11
- 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.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/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 +3 -3
- package/dist/core-7RJsqw6c.mjs.map +0 -1
- package/dist/core-CST4J4WU.cjs.map +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { DataFormat, JsxChildren } from '../jsx/content';
|
|
2
|
+
type UpdateMetadata = {
|
|
3
|
+
id?: string;
|
|
4
|
+
hash?: string;
|
|
5
|
+
context?: string;
|
|
6
|
+
maxChars?: number;
|
|
7
|
+
dataFormat?: DataFormat;
|
|
8
|
+
actionType?: 'standard' | 'fast' | string;
|
|
9
|
+
staticId?: string;
|
|
10
|
+
format?: string;
|
|
11
|
+
filePaths?: string[];
|
|
12
|
+
sourceCode?: unknown;
|
|
13
|
+
contextDeriveExpr?: unknown;
|
|
14
|
+
_contextDeriveExpr?: unknown;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
export type Updates = ({
|
|
18
|
+
metadata: UpdateMetadata;
|
|
19
|
+
} & ({
|
|
20
|
+
dataFormat: 'JSX';
|
|
21
|
+
source: JsxChildren;
|
|
22
|
+
} | {
|
|
23
|
+
dataFormat: 'ICU';
|
|
24
|
+
source: string;
|
|
25
|
+
} | {
|
|
26
|
+
dataFormat: 'I18NEXT';
|
|
27
|
+
source: string;
|
|
28
|
+
} | {
|
|
29
|
+
dataFormat: 'STRING';
|
|
30
|
+
source: string;
|
|
31
|
+
}))[];
|
|
32
|
+
/**
|
|
33
|
+
* Options for enqueueing files
|
|
34
|
+
* @param requireApproval - Whether to require approval for the files.
|
|
35
|
+
* @param description - Optional description for the project.
|
|
36
|
+
* @param sourceLocale - The project's source locale.
|
|
37
|
+
* @param targetLocales - The locales to translate the files to.
|
|
38
|
+
* @param version - Optional custom version ID to specify.
|
|
39
|
+
* @param timeout - Optional timeout for the request.
|
|
40
|
+
* @param modelProvider - Optional model provider to use.
|
|
41
|
+
*/
|
|
42
|
+
export type EnqueueFilesOptions = {
|
|
43
|
+
requireApproval?: boolean;
|
|
44
|
+
description?: string;
|
|
45
|
+
sourceLocale?: string;
|
|
46
|
+
targetLocales: string[];
|
|
47
|
+
version?: string;
|
|
48
|
+
_versionId?: string;
|
|
49
|
+
timeout?: number;
|
|
50
|
+
modelProvider?: string;
|
|
51
|
+
force?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export type RequiredEnqueueFilesOptions = EnqueueFilesOptions & Required<Pick<EnqueueFilesOptions, 'sourceLocale'>>;
|
|
54
|
+
export type EnqueueFilesResult = {
|
|
55
|
+
jobData: {
|
|
56
|
+
[jobId: string]: {
|
|
57
|
+
sourceFileId: string;
|
|
58
|
+
fileId: string;
|
|
59
|
+
versionId: string;
|
|
60
|
+
branchId: string;
|
|
61
|
+
targetLocale: string;
|
|
62
|
+
projectId: string;
|
|
63
|
+
force: boolean;
|
|
64
|
+
modelProvider?: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
locales: string[];
|
|
68
|
+
message: string;
|
|
69
|
+
};
|
|
70
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Content, DataFormat } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* ActionType is the type of action to perform on the request.
|
|
4
|
+
*
|
|
5
|
+
* @param fast - The fast action type (mini model).
|
|
6
|
+
*/
|
|
7
|
+
export type ActionType = 'fast';
|
|
8
|
+
/**
|
|
9
|
+
* EntryMetadata is the metadata for a GTRequest.
|
|
10
|
+
*
|
|
11
|
+
* @param context - The context of the request.
|
|
12
|
+
* @param id - The ID of the request.
|
|
13
|
+
* @param maxChars - The maxChars of the request.
|
|
14
|
+
* @param hash - The hash of the request.
|
|
15
|
+
*/
|
|
16
|
+
export type EntryMetadata = {
|
|
17
|
+
id?: string;
|
|
18
|
+
hash?: string;
|
|
19
|
+
context?: string;
|
|
20
|
+
maxChars?: number;
|
|
21
|
+
dataFormat?: DataFormat;
|
|
22
|
+
actionType?: ActionType;
|
|
23
|
+
};
|
|
24
|
+
export type RuntimeTranslateManyOptions = {
|
|
25
|
+
sourceLocale?: string;
|
|
26
|
+
modelProvider?: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
export type TranslateOptions = RuntimeTranslateManyOptions & {
|
|
30
|
+
targetLocale: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* TranslateManyEntry is the input type for translateMany.
|
|
34
|
+
* Can be a plain string or an object with source and entry metadata fields.
|
|
35
|
+
*/
|
|
36
|
+
export type TranslateManyEntry = string | {
|
|
37
|
+
source: Content;
|
|
38
|
+
metadata?: EntryMetadata;
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Content } from '../jsx/content';
|
|
2
|
+
export type FetchTranslationsOptions = {
|
|
3
|
+
timeout?: number;
|
|
4
|
+
};
|
|
5
|
+
export type RetrievedTranslation = {
|
|
6
|
+
locale: string;
|
|
7
|
+
translation: Content;
|
|
8
|
+
};
|
|
9
|
+
export type RetrievedTranslations = RetrievedTranslation[];
|
|
10
|
+
export type FetchTranslationsResult = {
|
|
11
|
+
translations: RetrievedTranslations;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DataFormat } from '../jsx/content';
|
|
2
|
+
import { Updates } from './enqueueFiles';
|
|
3
|
+
import type { JsonObject } from './json';
|
|
4
|
+
export type FileFormat = 'GTJSON' | 'JSON' | 'PO' | 'POT' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTML' | 'TXT' | 'TWILIO_CONTENT_JSON';
|
|
5
|
+
/**
|
|
6
|
+
* Metadata for files or entries.
|
|
7
|
+
*/
|
|
8
|
+
export type FormatMetadata = JsonObject | Updates[number]['metadata'];
|
|
9
|
+
/**
|
|
10
|
+
* File object structure for uploading files.
|
|
11
|
+
* @see {@link FileReferenceOptionalBranchId}
|
|
12
|
+
* @property {string} content - Content of the file.
|
|
13
|
+
* @property {string} locale - The locale of the file (e.g. 'en', 'de', 'es', etc.)
|
|
14
|
+
* @property {FormatMetadata} [formatMetadata] - Optional metadata for the file, specific to the format of the file
|
|
15
|
+
* @property {string} [incomingBranchId] - The ID of the incoming branch of the file.
|
|
16
|
+
* @property {string} [checkedOutBranchId] - The ID of the checked-out branch of the file.
|
|
17
|
+
*/
|
|
18
|
+
export type FileToUpload = Omit<FileReference, 'branchId'> & {
|
|
19
|
+
content: string;
|
|
20
|
+
locale: string;
|
|
21
|
+
transformFormat?: FileFormat;
|
|
22
|
+
formatMetadata?: FormatMetadata;
|
|
23
|
+
branchId?: string;
|
|
24
|
+
incomingBranchId?: string;
|
|
25
|
+
checkedOutBranchId?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* File object structure for referencing files.
|
|
29
|
+
* @property {string} fileId - The ID of the file.
|
|
30
|
+
* @property {string} versionId - The ID of the version of the file
|
|
31
|
+
* @property {string} branchId - The ID of the branch of the file
|
|
32
|
+
* @property {string} locale - The locale of the file (e.g. 'en', 'de', 'es', etc.)
|
|
33
|
+
* @property {string} fileName - The name of the file.
|
|
34
|
+
* @property {FileFormat} fileFormat - The format of the file (JSON, MDX, MD, etc.).
|
|
35
|
+
* @property {DataFormat} [dataFormat] - Optional format of the data within the file.
|
|
36
|
+
*/
|
|
37
|
+
export type FileReference = {
|
|
38
|
+
fileId: string;
|
|
39
|
+
versionId: string;
|
|
40
|
+
branchId: string;
|
|
41
|
+
fileName: string;
|
|
42
|
+
fileFormat: FileFormat;
|
|
43
|
+
transformFormat?: FileFormat;
|
|
44
|
+
dataFormat?: DataFormat;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* File reference object structure for referencing files.
|
|
48
|
+
* @see {@link FileReference}
|
|
49
|
+
* @property {string} [branchId] - The ID of the branch of the file
|
|
50
|
+
*/
|
|
51
|
+
export type FileReferenceIds = Omit<FileReference, 'branchId' | 'fileName' | 'fileFormat' | 'dataFormat'> & {
|
|
52
|
+
branchId?: string;
|
|
53
|
+
fileName?: string;
|
|
54
|
+
fileFormat?: FileFormat;
|
|
55
|
+
transformFormat?: FileFormat;
|
|
56
|
+
dataFormat?: DataFormat;
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { I18nextMessage, IcuMessage, JsxChildren, StringMessage } from '../jsx/content';
|
|
2
|
+
/**
|
|
3
|
+
* TranslationResultReference is used to store the reference for a translation result.
|
|
4
|
+
*/
|
|
5
|
+
export type TranslationResultReference = {
|
|
6
|
+
id?: string;
|
|
7
|
+
hash: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* TypedResult is a union type that represents the different types of translations that can be returned.
|
|
11
|
+
*/
|
|
12
|
+
export type TypedResult = {
|
|
13
|
+
translation: JsxChildren;
|
|
14
|
+
dataFormat: 'JSX';
|
|
15
|
+
} | {
|
|
16
|
+
translation: I18nextMessage | IcuMessage | StringMessage;
|
|
17
|
+
dataFormat: 'ICU' | 'I18NEXT' | 'STRING';
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* RequestError is a type that represents an error that occurred during a translation request.
|
|
21
|
+
*/
|
|
22
|
+
export type TranslationError = {
|
|
23
|
+
success: false;
|
|
24
|
+
error: string;
|
|
25
|
+
code: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* RequestSuccess is a type that represents a successful translation request.
|
|
29
|
+
*/
|
|
30
|
+
export type RequestSuccess = TypedResult & {
|
|
31
|
+
success: true;
|
|
32
|
+
locale: string;
|
|
33
|
+
};
|
|
34
|
+
export type TranslationResult = RequestSuccess | TranslationError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DataFormat } from '../jsx/content';
|
|
2
|
+
import { FileFormat, FileReference, type FormatMetadata } from './file';
|
|
3
|
+
/**
|
|
4
|
+
* Metadata stored alongside GTJSON file entries.
|
|
5
|
+
* Keys correspond to the entry id/hash in the GTJSON body.
|
|
6
|
+
*/
|
|
7
|
+
export type GTJsonFormatMetadata = Record<string, {
|
|
8
|
+
context?: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
domain?: string;
|
|
11
|
+
maxChars?: number;
|
|
12
|
+
dataFormat?: 'JSX' | 'ICU' | 'I18NEXT';
|
|
13
|
+
requestVersion?: number;
|
|
14
|
+
approved_at?: string | null;
|
|
15
|
+
approved_by?: string | null;
|
|
16
|
+
hash?: string;
|
|
17
|
+
staticId?: string;
|
|
18
|
+
filePaths?: string[];
|
|
19
|
+
}>;
|
|
20
|
+
export type FileUpload = {
|
|
21
|
+
branchId?: string;
|
|
22
|
+
incomingBranchId?: string;
|
|
23
|
+
checkedOutBranchId?: string;
|
|
24
|
+
content: string;
|
|
25
|
+
fileName: string;
|
|
26
|
+
fileFormat: FileFormat;
|
|
27
|
+
transformFormat?: FileFormat;
|
|
28
|
+
dataFormat?: DataFormat;
|
|
29
|
+
locale: string;
|
|
30
|
+
formatMetadata?: GTJsonFormatMetadata | FormatMetadata;
|
|
31
|
+
versionId?: string;
|
|
32
|
+
fileId?: string;
|
|
33
|
+
};
|
|
34
|
+
export type UploadFilesOptions = {
|
|
35
|
+
sourceLocale: string;
|
|
36
|
+
modelProvider?: string;
|
|
37
|
+
timeout?: number;
|
|
38
|
+
};
|
|
39
|
+
export type UploadFilesResponse = {
|
|
40
|
+
uploadedFiles: FileReference[];
|
|
41
|
+
count: number;
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
44
|
+
export type RequiredUploadFilesOptions = UploadFilesOptions & Required<Pick<UploadFilesOptions, 'sourceLocale'>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Variable } from './variables';
|
|
2
|
+
/**
|
|
3
|
+
* Map of data-_gt properties to their corresponding React props
|
|
4
|
+
*/
|
|
5
|
+
export declare const HTML_CONTENT_PROPS: {
|
|
6
|
+
readonly pl: "placeholder";
|
|
7
|
+
readonly ti: "title";
|
|
8
|
+
readonly alt: "alt";
|
|
9
|
+
readonly arl: "aria-label";
|
|
10
|
+
readonly arb: "aria-labelledby";
|
|
11
|
+
readonly ard: "aria-describedby";
|
|
12
|
+
};
|
|
13
|
+
export type HtmlContentPropKeysRecord = Partial<Record<keyof typeof HTML_CONTENT_PROPS, string>>;
|
|
14
|
+
export type HtmlContentPropValuesRecord = Partial<Record<(typeof HTML_CONTENT_PROPS)[keyof typeof HTML_CONTENT_PROPS], string>>;
|
|
15
|
+
/**
|
|
16
|
+
* GTProp is an internal property used to contain data for translating and rendering elements.
|
|
17
|
+
* note, transformations are only read on the server side if they are 'plural' or 'branch'
|
|
18
|
+
*/
|
|
19
|
+
export type GTProp = {
|
|
20
|
+
b?: Record<string, JsxChildren>;
|
|
21
|
+
t?: 'p' | 'b';
|
|
22
|
+
} & HtmlContentPropKeysRecord;
|
|
23
|
+
export type JsxElement = {
|
|
24
|
+
t?: string;
|
|
25
|
+
i?: number;
|
|
26
|
+
d?: GTProp;
|
|
27
|
+
c?: JsxChildren;
|
|
28
|
+
};
|
|
29
|
+
export type JsxChild = string | JsxElement | Variable;
|
|
30
|
+
/**
|
|
31
|
+
* The format of the string content
|
|
32
|
+
*/
|
|
33
|
+
export type StringFormat = 'ICU' | 'I18NEXT' | 'STRING';
|
|
34
|
+
/**
|
|
35
|
+
* The format of the content.
|
|
36
|
+
*/
|
|
37
|
+
export type DataFormat = 'JSX' | StringFormat;
|
|
38
|
+
/**
|
|
39
|
+
* String format content.
|
|
40
|
+
*/
|
|
41
|
+
export type StringContent = IcuMessage | StringMessage | I18nextMessage;
|
|
42
|
+
/**
|
|
43
|
+
* A content type representing JSX, ICU, and I18next messages.
|
|
44
|
+
*/
|
|
45
|
+
export type Content = JsxChildren | StringContent;
|
|
46
|
+
/**
|
|
47
|
+
* A content type representing JSX elements.
|
|
48
|
+
*/
|
|
49
|
+
export type JsxChildren = JsxChild | JsxChild[];
|
|
50
|
+
/**
|
|
51
|
+
* A content type representing ICU messages.
|
|
52
|
+
*/
|
|
53
|
+
export type IcuMessage = string;
|
|
54
|
+
/**
|
|
55
|
+
* A content type representing I18next messages.
|
|
56
|
+
*/
|
|
57
|
+
export type I18nextMessage = string;
|
|
58
|
+
/**
|
|
59
|
+
* A content type representing plain strings.
|
|
60
|
+
*/
|
|
61
|
+
export type StringMessage = string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transformations are made from a prefix and a suffix.
|
|
3
|
+
*/
|
|
4
|
+
export type Transformation = BaseTransformation | `${BaseTransformation}-${InjectionType}`;
|
|
5
|
+
export type BaseTransformation = 'translate-client' | 'translate-server' | 'translate-runtime' | 'variable-variable' | 'variable-currency' | 'variable-datetime' | 'variable-number' | 'variable-relative-time' | 'plural' | 'branch' | 'derive';
|
|
6
|
+
export type TransformationPrefix = 'translate' | 'variable' | 'plural' | 'branch' | 'fragment' | 'derive';
|
|
7
|
+
export type VariableTransformationSuffix = 'variable' | 'number' | 'datetime' | 'currency' | 'relative-time';
|
|
8
|
+
export type InjectionType = 'automatic' | 'manual';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as FileReference, A as BranchDataResult, At as
|
|
2
|
-
export { AwaitJobsOptions, AwaitJobsResult, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, ContentTranslationResult, CreateTagOptions, CreateTagResult, CustomMapping, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FetchTranslationsOptions, FetchTranslationsResult, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileTranslationQuery, FileUpload, FormatVariables, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, IcuTranslationResult, InjectionType, JobResult, JobStatus, JsxChild, JsxChildren, JsxElement, JsxTranslationResult, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, Request, RetrievedTranslations, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, TranslationStatusResult, Update, Updates, Variable, VariableTransformationSuffix, VariableType, _Content };
|
|
1
|
+
import { $ as FileReference, A as BranchDataResult, At as StringContent, B as FileUpload, C as ProcessMovesOptions, Ct as HtmlContentPropKeysRecord, D as FileDataQuery, Dt as JsxChild, E as OrphanedFile, Et as IcuMessage, F as DownloadFileOptions, Ft as LocaleProperties, G as FetchTranslationsOptions, I as PublishFileEntry, It as CustomMapping, J as DownloadFileBatchOptions, K as FetchTranslationsResult, L as PublishFilesResult, M as TranslationError, Mt as StringMessage, N as TranslationResult, Nt as Variable, O as FileDataResult, Ot as JsxChildren, P as TranslationResultReference, Pt as VariableType, Q as FileFormat, R as EnqueueEntriesOptions, S as MoveResult, St as HTML_CONTENT_PROPS, T as GetOrphanedFilesResult, Tt as I18nextMessage, U as CreateTagOptions, W as CreateTagResult, X as DownloadFileBatchResult, Z as DownloadedFile, _ as AwaitJobsResult, _t as TranslateManyEntry, a as Metadata, at as CheckFileTranslationsOptions, b as JobStatus, bt as DataFormat, c as Update, ct as FileTranslationQuery, d as Transformation, dt as JsonValue, f as TransformationPrefix, ft as TranslationStatusResult, g as AwaitJobsOptions, h as SubmitUserEditDiffsPayload, ht as EntryMetadata, i as JsxTranslationResult, it as Updates, j as TranslateManyResult, jt as StringFormat, k as BranchQuery, kt as JsxElement, l as _Content, lt as JsonObject, m as SubmitUserEditDiff, mt as ActionType, n as FormatVariables, nt as EnqueueFilesOptions, o as Request, p as VariableTransformationSuffix, pt as HashMetadata, q as RetrievedTranslations, r as IcuTranslationResult, rt as EnqueueFilesResult, s as TranslationRequestConfig, t as ContentTranslationResult, tt as FileToUpload, u as InjectionType, ut as JsonPrimitive, v as JobResult, w as ProcessMovesResponse, wt as HtmlContentPropValuesRecord, x as MoveMapping, xt as GTProp, y as CheckJobStatusResult, yt as Content, z as EnqueueEntriesResult } from "./types-Bf8_Apq_.cjs";
|
|
2
|
+
export { AwaitJobsOptions, AwaitJobsResult, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, ContentTranslationResult, CreateTagOptions, CreateTagResult, CustomMapping, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FetchTranslationsOptions, FetchTranslationsResult, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileTranslationQuery, FileUpload, FormatVariables, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, IcuTranslationResult, InjectionType, JobResult, JobStatus, JsonObject, JsonPrimitive, JsonValue, JsxChild, JsxChildren, JsxElement, JsxTranslationResult, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, Request, RetrievedTranslations, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, TranslationStatusResult, Update, Updates, Variable, VariableTransformationSuffix, VariableType, _Content };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as FileReference, A as BranchDataResult, At as
|
|
2
|
-
export { AwaitJobsOptions, AwaitJobsResult, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, ContentTranslationResult, CreateTagOptions, CreateTagResult, CustomMapping, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FetchTranslationsOptions, FetchTranslationsResult, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileTranslationQuery, FileUpload, FormatVariables, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, IcuTranslationResult, InjectionType, JobResult, JobStatus, JsxChild, JsxChildren, JsxElement, JsxTranslationResult, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, Request, RetrievedTranslations, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, TranslationStatusResult, Update, Updates, Variable, VariableTransformationSuffix, VariableType, _Content };
|
|
1
|
+
import { $ as FileReference, A as BranchDataResult, At as StringContent, B as FileUpload, C as ProcessMovesOptions, Ct as HtmlContentPropKeysRecord, D as FileDataQuery, Dt as JsxChild, E as OrphanedFile, Et as IcuMessage, F as DownloadFileOptions, Ft as LocaleProperties, G as FetchTranslationsOptions, I as PublishFileEntry, It as CustomMapping, J as DownloadFileBatchOptions, K as FetchTranslationsResult, L as PublishFilesResult, M as TranslationError, Mt as StringMessage, N as TranslationResult, Nt as Variable, O as FileDataResult, Ot as JsxChildren, P as TranslationResultReference, Pt as VariableType, Q as FileFormat, R as EnqueueEntriesOptions, S as MoveResult, St as HTML_CONTENT_PROPS, T as GetOrphanedFilesResult, Tt as I18nextMessage, U as CreateTagOptions, W as CreateTagResult, X as DownloadFileBatchResult, Z as DownloadedFile, _ as AwaitJobsResult, _t as TranslateManyEntry, a as Metadata, at as CheckFileTranslationsOptions, b as JobStatus, bt as DataFormat, c as Update, ct as FileTranslationQuery, d as Transformation, dt as JsonValue, f as TransformationPrefix, ft as TranslationStatusResult, g as AwaitJobsOptions, h as SubmitUserEditDiffsPayload, ht as EntryMetadata, i as JsxTranslationResult, it as Updates, j as TranslateManyResult, jt as StringFormat, k as BranchQuery, kt as JsxElement, l as _Content, lt as JsonObject, m as SubmitUserEditDiff, mt as ActionType, n as FormatVariables, nt as EnqueueFilesOptions, o as Request, p as VariableTransformationSuffix, pt as HashMetadata, q as RetrievedTranslations, r as IcuTranslationResult, rt as EnqueueFilesResult, s as TranslationRequestConfig, t as ContentTranslationResult, tt as FileToUpload, u as InjectionType, ut as JsonPrimitive, v as JobResult, w as ProcessMovesResponse, wt as HtmlContentPropValuesRecord, x as MoveMapping, xt as GTProp, y as CheckJobStatusResult, yt as Content, z as EnqueueEntriesResult } from "./types-AHtYZIP-.mjs";
|
|
2
|
+
export { AwaitJobsOptions, AwaitJobsResult, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, ContentTranslationResult, CreateTagOptions, CreateTagResult, CustomMapping, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FetchTranslationsOptions, FetchTranslationsResult, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileTranslationQuery, FileUpload, FormatVariables, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, IcuTranslationResult, InjectionType, JobResult, JobStatus, JsonObject, JsonPrimitive, JsonValue, JsxChild, JsxChildren, JsxElement, JsxTranslationResult, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, Request, RetrievedTranslations, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, TranslationStatusResult, Update, Updates, Variable, VariableTransformationSuffix, VariableType, _Content };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { LocaleProperties } from './locales/getLocaleProperties';
|
|
2
|
+
import type { Variable, VariableType } from './types-dir/jsx/variables';
|
|
3
|
+
import { type IcuMessage, type I18nextMessage, type StringMessage, type StringContent, type JsxChildren, type JsxChild, type JsxElement, type GTProp, type HtmlContentPropKeysRecord, type HtmlContentPropValuesRecord, HTML_CONTENT_PROPS, type DataFormat, type Content, type StringFormat } from './types-dir/jsx/content';
|
|
4
|
+
import type { ActionType, EntryMetadata, TranslateManyEntry } from './types-dir/api/entry';
|
|
5
|
+
import type { HashMetadata } from './id/types';
|
|
6
|
+
export type { TranslationStatusResult } from './types-dir/api/translationStatus';
|
|
7
|
+
export type { JsonObject, JsonPrimitive, JsonValue, } from './types-dir/api/json';
|
|
8
|
+
export { IcuMessage, StringMessage, I18nextMessage, StringContent, JsxChildren, JsxChild, JsxElement, GTProp, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, HTML_CONTENT_PROPS, Variable, VariableType, LocaleProperties, DataFormat, ActionType as EntryActionType, EntryMetadata, TranslateManyEntry, Content, StringFormat, HashMetadata, };
|
|
9
|
+
export type { FileTranslationQuery, CheckFileTranslationsOptions, } from './types-dir/api/checkFileTranslations';
|
|
10
|
+
export type { DownloadFileBatchOptions, DownloadFileBatchResult, } from './types-dir/api/downloadFileBatch';
|
|
11
|
+
export type { FetchTranslationsOptions, FetchTranslationsResult, RetrievedTranslations, } from './types-dir/api/fetchTranslations';
|
|
12
|
+
export type { EnqueueFilesOptions, EnqueueFilesResult, Updates, } from './types-dir/api/enqueueFiles';
|
|
13
|
+
export type { CreateTagOptions, CreateTagResult } from './translate/createTag';
|
|
14
|
+
export type { FileToUpload } from './types-dir/api/file';
|
|
15
|
+
export type { FileUpload } from './types-dir/api/uploadFiles';
|
|
16
|
+
export type { EnqueueEntriesOptions, EnqueueEntriesResult, } from './types-dir/api/enqueueEntries';
|
|
17
|
+
export type { FileReference } from './types-dir/api/file';
|
|
18
|
+
export type { PublishFileEntry, PublishFilesResult, } from './translate/publishFiles';
|
|
19
|
+
export type { DownloadedFile } from './types-dir/api/downloadFileBatch';
|
|
20
|
+
export type { DownloadFileOptions } from './types-dir/api/downloadFile';
|
|
21
|
+
export type { FileFormat } from './types-dir/api/file';
|
|
22
|
+
export type { TranslateManyResult } from './types-dir/api/translateMany';
|
|
23
|
+
export type { TranslationResult, TranslationError, TranslationResultReference, } from './types-dir/api/translate';
|
|
24
|
+
export type { BranchDataResult } from './types-dir/api/branch';
|
|
25
|
+
export type { BranchQuery } from './translate/queryBranchData';
|
|
26
|
+
export type { FileDataQuery, FileDataResult } from './translate/queryFileData';
|
|
27
|
+
export type { OrphanedFile, GetOrphanedFilesResult, } from './translate/getOrphanedFiles';
|
|
28
|
+
export type { MoveMapping, MoveResult, ProcessMovesResponse, ProcessMovesOptions, } from './translate/processFileMoves';
|
|
29
|
+
export type { JobStatus, CheckJobStatusResult, } from './translate/checkJobStatus';
|
|
30
|
+
export type { AwaitJobsOptions, AwaitJobsResult, JobResult, } from './translate/awaitJobs';
|
|
31
|
+
export type { SubmitUserEditDiff, SubmitUserEditDiffsPayload, } from './translate/submitUserEditDiffs';
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use {@link Content} instead.
|
|
34
|
+
*/
|
|
35
|
+
export type _Content = string | Array<string | Variable>;
|
|
36
|
+
export type { Transformation, TransformationPrefix, VariableTransformationSuffix, InjectionType, } from './types-dir/transformations';
|
|
37
|
+
export type Metadata = {
|
|
38
|
+
maxChars?: number;
|
|
39
|
+
context?: string;
|
|
40
|
+
id?: string;
|
|
41
|
+
hash?: string;
|
|
42
|
+
format?: string;
|
|
43
|
+
dataFormat?: DataFormat;
|
|
44
|
+
sourceLocale?: string;
|
|
45
|
+
actionType?: 'standard' | 'fast' | string;
|
|
46
|
+
filePaths?: string[];
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
};
|
|
49
|
+
export type FormatVariables = Record<string, string | number | boolean | null | undefined | Date>;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated This type is deprecated and will be removed in a future version.
|
|
52
|
+
*/
|
|
53
|
+
export type Update = {
|
|
54
|
+
type: 'content';
|
|
55
|
+
data: {
|
|
56
|
+
source: _Content;
|
|
57
|
+
metadata: Metadata;
|
|
58
|
+
};
|
|
59
|
+
} | {
|
|
60
|
+
type: 'jsx';
|
|
61
|
+
data: {
|
|
62
|
+
source: JsxChildren;
|
|
63
|
+
metadata: Metadata;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated This type is deprecated and will be removed in a future version.
|
|
68
|
+
*/
|
|
69
|
+
export type Request = {
|
|
70
|
+
type: 'content';
|
|
71
|
+
data: {
|
|
72
|
+
source: _Content;
|
|
73
|
+
targetLocale: string;
|
|
74
|
+
metadata: Metadata;
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
type: 'jsx';
|
|
78
|
+
data: {
|
|
79
|
+
source: JsxChildren;
|
|
80
|
+
targetLocale: string;
|
|
81
|
+
metadata: Metadata;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Use {@link TranslationResult} instead.
|
|
86
|
+
*/
|
|
87
|
+
export type ContentTranslationResult = {
|
|
88
|
+
translation: _Content;
|
|
89
|
+
locale: string;
|
|
90
|
+
reference?: {
|
|
91
|
+
id: string;
|
|
92
|
+
key: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated Use {@link TranslationResult} instead.
|
|
97
|
+
*/
|
|
98
|
+
export type IcuTranslationResult = {
|
|
99
|
+
translation: string;
|
|
100
|
+
locale: string;
|
|
101
|
+
reference?: {
|
|
102
|
+
id: string;
|
|
103
|
+
key: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated Use {@link TranslationResult} instead.
|
|
108
|
+
*/
|
|
109
|
+
export type JsxTranslationResult = {
|
|
110
|
+
translation: JsxChildren;
|
|
111
|
+
locale: string;
|
|
112
|
+
reference?: {
|
|
113
|
+
id: string;
|
|
114
|
+
key: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
export type { CustomMapping } from './locales/customLocaleMapping';
|
|
118
|
+
/**
|
|
119
|
+
* TranslationRequestConfig is used to configure the translation request.
|
|
120
|
+
*
|
|
121
|
+
* @param projectId - The project ID of the translation request.
|
|
122
|
+
* @param baseUrl - The base URL of the translation request.
|
|
123
|
+
* @param apiKey - The API key of the translation request.
|
|
124
|
+
*/
|
|
125
|
+
export type TranslationRequestConfig = {
|
|
126
|
+
projectId: string;
|
|
127
|
+
baseUrl?: string;
|
|
128
|
+
apiKey?: string;
|
|
129
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Encode a string to base64
|
|
2
|
+
export function encode(data) {
|
|
3
|
+
if (typeof Buffer !== 'undefined') {
|
|
4
|
+
// Node.js path.
|
|
5
|
+
return Buffer.from(data, 'utf8').toString('base64');
|
|
6
|
+
}
|
|
7
|
+
// Browser path.
|
|
8
|
+
var bytes = new TextEncoder().encode(data);
|
|
9
|
+
var binary = '';
|
|
10
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
11
|
+
binary += String.fromCharCode(bytes[i]);
|
|
12
|
+
}
|
|
13
|
+
return btoa(binary);
|
|
14
|
+
}
|
|
15
|
+
// Decode a base64 string to a string
|
|
16
|
+
export function decode(base64) {
|
|
17
|
+
if (typeof Buffer !== 'undefined') {
|
|
18
|
+
// Node.js path.
|
|
19
|
+
return Buffer.from(base64, 'base64').toString('utf8');
|
|
20
|
+
}
|
|
21
|
+
// Browser path.
|
|
22
|
+
var binary = atob(base64);
|
|
23
|
+
var bytes = new Uint8Array(binary.length);
|
|
24
|
+
for (var i = 0; i < binary.length; i++) {
|
|
25
|
+
bytes[i] = binary.charCodeAt(i);
|
|
26
|
+
}
|
|
27
|
+
return new TextDecoder().decode(bytes);
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FileFormat } from '../types-dir/api/file';
|
|
2
|
+
/**
|
|
3
|
+
* This function checks if a file format transformation is supported during translation
|
|
4
|
+
* @param from - The source file format.
|
|
5
|
+
* @param to - The target file format.
|
|
6
|
+
* @returns True if the transformation is supported, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSupportedFileFormatTransform(from: FileFormat, to: FileFormat): boolean;
|