generaltranslation 8.2.5 → 8.2.7

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.
Files changed (161) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/ApiError-4zIP-twr.cjs +24 -0
  3. package/dist/ApiError-4zIP-twr.cjs.map +1 -0
  4. package/dist/ApiError-Bv7vlzyQ.mjs +19 -0
  5. package/dist/ApiError-Bv7vlzyQ.mjs.map +1 -0
  6. package/dist/errors.cjs +3 -0
  7. package/dist/errors.d.cts +11 -0
  8. package/dist/errors.d.mts +11 -0
  9. package/dist/errors.mjs +2 -0
  10. package/dist/id-CPbVYREY.mjs +74 -0
  11. package/dist/id-CPbVYREY.mjs.map +1 -0
  12. package/dist/id-VXBgyXu2.cjs +89 -0
  13. package/dist/id-VXBgyXu2.cjs.map +1 -0
  14. package/dist/id.cjs +5 -0
  15. package/dist/{id/hashSource.d.ts → id.d.cts} +20 -5
  16. package/dist/id.d.mts +40 -0
  17. package/dist/id.mjs +2 -0
  18. package/dist/index.cjs +3354 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.cts +1157 -0
  21. package/dist/index.d.mts +1157 -0
  22. package/dist/index.mjs +3305 -0
  23. package/dist/index.mjs.map +1 -0
  24. package/dist/internal-CTeI8uLd.mjs +774 -0
  25. package/dist/internal-CTeI8uLd.mjs.map +1 -0
  26. package/dist/internal-PCKq4YMW.cjs +1012 -0
  27. package/dist/internal-PCKq4YMW.cjs.map +1 -0
  28. package/dist/internal.cjs +43 -0
  29. package/dist/{internal.d.ts → internal.d.cts} +62 -114
  30. package/dist/internal.d.mts +242 -0
  31. package/dist/internal.mjs +3 -0
  32. package/dist/sha2-DKowBr6H.cjs +747 -0
  33. package/dist/sha2-DKowBr6H.cjs.map +1 -0
  34. package/dist/stableStringify-DgDlE_pD.mjs +53 -0
  35. package/dist/stableStringify-DgDlE_pD.mjs.map +1 -0
  36. package/dist/types-D2fTTTvZ.d.cts +737 -0
  37. package/dist/types-fUW4_Ole.d.mts +737 -0
  38. package/dist/types.cjs +17 -0
  39. package/dist/types.cjs.map +1 -0
  40. package/dist/types.d.cts +2 -0
  41. package/dist/types.d.mts +2 -0
  42. package/dist/types.mjs +16 -0
  43. package/dist/types.mjs.map +1 -0
  44. package/package.json +53 -35
  45. package/dist/backwards-compatability/dataConversion.d.ts +0 -23
  46. package/dist/backwards-compatability/oldHashJsxChildren.d.ts +0 -23
  47. package/dist/backwards-compatability/oldTypes.d.ts +0 -21
  48. package/dist/backwards-compatability/typeChecking.d.ts +0 -21
  49. package/dist/cache/IntlCache.d.ts +0 -26
  50. package/dist/cache/types.d.ts +0 -32
  51. package/dist/derive/condenseVars.d.ts +0 -7
  52. package/dist/derive/declareVar.d.ts +0 -26
  53. package/dist/derive/decodeVars.d.ts +0 -9
  54. package/dist/derive/derive.d.ts +0 -38
  55. package/dist/derive/extractVars.d.ts +0 -9
  56. package/dist/derive/index.d.ts +0 -7
  57. package/dist/derive/indexVars.d.ts +0 -6
  58. package/dist/derive/utils/constants.d.ts +0 -2
  59. package/dist/derive/utils/regex.d.ts +0 -2
  60. package/dist/derive/utils/sanitizeVar.d.ts +0 -12
  61. package/dist/derive/utils/traverseHelpers.d.ts +0 -4
  62. package/dist/derive/utils/traverseIcu.d.ts +0 -20
  63. package/dist/derive/utils/types.d.ts +0 -23
  64. package/dist/errors/ApiError.d.ts +0 -7
  65. package/dist/errors/formattingErrors.d.ts +0 -1
  66. package/dist/errors.cjs.min.cjs +0 -2
  67. package/dist/errors.cjs.min.cjs.map +0 -1
  68. package/dist/errors.d.ts +0 -9
  69. package/dist/errors.esm.min.mjs +0 -2
  70. package/dist/errors.esm.min.mjs.map +0 -1
  71. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +0 -59
  72. package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +0 -4
  73. package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +0 -48
  74. package/dist/formatting/format.d.ts +0 -1
  75. package/dist/id/hashTemplate.d.ts +0 -4
  76. package/dist/id/types.d.ts +0 -7
  77. package/dist/id.cjs.min.cjs +0 -19
  78. package/dist/id.cjs.min.cjs.map +0 -1
  79. package/dist/id.d.ts +0 -86
  80. package/dist/id.esm.min.mjs +0 -19
  81. package/dist/id.esm.min.mjs.map +0 -1
  82. package/dist/index.cjs.min.cjs +0 -19
  83. package/dist/index.cjs.min.cjs.map +0 -1
  84. package/dist/index.d.ts +0 -1627
  85. package/dist/index.esm.min.mjs +0 -19
  86. package/dist/index.esm.min.mjs.map +0 -1
  87. package/dist/internal.cjs.min.cjs +0 -19
  88. package/dist/internal.cjs.min.cjs.map +0 -1
  89. package/dist/internal.esm.min.mjs +0 -19
  90. package/dist/internal.esm.min.mjs.map +0 -1
  91. package/dist/locales/customLocaleMapping.d.ts +0 -11
  92. package/dist/locales/determineLocale.d.ts +0 -1
  93. package/dist/locales/getLocaleDirection.d.ts +0 -1
  94. package/dist/locales/getLocaleEmoji.d.ts +0 -2
  95. package/dist/locales/getLocaleName.d.ts +0 -1
  96. package/dist/locales/getLocaleProperties.d.ts +0 -32
  97. package/dist/locales/getPluralForm.d.ts +0 -9
  98. package/dist/locales/getRegionProperties.d.ts +0 -7
  99. package/dist/locales/isSameDialect.d.ts +0 -1
  100. package/dist/locales/isSameLanguage.d.ts +0 -1
  101. package/dist/locales/isSupersetLocale.d.ts +0 -1
  102. package/dist/locales/isValidLocale.d.ts +0 -1
  103. package/dist/locales/requiresTranslation.d.ts +0 -1
  104. package/dist/locales/resolveAliasLocale.d.ts +0 -8
  105. package/dist/locales/resolveCanonicalLocale.d.ts +0 -8
  106. package/dist/logging/errors.d.ts +0 -10
  107. package/dist/logging/logger.d.ts +0 -117
  108. package/dist/logging/warnings.d.ts +0 -2
  109. package/dist/projects/getProjectData.d.ts +0 -1
  110. package/dist/settings/plurals.d.ts +0 -3
  111. package/dist/settings/settings.d.ts +0 -2
  112. package/dist/settings/settingsUrls.d.ts +0 -3
  113. package/dist/translate/api.d.ts +0 -1
  114. package/dist/translate/awaitJobs.d.ts +0 -19
  115. package/dist/translate/checkJobStatus.d.ts +0 -8
  116. package/dist/translate/createBranch.d.ts +0 -10
  117. package/dist/translate/createTag.d.ts +0 -19
  118. package/dist/translate/downloadFileBatch.d.ts +0 -1
  119. package/dist/translate/enqueueFiles.d.ts +0 -8
  120. package/dist/translate/getOrphanedFiles.d.ts +0 -8
  121. package/dist/translate/processFileMoves.d.ts +0 -25
  122. package/dist/translate/publishFiles.d.ts +0 -17
  123. package/dist/translate/queryBranchData.d.ts +0 -3
  124. package/dist/translate/queryFileData.d.ts +0 -42
  125. package/dist/translate/querySourceFile.d.ts +0 -1
  126. package/dist/translate/setupProject.d.ts +0 -11
  127. package/dist/translate/submitUserEditDiffs.d.ts +0 -12
  128. package/dist/translate/translateMany.d.ts +0 -1
  129. package/dist/translate/uploadSourceFiles.d.ts +0 -1
  130. package/dist/translate/uploadTranslations.d.ts +0 -1
  131. package/dist/translate/utils/apiRequest.d.ts +0 -1
  132. package/dist/translate/utils/batch.d.ts +0 -52
  133. package/dist/translate/utils/fetchWithTimeout.d.ts +0 -1
  134. package/dist/translate/utils/generateRequestHeaders.d.ts +0 -2
  135. package/dist/translate/utils/handleFetchError.d.ts +0 -1
  136. package/dist/translate/utils/validateResponse.d.ts +0 -1
  137. package/dist/types-dir/api/branch.d.ts +0 -10
  138. package/dist/types-dir/api/checkFileTranslations.d.ts +0 -37
  139. package/dist/types-dir/api/downloadFile.d.ts +0 -3
  140. package/dist/types-dir/api/downloadFileBatch.d.ts +0 -34
  141. package/dist/types-dir/api/enqueueEntries.d.ts +0 -21
  142. package/dist/types-dir/api/enqueueFiles.d.ts +0 -56
  143. package/dist/types-dir/api/entry.d.ts +0 -36
  144. package/dist/types-dir/api/fetchTranslations.d.ts +0 -11
  145. package/dist/types-dir/api/file.d.ts +0 -54
  146. package/dist/types-dir/api/project.d.ts +0 -7
  147. package/dist/types-dir/api/translate.d.ts +0 -34
  148. package/dist/types-dir/api/translateMany.d.ts +0 -5
  149. package/dist/types-dir/api/translationStatus.d.ts +0 -9
  150. package/dist/types-dir/api/uploadFiles.d.ts +0 -43
  151. package/dist/types-dir/jsx/content.d.ts +0 -61
  152. package/dist/types-dir/jsx/variables.d.ts +0 -9
  153. package/dist/types-dir/transformations.d.ts +0 -8
  154. package/dist/types.cjs.min.cjs +0 -2
  155. package/dist/types.cjs.min.cjs.map +0 -1
  156. package/dist/types.d.ts +0 -652
  157. package/dist/types.esm.min.mjs +0 -2
  158. package/dist/types.esm.min.mjs.map +0 -1
  159. package/dist/utils/base64.d.ts +0 -2
  160. package/dist/utils/isVariable.d.ts +0 -2
  161. package/dist/utils/minify.d.ts +0 -2
@@ -0,0 +1,1157 @@
1
+ import { $ as FileReference, A as BranchDataResult, B as FileUpload, C as ProcessMovesOptions, D as FileDataQuery, Dt as StringFormat, F as DownloadFileOptions, H as UploadFilesResponse, I as PublishFileEntry, J as DownloadFileBatchOptions, L as PublishFilesResult, M as TranslationError, Mt as CustomMapping, N as TranslationResult, O as FileDataResult, T as GetOrphanedFilesResult, U as CreateTagOptions, V as UploadFilesOptions, W as CreateTagResult, X as DownloadFileBatchResult, Y as DownloadFileBatchRequest, _ as AwaitJobsResult, at as CheckFileTranslationsOptions, et as FileReferenceIds, g as AwaitJobsOptions, h as SubmitUserEditDiffsPayload, j as TranslateManyResult, jt as LocaleProperties, k as BranchQuery, mt as TranslateOptions, n as FormatVariables, ot as FileQuery, pt as TranslateManyEntry, rt as EnqueueFilesResult, st as FileQueryResult, w as ProcessMovesResponse, x as MoveMapping, y as CheckJobStatusResult } from "./types-D2fTTTvZ.cjs";
2
+
3
+ //#region src/translate/setupProject.d.ts
4
+ type SetupProjectResult = {
5
+ setupJobId: string;
6
+ status: 'queued';
7
+ } | {
8
+ status: 'completed';
9
+ };
10
+ type SetupProjectOptions = {
11
+ force?: boolean;
12
+ locales?: string[];
13
+ timeoutMs?: number;
14
+ };
15
+ //#endregion
16
+ //#region src/translate/enqueueFiles.d.ts
17
+ type EnqueueOptions = {
18
+ sourceLocale?: string;
19
+ targetLocales: string[];
20
+ requireApproval?: boolean;
21
+ modelProvider?: string;
22
+ force?: boolean;
23
+ timeout?: number;
24
+ };
25
+ //#endregion
26
+ //#region src/locales/getRegionProperties.d.ts
27
+ type CustomRegionMapping = {
28
+ [region: string]: {
29
+ name?: string;
30
+ emoji?: string;
31
+ locale?: string;
32
+ };
33
+ };
34
+ //#endregion
35
+ //#region src/types-dir/api/project.d.ts
36
+ type ProjectData = {
37
+ id: string;
38
+ name: string;
39
+ orgId: string;
40
+ defaultLocale: string;
41
+ currentLocales: string[];
42
+ };
43
+ //#endregion
44
+ //#region src/translate/createBranch.d.ts
45
+ type CreateBranchQuery = {
46
+ branchName: string;
47
+ defaultBranch: boolean;
48
+ };
49
+ type CreateBranchResult = {
50
+ branch: {
51
+ id: string;
52
+ name: string;
53
+ };
54
+ };
55
+ //#endregion
56
+ //#region src/formatting/custom-formats/CutoffFormat/types.d.ts
57
+ /** Type of terminator */
58
+ type CutoffFormatStyle = 'none' | 'ellipsis';
59
+ /** Terminator options */
60
+ interface TerminatorOptions {
61
+ /** The terminator to use */
62
+ terminator?: string;
63
+ /** An optional separator between the terminator and the value */
64
+ separator?: string;
65
+ }
66
+ /** Input formatting options (for constructor) */
67
+ interface CutoffFormatOptions extends TerminatorOptions {
68
+ /** Cutoff length */
69
+ maxChars?: number;
70
+ /** Type of terminator */
71
+ style?: CutoffFormatStyle;
72
+ }
73
+ //#endregion
74
+ //#region src/index.d.ts
75
+ /**
76
+ * Type representing the constructor parameters for the GT class.
77
+ * @typedef {Object} GTConstructorParams
78
+ * @property {string} [apiKey] - The API key for accessing the translation service
79
+ * @property {string} [devApiKey] - The development API key for accessing the translation service
80
+ * @property {string} [sourceLocale] - The default source locale for translations
81
+ * @property {string} [targetLocale] - The default target locale for translations
82
+ * @property {string[]} [locales] - Array of supported locales
83
+ * @property {string} [projectId] - The project ID for the translation service
84
+ * @property {string} [baseUrl] - The base URL for the translation service
85
+ * @property {CustomMapping} [customMapping] - Custom mapping of locale codes to their names
86
+ */
87
+ type GTConstructorParams = {
88
+ apiKey?: string;
89
+ devApiKey?: string;
90
+ sourceLocale?: string;
91
+ targetLocale?: string;
92
+ locales?: string[];
93
+ projectId?: string;
94
+ baseUrl?: string;
95
+ customMapping?: CustomMapping;
96
+ };
97
+ /**
98
+ * GT is the core driver for the General Translation library.
99
+ * This class provides functionality for locale management, formatting, and translation operations.
100
+ *
101
+ * @class GT
102
+ * @description A comprehensive toolkit for handling internationalization and localization.
103
+ *
104
+ * @example
105
+ * const gt = new GT({
106
+ * sourceLocale: 'en-US',
107
+ * targetLocale: 'es-ES',
108
+ * locales: ['en-US', 'es-ES', 'fr-FR']
109
+ * });
110
+ */
111
+ declare class GT {
112
+ /** Base URL for the translation service API */
113
+ baseUrl?: string;
114
+ /** Project ID for the translation service */
115
+ projectId?: string;
116
+ /** API key for accessing the translation service */
117
+ apiKey?: string;
118
+ /** Development API key for accessing the translation service */
119
+ devApiKey?: string;
120
+ /** Source locale for translations */
121
+ sourceLocale?: string;
122
+ /** Target locale for translations */
123
+ targetLocale?: string;
124
+ /** Array of supported locales */
125
+ locales?: string[];
126
+ /** Array of locales used for rendering variables */
127
+ _renderingLocales: string[];
128
+ /** Custom mapping for locale codes to their names */
129
+ customMapping?: CustomMapping;
130
+ /** Lazily derived reverse custom mapping for alias locales */
131
+ reverseCustomMapping?: Record<string, string>;
132
+ /** Lazily derived custom mapping for regions */
133
+ customRegionMapping?: CustomRegionMapping;
134
+ /**
135
+ * Constructs an instance of the GT class.
136
+ *
137
+ * @param {GTConstructorParams} [params] - The parameters for initializing the GT instance
138
+ * @throws {Error} If an invalid locale is provided
139
+ * @throws {Error} If any of the provided locales are invalid
140
+ *
141
+ * @example
142
+ * const gt = new GT({
143
+ * apiKey: 'your-api-key',
144
+ * sourceLocale: 'en-US',
145
+ * targetLocale: 'es-ES',
146
+ * locales: ['en-US', 'es-ES', 'fr-FR']
147
+ * });
148
+ */
149
+ constructor(params?: GTConstructorParams);
150
+ setConfig({
151
+ apiKey,
152
+ devApiKey,
153
+ sourceLocale,
154
+ targetLocale,
155
+ locales,
156
+ projectId,
157
+ customMapping,
158
+ baseUrl
159
+ }: GTConstructorParams): void;
160
+ private _getTranslationConfig;
161
+ private _validateAuth;
162
+ /**
163
+ * Queries branch information from the API.
164
+ *
165
+ * @param {BranchQuery} query - Object mapping the current branch and incoming branches
166
+ * @returns {Promise<BranchDataResult>} The branch information
167
+ */
168
+ queryBranchData(query: BranchQuery): Promise<BranchDataResult>;
169
+ /**
170
+ * Creates a new branch in the API. If the branch already exists, it will be returned.
171
+ *
172
+ * @param {CreateBranchQuery} query - Object mapping the branch name and default branch flag
173
+ * @returns {Promise<CreateBranchResult>} The created branch information
174
+ */
175
+ createBranch(query: CreateBranchQuery): Promise<CreateBranchResult>;
176
+ /**
177
+ * Processes file moves by cloning source files and translations with new fileIds.
178
+ * This is called when files have been moved/renamed and we want to preserve translations.
179
+ *
180
+ * @param {MoveMapping[]} moves - Array of move mappings (old fileId to new fileId)
181
+ * @param {ProcessMovesOptions} options - Options including branchId and timeout
182
+ * @returns {Promise<ProcessMovesResponse>} The move processing results
183
+ *
184
+ * @example
185
+ * const result = await gt.processFileMoves([
186
+ * { oldFileId: 'abc123', newFileId: 'def456', newFileName: 'locales/en.json' }
187
+ * ], { branchId: 'main' });
188
+ */
189
+ processFileMoves(moves: MoveMapping[], options?: ProcessMovesOptions): Promise<ProcessMovesResponse>;
190
+ /**
191
+ * Gets orphaned files for a branch - files that exist on the branch
192
+ * but whose fileIds are not in the provided list.
193
+ * Used for move detection.
194
+ *
195
+ * @param {string} branchId - The branch to check for orphaned files
196
+ * @param {string[]} fileIds - List of current file IDs (files that are NOT orphaned)
197
+ * @param {Object} options - Options including timeout
198
+ * @returns {Promise<GetOrphanedFilesResult>} The orphaned files
199
+ *
200
+ * @example
201
+ * const result = await gt.getOrphanedFiles('branch-id', ['file-1', 'file-2']);
202
+ */
203
+ getOrphanedFiles(branchId: string, fileIds: string[], options?: {
204
+ timeout?: number;
205
+ }): Promise<GetOrphanedFilesResult>;
206
+ /**
207
+ * Enqueues project setup job using the specified file references
208
+ *
209
+ * This method creates setup jobs that will process source file references
210
+ * and generate a project setup. The files parameter contains references (IDs) to source
211
+ * files that have already been uploaded via uploadSourceFiles. The setup jobs are queued
212
+ * for processing and will generate a project setup based on the source files.
213
+ *
214
+ * @param {FileReference[]} files - Array of file references containing IDs of previously uploaded source files
215
+ * @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout
216
+ * @returns {Promise<SetupProjectResult>} Object containing the jobId and status
217
+ */
218
+ setupProject(files: FileReference[], options?: SetupProjectOptions): Promise<SetupProjectResult>;
219
+ /**
220
+ * Checks the current status of one or more project jobs by their unique identifiers.
221
+ *
222
+ * This method polls the API to determine whether one or more jobs are still running,
223
+ * have completed successfully, or have failed. Jobs are created after calling either enqueueFiles or setupProject.
224
+ *
225
+ * @param {string[]} jobIds - The unique identifiers of the jobs to check
226
+ * @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request
227
+ * @returns {Promise<CheckJobStatusResult>} Object containing the job status
228
+ *
229
+ * @example
230
+ * const result = await gt.checkJobStatus([
231
+ * 'job-123',
232
+ * 'job-456',
233
+ * ], {
234
+ * timeout: 10000,
235
+ * });
236
+ */
237
+ checkJobStatus(jobIds: string[], timeoutMs?: number): Promise<CheckJobStatusResult>;
238
+ /**
239
+ * Polls job statuses until all jobs from enqueueFiles are finished or the timeout is reached.
240
+ *
241
+ * @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles
242
+ * @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout)
243
+ * @returns {Promise<AwaitJobsResult>} The final status of all jobs and whether they all completed
244
+ */
245
+ awaitJobs(enqueueResult: EnqueueFilesResult, options?: AwaitJobsOptions): Promise<AwaitJobsResult>;
246
+ /**
247
+ * Enqueues translation jobs for previously uploaded source files.
248
+ *
249
+ * This method creates translation jobs that will process existing source files
250
+ * and generate translations in the specified target languages. The files parameter
251
+ * contains references (IDs) to source files that have already been uploaded via
252
+ * uploadSourceFiles. The translation jobs are queued for processing and will
253
+ * generate translated content based on the source files and target locales provided.
254
+ *
255
+ * @param {FileReferenceIds[]} files - Array of file references containing IDs of previously uploaded source files
256
+ * @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings
257
+ * @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information
258
+ */
259
+ enqueueFiles(files: FileReferenceIds[], options: EnqueueOptions): Promise<EnqueueFilesResult>;
260
+ /**
261
+ * Creates or upserts a file tag, associating a set of source files
262
+ * with a user-defined tag ID and optional message.
263
+ *
264
+ * @param {CreateTagOptions} options - Tag creation options including tagId, sourceFileIds, and optional message
265
+ * @returns {Promise<CreateTagResult>} The created or updated tag
266
+ */
267
+ createTag(options: CreateTagOptions): Promise<CreateTagResult>;
268
+ /**
269
+ * Publishes or unpublishes files on the CDN.
270
+ *
271
+ * @param {PublishFileEntry[]} files - Array of file entries with publish flags
272
+ * @returns {Promise<PublishFilesResult>} Result containing per-file success/failure
273
+ */
274
+ publishFiles(files: PublishFileEntry[]): Promise<PublishFilesResult>;
275
+ /**
276
+ * Submits user edit diffs for existing translations so future generations preserve user intent.
277
+ *
278
+ * @param {SubmitUserEditDiffsPayload} payload - Project-scoped diff payload.
279
+ * @returns {Promise<void>} Resolves when submission succeeds.
280
+ */
281
+ submitUserEditDiffs(payload: SubmitUserEditDiffsPayload): Promise<void>;
282
+ /**
283
+ * Queries data about one or more source or translation files.
284
+ *
285
+ * @param {FileDataQuery} data - Object mapping source and translation file information.
286
+ * @param {CheckFileTranslationsOptions} options - Options for the API call.
287
+ * @returns {Promise<FileDataResult>} The source and translation file data information.
288
+ *
289
+ * @example
290
+ * const result = await gt.queryFileData({
291
+ * sourceFiles: [
292
+ * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890' },
293
+ * ],
294
+ * translatedFiles: [
295
+ * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890', locale: 'es-ES' },
296
+ * ],
297
+ * }, {
298
+ * timeout: 10000,
299
+ * });
300
+ *
301
+ */
302
+ queryFileData(data: FileDataQuery, options?: CheckFileTranslationsOptions): Promise<FileDataResult>;
303
+ /**
304
+ * Gets source and translation information for a given file ID and version ID.
305
+ *
306
+ * @param {FileQuery} data - File query containing file ID and version ID.
307
+ * @param {CheckFileTranslationsOptions} options - Options for getting source and translation information.
308
+ * @returns {Promise<FileQueryResult>} The source file and translation information.
309
+ *
310
+ * @example
311
+ * const result = await gt.querySourceFile(
312
+ * { fileId: '1234567890', versionId: '1234567890' },
313
+ * { timeout: 10000 }
314
+ * );
315
+ *
316
+ */
317
+ querySourceFile(data: FileQuery, options?: CheckFileTranslationsOptions): Promise<FileQueryResult>;
318
+ /**
319
+ * Get project data for a given project ID.
320
+ *
321
+ * @param {string} projectId - The ID of the project to get the data for.
322
+ * @returns {Promise<ProjectData>} The project data.
323
+ *
324
+ * @example
325
+ * const result = await gt.getProjectData(
326
+ * '1234567890'
327
+ * );
328
+ *
329
+ */
330
+ getProjectData(projectId: string, options?: {
331
+ timeout?: number;
332
+ }): Promise<ProjectData>;
333
+ /**
334
+ * Downloads a single file.
335
+ *
336
+ * @param file - The file query object.
337
+ * @param {string} file.fileId - The ID of the file to download.
338
+ * @param {string} [file.branchId] - The ID of the branch to download the file from. If not provided, the default branch will be used.
339
+ * @param {string} [file.locale] - The locale to download the file for. If not provided, the source file will be downloaded.
340
+ * @param {string} [file.versionId] - The version ID to download the file from. If not provided, the latest version will be used.
341
+ * @param {DownloadFileOptions} options - Options for downloading the file.
342
+ * @returns {Promise<string>} The downloaded file content.
343
+ *
344
+ * @example
345
+ * const result = await gt.downloadFile({
346
+ * fileId: '1234567890',
347
+ * branchId: '1234567890',
348
+ * locale: 'es-ES',
349
+ * versionId: '1234567890',
350
+ * }, {
351
+ * timeout: 10000,
352
+ * });
353
+ */
354
+ downloadFile(file: {
355
+ fileId: string;
356
+ branchId?: string;
357
+ locale?: string;
358
+ versionId?: string;
359
+ useLatestAvailableVersion?: boolean;
360
+ }, options?: DownloadFileOptions): Promise<string>;
361
+ /**
362
+ * Downloads multiple files in a batch.
363
+ *
364
+ * @param {DownloadFileBatchRequest} requests - Array of file query objects to download.
365
+ * @param {DownloadFileBatchOptions} options - Options for the batch download.
366
+ * @returns {Promise<DownloadFileBatchResult>} The batch download results.
367
+ *
368
+ * @example
369
+ * const result = await gt.downloadFileBatch([{
370
+ * fileId: '1234567890',
371
+ * locale: 'es-ES',
372
+ * versionId: '1234567890',
373
+ * }], {
374
+ * timeout: 10000,
375
+ * });
376
+ */
377
+ downloadFileBatch(requests: DownloadFileBatchRequest, options?: DownloadFileBatchOptions): Promise<DownloadFileBatchResult>;
378
+ /**
379
+ * Translates a single source string to the target locale.
380
+ * Routes through {@link translateMany} under the hood.
381
+ *
382
+ * @param {string} source - The source string to translate.
383
+ * @param {object} options - Translation options including targetLocale and optional entry metadata.
384
+ * @returns {Promise<TranslationResult | TranslationError>} The translated content.
385
+ *
386
+ * @example
387
+ * const result = await gt.translate('Hello, world!', { targetLocale: 'es' });
388
+ *
389
+ * @example
390
+ * const result = await gt.translate('Hello, world!', {
391
+ * targetLocale: 'es',
392
+ * dataFormat: 'ICU',
393
+ * context: 'A formal greeting',
394
+ * });
395
+ */
396
+ translate(source: TranslateManyEntry, options: string | TranslateOptions, timeout?: number): Promise<TranslationResult | TranslationError>;
397
+ /**
398
+ * Translates multiple source strings to the target locale.
399
+ * Each entry can be a plain string or an object with source and metadata fields.
400
+ *
401
+ * @param {TranslateManyEntry[] | Record<string, TranslateManyEntry>} sources - The source entries to translate. Can be an array or a record keyed by hash.
402
+ * @param {object} options - Translation options including targetLocale.
403
+ * @returns {Promise<TranslateManyResult | Record<string, TranslationResult>>} The translated contents. An array if sources was an array, a record if sources was a record.
404
+ *
405
+ * @example
406
+ * const result = await gt.translateMany(
407
+ * ['Hello, world!', 'Goodbye, world!'],
408
+ * { targetLocale: 'es' }
409
+ * );
410
+ *
411
+ * @example
412
+ * const result = await gt.translateMany(
413
+ * [{ source: 'Hello, world!', dataFormat: 'ICU' }],
414
+ * { targetLocale: 'es' }
415
+ * );
416
+ *
417
+ * @example
418
+ * const result = await gt.translateMany(
419
+ * { 'my-hash': 'Hello, world!' },
420
+ * { targetLocale: 'es' }
421
+ * );
422
+ */
423
+ translateMany(sources: TranslateManyEntry[], options: string | TranslateOptions, timeout?: number): Promise<TranslateManyResult>;
424
+ translateMany(sources: Record<string, TranslateManyEntry>, options: string | TranslateOptions, timeout?: number): Promise<Record<string, TranslationResult>>;
425
+ /**
426
+ * Uploads source files to the translation service without any translation content.
427
+ *
428
+ * This method creates or replaces source file entries in your project. Each uploaded
429
+ * file becomes a source that can later be translated into target languages. The files
430
+ * are processed and stored as base entries that serve as the foundation for generating
431
+ * translations through the translation workflow.
432
+ *
433
+ * @param {Array<{source: FileUpload}>} files - Array of objects containing source file data to upload
434
+ * @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings
435
+ * @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status
436
+ */
437
+ uploadSourceFiles(files: {
438
+ source: FileUpload;
439
+ }[], options: UploadFilesOptions): Promise<UploadFilesResponse>;
440
+ /**
441
+ * Uploads translation files that correspond to previously uploaded source files.
442
+ *
443
+ * This method allows you to provide translated content for existing source files in your project.
444
+ * Each translation must reference an existing source file and include the translated content
445
+ * along with the target locale information. This is used when you have pre-existing translations
446
+ * that you want to upload directly rather than generating them through the translation service.
447
+ *
448
+ * @param {Array<{source: FileUpload, translations: FileUpload[]}>} files - Array of file objects where:
449
+ * - `source`: Reference to the existing source file (contains IDs but no content)
450
+ * - `translations`: Array of translated files, each containing content, locale, and reference IDs
451
+ * @param {UploadFilesOptions} options - Configuration options including source locale and upload settings
452
+ * @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information
453
+ */
454
+ uploadTranslations(files: {
455
+ source: FileUpload;
456
+ translations: FileUpload[];
457
+ }[], options: UploadFilesOptions): Promise<UploadFilesResponse>;
458
+ /**
459
+ * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
460
+ *
461
+ * This method uses the GT instance's rendering locales by default for locale-specific terminator selection,
462
+ * but can be overridden with custom locales in the options.
463
+ *
464
+ * @param {string} value - The string value to format with cutoff behavior.
465
+ * @param {Object} [options] - Configuration options for cutoff formatting.
466
+ * @param {string | string[]} [options.locales] - The locales to use for terminator selection. Defaults to instance's rendering locales.
467
+ * @param {number} [options.maxChars] - The maximum number of characters to display.
468
+ * - Undefined values are treated as no cutoff.
469
+ * - Negative values follow .slice() behavior and terminator will be added before the value.
470
+ * - 0 will result in an empty string.
471
+ * - If cutoff results in an empty string, no terminator is added.
472
+ * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
473
+ * @param {string} [options.terminator] - Optional override the terminator to use.
474
+ * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
475
+ * - If no terminator is provided, then separator is ignored.
476
+ * @returns {string} The formatted string with terminator applied if cutoff occurs.
477
+ *
478
+ * @example
479
+ * const gt = new GT({ targetLocale: 'en-US' });
480
+ * gt.formatCutoff('Hello, world!', { maxChars: 8 });
481
+ * // Returns: 'Hello, w...'
482
+ *
483
+ * @example
484
+ * gt.formatCutoff('Hello, world!', { maxChars: -3 });
485
+ * // Returns: '...ld!'
486
+ */
487
+ formatCutoff(value: string, options?: {
488
+ locales?: string | string[];
489
+ } & CutoffFormatOptions): string;
490
+ /**
491
+ * Formats a message according to the specified locales and options.
492
+ *
493
+ * @param {string} message - The message to format.
494
+ * @param {string | string[]} [locales='en'] - The locales to use for formatting.
495
+ * @param {FormatVariables} [variables={}] - The variables to use for formatting.
496
+ * @param {StringFormat} [dataFormat='ICU'] - The format of the message.
497
+ * @returns {string} The formatted message.
498
+ *
499
+ * @example
500
+ * gt.formatMessage('Hello {name}', { name: 'John' });
501
+ * // Returns: "Hello John"
502
+ *
503
+ * gt.formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });
504
+ * // Returns: "Bonjour John"
505
+ */
506
+ formatMessage(message: string, options?: {
507
+ locales?: string | string[];
508
+ variables?: FormatVariables;
509
+ dataFormat?: StringFormat;
510
+ }): string;
511
+ /**
512
+ * Formats a number according to the specified locales and options.
513
+ *
514
+ * @param {number} number - The number to format
515
+ * @param {Object} [options] - Additional options for number formatting
516
+ * @param {string | string[]} [options.locales] - The locales to use for formatting
517
+ * @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options
518
+ * @returns {string} The formatted number
519
+ *
520
+ * @example
521
+ * gt.formatNum(1234.56, { style: 'currency', currency: 'USD' });
522
+ * // Returns: "$1,234.56"
523
+ */
524
+ formatNum(number: number, options?: {
525
+ locales?: string | string[];
526
+ } & Intl.NumberFormatOptions): string;
527
+ /**
528
+ * Formats a date according to the specified locales and options.
529
+ *
530
+ * @param {Date} date - The date to format
531
+ * @param {Object} [options] - Additional options for date formatting
532
+ * @param {string | string[]} [options.locales] - The locales to use for formatting
533
+ * @param {Intl.DateTimeFormatOptions} [options] - Additional Intl.DateTimeFormat options
534
+ * @returns {string} The formatted date
535
+ *
536
+ * @example
537
+ * gt.formatDateTime(new Date(), { dateStyle: 'full', timeStyle: 'long' });
538
+ * // Returns: "Thursday, March 14, 2024 at 2:30:45 PM GMT-7"
539
+ */
540
+ formatDateTime(date: Date, options?: {
541
+ locales?: string | string[];
542
+ } & Intl.DateTimeFormatOptions): string;
543
+ /**
544
+ * Formats a currency value according to the specified locales and options.
545
+ *
546
+ * @param {number} value - The currency value to format
547
+ * @param {string} currency - The currency code (e.g., 'USD', 'EUR')
548
+ * @param {Object} [options] - Additional options for currency formatting
549
+ * @param {string | string[]} [options.locales] - The locales to use for formatting
550
+ * @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options
551
+ * @returns {string} The formatted currency value
552
+ *
553
+ * @example
554
+ * gt.formatCurrency(1234.56, 'USD', { style: 'currency' });
555
+ * // Returns: "$1,234.56"
556
+ */
557
+ formatCurrency(value: number, currency: string, options?: {
558
+ locales?: string | string[];
559
+ } & Intl.NumberFormatOptions): string;
560
+ /**
561
+ * Formats a list of items according to the specified locales and options.
562
+ *
563
+ * @param {Array<string | number>} array - The list of items to format
564
+ * @param {Object} [options] - Additional options for list formatting
565
+ * @param {string | string[]} [options.locales] - The locales to use for formatting
566
+ * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
567
+ * @returns {string} The formatted list
568
+ *
569
+ * @example
570
+ * gt.formatList(['apple', 'banana', 'orange'], { type: 'conjunction' });
571
+ * // Returns: "apple, banana, and orange"
572
+ */
573
+ formatList(array: Array<string | number>, options?: {
574
+ locales?: string | string[];
575
+ } & Intl.ListFormatOptions): string;
576
+ /**
577
+ * Formats a list of items according to the specified locales and options.
578
+ * @param {Array<T>} array - The list of items to format
579
+ * @param {Object} [options] - Additional options for list formatting
580
+ * @param {string | string[]} [options.locales] - The locales to use for formatting
581
+ * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
582
+ * @returns {Array<T | string>} The formatted list parts
583
+ *
584
+ * @example
585
+ * gt.formatListToParts(['apple', 42, { foo: 'bar' }], { type: 'conjunction', style: 'short', locales: ['en'] });
586
+ * // Returns: ['apple', ', ', 42, ' and ', '{ foo: "bar" }']
587
+ */
588
+ formatListToParts<T>(array: Array<T>, options?: {
589
+ locales?: string | string[];
590
+ } & Intl.ListFormatOptions): Array<T | string>;
591
+ /**
592
+ * Formats a relative time value according to the specified locales and options.
593
+ *
594
+ * @param {number} value - The relative time value to format
595
+ * @param {Intl.RelativeTimeFormatUnit} unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year')
596
+ * @param {Object} options - Additional options for relative time formatting
597
+ * @param {string | string[]} [options.locales] - The locales to use for formatting
598
+ * @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options
599
+ * @returns {string} The formatted relative time string
600
+ *
601
+ * @example
602
+ * gt.formatRelativeTime(-1, 'day', { locales: ['en-US'], numeric: 'auto' });
603
+ * // Returns: "yesterday"
604
+ */
605
+ formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, options?: {
606
+ locales?: string | string[];
607
+ } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>): string;
608
+ /**
609
+ * Formats a relative time string from a Date, automatically selecting the best unit.
610
+ *
611
+ * @param {Date} date - The date to format relative to now
612
+ * @param {Object} [options] - Additional options for relative time formatting
613
+ * @param {string | string[]} [options.locales] - The locales to use for formatting
614
+ * @returns {string} The formatted relative time string (e.g., "2 hours ago", "in 3 days")
615
+ *
616
+ * @example
617
+ * gt.formatRelativeTimeFromDate(new Date(Date.now() - 3600000));
618
+ * // Returns: "1 hour ago"
619
+ */
620
+ formatRelativeTimeFromDate(date: Date, options?: {
621
+ locales?: string | string[];
622
+ baseDate?: Date;
623
+ } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>): string;
624
+ /**
625
+ * Retrieves the display name of a locale code using Intl.DisplayNames, returning an empty string if no name is found.
626
+ *
627
+ * @param {string} [locale=this.targetLocale] - A BCP-47 locale code
628
+ * @returns {string} The display name corresponding to the code
629
+ * @throws {Error} If no target locale is provided
630
+ *
631
+ * @example
632
+ * gt.getLocaleName('es-ES');
633
+ * // Returns: "Spanish (Spain)"
634
+ */
635
+ getLocaleName(locale?: string | undefined): string;
636
+ /**
637
+ * Retrieves an emoji based on a given locale code.
638
+ * Uses the locale's region (if present) to select an emoji or falls back on default emojis.
639
+ *
640
+ * @param {string} [locale=this.targetLocale] - A BCP-47 locale code (e.g., 'en-US', 'fr-CA')
641
+ * @returns {string} The emoji representing the locale or its region
642
+ * @throws {Error} If no target locale is provided
643
+ *
644
+ * @example
645
+ * gt.getLocaleEmoji('es-ES');
646
+ * // Returns: "🇪🇸"
647
+ */
648
+ getLocaleEmoji(locale?: string | undefined): string;
649
+ /**
650
+ * Generates linguistic details for a given locale code.
651
+ *
652
+ * This function returns information about the locale,
653
+ * script, and region of a given language code both in a standard form and in a maximized form (with likely script and region).
654
+ * The function provides these names in both your default language and native forms, and an associated emoji.
655
+ *
656
+ * @param {string} [locale=this.targetLocale] - The locale code to get properties for (e.g., "de-AT").
657
+ * @returns {LocaleProperties} - An object containing detailed information about the locale.
658
+ *
659
+ * @property {string} code - The full locale code, e.g., "de-AT".
660
+ * @property {string} name - Language name in the default display language, e.g., "Austrian German".
661
+ * @property {string} nativeName - Language name in the locale's native language, e.g., "Österreichisches Deutsch".
662
+ * @property {string} languageCode - The base language code, e.g., "de".
663
+ * @property {string} languageName - The language name in the default display language, e.g., "German".
664
+ * @property {string} nativeLanguageName - The language name in the native language, e.g., "Deutsch".
665
+ * @property {string} nameWithRegionCode - Language name with region in the default language, e.g., "German (AT)".
666
+ * @property {string} nativeNameWithRegionCode - Language name with region in the native language, e.g., "Deutsch (AT)".
667
+ * @property {string} regionCode - The region code from maximization, e.g., "AT".
668
+ * @property {string} regionName - The region name in the default display language, e.g., "Austria".
669
+ * @property {string} nativeRegionName - The region name in the native language, e.g., "Österreich".
670
+ * @property {string} scriptCode - The script code from maximization, e.g., "Latn".
671
+ * @property {string} scriptName - The script name in the default display language, e.g., "Latin".
672
+ * @property {string} nativeScriptName - The script name in the native language, e.g., "Lateinisch".
673
+ * @property {string} maximizedCode - The maximized locale code, e.g., "de-Latn-AT".
674
+ * @property {string} maximizedName - Maximized locale name with likely script in the default language, e.g., "Austrian German (Latin)".
675
+ * @property {string} nativeMaximizedName - Maximized locale name in the native language, e.g., "Österreichisches Deutsch (Lateinisch)".
676
+ * @property {string} minimizedCode - Minimized locale code, e.g., "de-AT" (or "de" for "de-DE").
677
+ * @property {string} minimizedName - Minimized language name in the default language, e.g., "Austrian German".
678
+ * @property {string} nativeMinimizedName - Minimized language name in the native language, e.g., "Österreichisches Deutsch".
679
+ * @property {string} emoji - The emoji associated with the locale's region, if applicable.
680
+ */
681
+ getLocaleProperties(locale?: string | undefined): LocaleProperties;
682
+ /**
683
+ * Retrieves multiple properties for a given region code, including:
684
+ * - `code`: the original region code
685
+ * - `name`: the localized display name
686
+ * - `emoji`: the associated flag or symbol
687
+ *
688
+ * Behavior:
689
+ * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `"US"`, `"FR"`, `"419"`).
690
+ * - Uses the instance's `targetLocale` to localize the region name for the user.
691
+ * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.
692
+ * - Otherwise, uses `Intl.DisplayNames` to get the localized region name, falling back to `libraryDefaultLocale`.
693
+ * - Falls back to the region code as `name` if display name resolution fails.
694
+ * - Falls back to a default emoji if no emoji mapping is found in built-in data or `customMapping`.
695
+ *
696
+ * @param {string} [region=this.getLocaleProperties().regionCode] - The region code to look up (e.g., `"US"`, `"GB"`, `"DE"`).
697
+ * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.
698
+ * @returns {{ code: string, name: string, emoji: string }} An object containing:
699
+ * - `code`: the input region code
700
+ * - `name`: the localized or custom region name
701
+ * - `emoji`: the matching emoji flag or symbol
702
+ *
703
+ * @throws {Error} If no target locale is available to determine region properties.
704
+ *
705
+ * @example
706
+ * const gt = new GT({ targetLocale: 'en-US' });
707
+ * gt.getRegionProperties('US');
708
+ * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }
709
+ *
710
+ * @example
711
+ * const gt = new GT({ targetLocale: 'fr-FR' });
712
+ * gt.getRegionProperties('US');
713
+ * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }
714
+ *
715
+ * @example
716
+ * gt.getRegionProperties('US', { US: { name: 'USA', emoji: '🗽' } });
717
+ * // => { code: 'US', name: 'USA', emoji: '🗽' }
718
+ */
719
+ getRegionProperties(region?: string, customMapping?: CustomRegionMapping): {
720
+ code: string;
721
+ name: string;
722
+ emoji: string;
723
+ };
724
+ /**
725
+ * Determines whether a translation is required based on the source and target locales.
726
+ *
727
+ * @param {string} [sourceLocale=this.sourceLocale] - The locale code for the original content
728
+ * @param {string} [targetLocale=this.targetLocale] - The locale code to translate into
729
+ * @param {string[]} [approvedLocales=this.locales] - Optional array of approved target locales
730
+ * @returns {boolean} True if translation is required, false otherwise
731
+ * @throws {Error} If no source locale is provided
732
+ * @throws {Error} If no target locale is provided
733
+ *
734
+ * @example
735
+ * gt.requiresTranslation('en-US', 'es-ES');
736
+ * // Returns: true
737
+ */
738
+ requiresTranslation(sourceLocale?: string | undefined, targetLocale?: string | undefined, approvedLocales?: string[] | undefined, customMapping?: CustomMapping | undefined): boolean;
739
+ /**
740
+ * Determines the best matching locale from the provided approved locales list.
741
+ *
742
+ * @param {string | string[]} locales - A single locale or array of locales in preference order
743
+ * @param {string[]} [approvedLocales=this.locales] - Array of approved locales in preference order
744
+ * @returns {string | undefined} The best matching locale or undefined if no match is found
745
+ *
746
+ * @example
747
+ * gt.determineLocale(['fr-CA', 'fr-FR'], ['en-US', 'fr-FR', 'es-ES']);
748
+ * // Returns: "fr-FR"
749
+ */
750
+ determineLocale(locales: string | string[], approvedLocales?: string[] | undefined, customMapping?: CustomMapping | undefined): string | undefined;
751
+ /**
752
+ * Gets the text direction for a given locale code.
753
+ *
754
+ * @param {string} [locale=this.targetLocale] - A BCP-47 locale code
755
+ * @returns {'ltr' | 'rtl'} 'rtl' if the locale is right-to-left, otherwise 'ltr'
756
+ * @throws {Error} If no target locale is provided
757
+ *
758
+ * @example
759
+ * gt.getLocaleDirection('ar-SA');
760
+ * // Returns: "rtl"
761
+ */
762
+ getLocaleDirection(locale?: string | undefined): 'ltr' | 'rtl';
763
+ /**
764
+ * Checks if a given BCP 47 locale code is valid.
765
+ *
766
+ * @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate
767
+ * @param {customMapping} [customMapping=this.customMapping] - The custom mapping to use for validation
768
+ * @returns {boolean} True if the locale code is valid, false otherwise
769
+ * @throws {Error} If no target locale is provided
770
+ *
771
+ * @example
772
+ * gt.isValidLocale('en-US');
773
+ * // Returns: true
774
+ */
775
+ isValidLocale(locale?: string | undefined, customMapping?: CustomMapping | undefined): boolean;
776
+ /**
777
+ * Resolves the canonical locale for a given locale.
778
+ * @param locale - The locale to resolve the canonical locale for
779
+ * @param customMapping - The custom mapping to use for resolving the canonical locale
780
+ * @returns The canonical locale
781
+ */
782
+ resolveCanonicalLocale(locale?: string | undefined, customMapping?: CustomMapping | undefined): string;
783
+ /**
784
+ * Resolves the alias locale for a given locale.
785
+ * @param locale - The locale to resolve the alias locale for
786
+ * @param customMapping - The custom mapping to use for resolving the alias locale
787
+ * @returns The alias locale
788
+ */
789
+ resolveAliasLocale(locale: string, customMapping?: CustomMapping | undefined): string;
790
+ /**
791
+ * Standardizes a BCP 47 locale code to ensure correct formatting.
792
+ *
793
+ * @param {string} [locale=this.targetLocale] - The BCP 47 locale code to standardize
794
+ * @returns {string} The standardized locale code or empty string if invalid
795
+ * @throws {Error} If no target locale is provided
796
+ *
797
+ * @example
798
+ * gt.standardizeLocale('en_us');
799
+ * // Returns: "en-US"
800
+ */
801
+ standardizeLocale(locale?: string | undefined): string;
802
+ /**
803
+ * Checks if multiple BCP 47 locale codes represent the same dialect.
804
+ *
805
+ * @param {...(string | string[])} locales - The BCP 47 locale codes to compare
806
+ * @returns {boolean} True if all codes represent the same dialect, false otherwise
807
+ *
808
+ * @example
809
+ * gt.isSameDialect('en-US', 'en-GB');
810
+ * // Returns: false
811
+ *
812
+ * gt.isSameDialect('en', 'en-US');
813
+ * // Returns: true
814
+ */
815
+ isSameDialect(...locales: (string | string[])[]): boolean;
816
+ /**
817
+ * Checks if multiple BCP 47 locale codes represent the same language.
818
+ *
819
+ * @param {...(string | string[])} locales - The BCP 47 locale codes to compare
820
+ * @returns {boolean} True if all codes represent the same language, false otherwise
821
+ *
822
+ * @example
823
+ * gt.isSameLanguage('en-US', 'en-GB');
824
+ * // Returns: true
825
+ */
826
+ isSameLanguage(...locales: (string | string[])[]): boolean;
827
+ /**
828
+ * Checks if a locale is a superset of another locale.
829
+ *
830
+ * @param {string} superLocale - The locale to check if it is a superset
831
+ * @param {string} subLocale - The locale to check if it is a subset
832
+ * @returns {boolean} True if superLocale is a superset of subLocale, false otherwise
833
+ *
834
+ * @example
835
+ * gt.isSupersetLocale('en', 'en-US');
836
+ * // Returns: true
837
+ *
838
+ * gt.isSupersetLocale('en-US', 'en');
839
+ * // Returns: false
840
+ */
841
+ isSupersetLocale(superLocale: string, subLocale: string): boolean;
842
+ }
843
+ /**
844
+ * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
845
+ *
846
+ * This standalone function provides cutoff formatting functionality without requiring a GT instance.
847
+ * The locales parameter is required for proper terminator selection based on the target language.
848
+ *
849
+ * @param {string} value - The string value to format with cutoff behavior.
850
+ * @param {Object} [options] - Configuration options for cutoff formatting.
851
+ * @param {string | string[]} [options.locales] - The locales to use for terminator selection.
852
+ * @param {number} [options.maxChars] - The maximum number of characters to display.
853
+ * - Undefined values are treated as no cutoff.
854
+ * - Negative values follow .slice() behavior and terminator will be added before the value.
855
+ * - 0 will result in an empty string.
856
+ * - If cutoff results in an empty string, no terminator is added.
857
+ * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
858
+ * @param {string} [options.terminator] - Optional override the terminator to use.
859
+ * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
860
+ * - If no terminator is provided, then separator is ignored.
861
+ * @returns {string} The formatted string with terminator applied if cutoff occurs.
862
+ *
863
+ * @example
864
+ * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });
865
+ * // Returns: 'Hello, w...'
866
+ *
867
+ * @example
868
+ * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });
869
+ * // Returns: '...ld!'
870
+ *
871
+ * @example
872
+ * formatCutoff('Very long text that needs cutting', {
873
+ * locales: 'en-US',
874
+ * maxChars: 15,
875
+ * style: 'ellipsis',
876
+ * separator: ' '
877
+ * });
878
+ * // Returns: 'Very long text ...'
879
+ */
880
+ declare function formatCutoff(value: string, options?: {
881
+ locales?: string | string[];
882
+ } & CutoffFormatOptions): string;
883
+ /**
884
+ * Formats a message according to the specified locales and options.
885
+ *
886
+ * @param {string} message - The message to format.
887
+ * @param {string | string[]} [locales='en'] - The locales to use for formatting.
888
+ * @param {FormatVariables} [variables={}] - The variables to use for formatting.
889
+ * @param {StringFormat} [dataFormat='ICU'] - The format of the message. (When STRING, the message is returned as is)
890
+ * @returns {string} The formatted message.
891
+ *
892
+ * @example
893
+ * formatMessage('Hello {name}', { name: 'John' });
894
+ * // Returns: "Hello John"
895
+ *
896
+ * formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });
897
+ * // Returns: "Bonjour John"
898
+ */
899
+ declare function formatMessage(message: string, options?: {
900
+ locales?: string | string[];
901
+ variables?: FormatVariables;
902
+ dataFormat?: StringFormat;
903
+ }): string;
904
+ /**
905
+ * Formats a number according to the specified locales and options.
906
+ * @param {Object} params - The parameters for the number formatting.
907
+ * @param {number} params.value - The number to format.
908
+ * @param {Intl.NumberFormatOptions} [params.options] - Additional options for number formatting.
909
+ * @param {string | string[]} [params.options.locales] - The locales to use for formatting.
910
+ * @returns {string} The formatted number.
911
+ */
912
+ declare function formatNum(number: number, options: {
913
+ locales: string | string[];
914
+ } & Intl.NumberFormatOptions): string;
915
+ /**
916
+ * Formats a date according to the specified languages and options.
917
+ * @param {Object} params - The parameters for the date formatting.
918
+ * @param {Date} params.value - The date to format.
919
+ * @param {Intl.DateTimeFormatOptions} [params.options] - Additional options for date formatting.
920
+ * @param {string | string[]} [params.options.locales] - The languages to use for formatting.
921
+ * @returns {string} The formatted date.
922
+ */
923
+ declare function formatDateTime(date: Date, options?: {
924
+ locales?: string | string[];
925
+ } & Intl.DateTimeFormatOptions): string;
926
+ /**
927
+ * Formats a currency value according to the specified languages, currency, and options.
928
+ * @param {Object} params - The parameters for the currency formatting.
929
+ * @param {number} params.value - The currency value to format.
930
+ * @param {string} params.currency - The currency code (e.g., 'USD').
931
+ * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.
932
+ * @param {string | string[]} [params.options.locales] - The locale codes to use for formatting.
933
+ * @returns {string} The formatted currency value.
934
+ */
935
+ declare function formatCurrency(value: number, currency: string, options: {
936
+ locales: string | string[];
937
+ } & Intl.NumberFormatOptions): string;
938
+ /**
939
+ * Formats a list of items according to the specified locales and options.
940
+ * @param {Object} params - The parameters for the list formatting.
941
+ * @param {Array<string | number>} params.value - The list of items to format.
942
+ * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
943
+ * @param {string | string[]} [params.options.locales] - The locales to use for formatting.
944
+ * @returns {string} The formatted list.
945
+ */
946
+ declare function formatList(array: Array<string | number>, options: {
947
+ locales: string | string[];
948
+ } & Intl.ListFormatOptions): string;
949
+ /**
950
+ * Formats a list of items according to the specified locales and options.
951
+ * @param {Array<T>} array - The list of items to format
952
+ * @param {Object} [options] - Additional options for list formatting
953
+ * @param {string | string[]} [options.locales] - The locales to use for formatting
954
+ * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options
955
+ * @returns {Array<T | string>} The formatted list parts
956
+ */
957
+ declare function formatListToParts<T>(array: Array<T>, options?: {
958
+ locales?: string | string[];
959
+ } & Intl.ListFormatOptions): Array<T | string>;
960
+ /**
961
+ * Formats a relative time value according to the specified locales and options.
962
+ * @param {Object} params - The parameters for the relative time formatting.
963
+ * @param {number} params.value - The relative time value to format.
964
+ * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').
965
+ * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.
966
+ * @param {string | string[]} [params.options.locales] - The locales to use for formatting.
967
+ * @returns {string} The formatted relative time string.
968
+ */
969
+ declare function formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, options: {
970
+ locales: string | string[];
971
+ } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>): string;
972
+ /**
973
+ * Formats a relative time string from a Date, automatically selecting the best unit.
974
+ * @param {Date} date - The date to format relative to now.
975
+ * @param {Object} options - Formatting options.
976
+ * @param {string | string[]} options.locales - The locales to use for formatting.
977
+ * @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options.
978
+ * @returns {string} The formatted relative time string (e.g., "2 hours ago", "in 3 days").
979
+ */
980
+ declare function formatRelativeTimeFromDate(date: Date, options: {
981
+ locales: string | string[];
982
+ baseDate?: Date;
983
+ } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>): string;
984
+ /**
985
+ * Retrieves the display name of locale code using Intl.DisplayNames.
986
+ *
987
+ * @param {string} locale - A BCP-47 locale code.
988
+ * @param {string} [defaultLocale] - The default locale to use for formatting.
989
+ * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.
990
+ * @returns {string} The display name corresponding to the code.
991
+ */
992
+ declare function getLocaleName(locale: string, defaultLocale?: string, customMapping?: CustomMapping): string;
993
+ /**
994
+ * Retrieves an emoji based on a given locale code, taking into account region, language, and specific exceptions.
995
+ *
996
+ * This function uses the locale's region (if present) to select an emoji or falls back on default emojis for certain languages.
997
+ *
998
+ * @param locale - A string representing the locale code (e.g., 'en-US', 'fr-CA').
999
+ * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.
1000
+ * @returns The emoji representing the locale or its region, or a default emoji if no specific match is found.
1001
+ */
1002
+ declare function getLocaleEmoji(locale: string, customMapping?: CustomMapping): string;
1003
+ /**
1004
+ * Generates linguistic details for a given locale code.
1005
+ *
1006
+ * This function returns information about the locale,
1007
+ * script, and region of a given language code both in a standard form and in a maximized form (with likely script and region).
1008
+ * The function provides these names in both your default language and native forms, and an associated emoji.
1009
+ *
1010
+ * @param {string} locale - The locale code to get properties for (e.g., "de-AT").
1011
+ * @param {string} [defaultLocale] - The default locale to use for formatting.
1012
+ * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.
1013
+ * @returns {LocaleProperties} - An object containing detailed information about the locale.
1014
+ *
1015
+ * @property {string} code - The full locale code, e.g., "de-AT".
1016
+ * @property {string} name - Language name in the default display language, e.g., "Austrian German".
1017
+ * @property {string} nativeName - Language name in the locale's native language, e.g., "Österreichisches Deutsch".
1018
+ * @property {string} languageCode - The base language code, e.g., "de".
1019
+ * @property {string} languageName - The language name in the default display language, e.g., "German".
1020
+ * @property {string} nativeLanguageName - The language name in the native language, e.g., "Deutsch".
1021
+ * @property {string} nameWithRegionCode - Language name with region in the default language, e.g., "German (AT)".
1022
+ * @property {string} nativeNameWithRegionCode - Language name with region in the native language, e.g., "Deutsch (AT)".
1023
+ * @property {string} regionCode - The region code from maximization, e.g., "AT".
1024
+ * @property {string} regionName - The region name in the default display language, e.g., "Austria".
1025
+ * @property {string} nativeRegionName - The region name in the native language, e.g., "Österreich".
1026
+ * @property {string} scriptCode - The script code from maximization, e.g., "Latn".
1027
+ * @property {string} scriptName - The script name in the default display language, e.g., "Latin".
1028
+ * @property {string} nativeScriptName - The script name in the native language, e.g., "Lateinisch".
1029
+ * @property {string} maximizedCode - The maximized locale code, e.g., "de-Latn-AT".
1030
+ * @property {string} maximizedName - Maximized locale name with likely script in the default language, e.g., "Austrian German (Latin)".
1031
+ * @property {string} nativeMaximizedName - Maximized locale name in the native language, e.g., "Österreichisches Deutsch (Lateinisch)".
1032
+ * @property {string} minimizedCode - Minimized locale code, e.g., "de-AT" (or "de" for "de-DE").
1033
+ * @property {string} minimizedName - Minimized language name in the default language, e.g., "Austrian German".
1034
+ * @property {string} nativeMinimizedName - Minimized language name in the native language, e.g., "Österreichisches Deutsch".
1035
+ * @property {string} emoji - The emoji associated with the locale's region, if applicable.
1036
+ */
1037
+ declare function getLocaleProperties(locale: string, defaultLocale?: string, customMapping?: CustomMapping): LocaleProperties;
1038
+ /**
1039
+ * Retrieves multiple properties for a given region code, including:
1040
+ * - `code`: the original region code
1041
+ * - `name`: the localized display name
1042
+ * - `emoji`: the associated flag or symbol
1043
+ *
1044
+ * Behavior:
1045
+ * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `"US"`, `"FR"`, `"419"`).
1046
+ * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.
1047
+ * - Otherwise, uses `Intl.DisplayNames` to get the localized region name in the given `defaultLocale`,
1048
+ * falling back to `libraryDefaultLocale`.
1049
+ * - Falls back to the region code as `name` if display name resolution fails.
1050
+ * - Falls back to `defaultEmoji` if no emoji mapping is found in `emojis` or `customMapping`.
1051
+ *
1052
+ * @param {string} region - The region code to look up (e.g., `"US"`, `"GB"`, `"DE"`).
1053
+ * @param {string} [defaultLocale=libraryDefaultLocale] - The locale to use when localizing the region name.
1054
+ * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.
1055
+ * @returns {{ code: string, name: string, emoji: string }} An object containing:
1056
+ * - `code`: the input region code
1057
+ * - `name`: the localized or custom region name
1058
+ * - `emoji`: the matching emoji flag or symbol
1059
+ *
1060
+ * @example
1061
+ * getRegionProperties('US', 'en');
1062
+ * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }
1063
+ *
1064
+ * @example
1065
+ * getRegionProperties('US', 'fr');
1066
+ * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }
1067
+ *
1068
+ * @example
1069
+ * getRegionProperties('US', 'en', { US: { name: 'USA', emoji: '🗽' } });
1070
+ * // => { code: 'US', name: 'USA', emoji: '🗽' }
1071
+ */
1072
+ declare function getRegionProperties(region: string, defaultLocale?: string, customMapping?: CustomRegionMapping): {
1073
+ code: string;
1074
+ name: string;
1075
+ emoji: string;
1076
+ };
1077
+ /**
1078
+ * Determines whether a translation is required based on the source and target locales.
1079
+ *
1080
+ * - If the target locale is not specified, the function returns `false`, as translation is not needed.
1081
+ * - If the source and target locale are the same, returns `false`, indicating that no translation is necessary.
1082
+ * - If the `approvedLocales` array is provided, and the target locale is not within that array, the function also returns `false`.
1083
+ * - Otherwise, it returns `true`, meaning that a translation is required.
1084
+ *
1085
+ * @param {string} sourceLocale - The locale code for the original content (BCP 47 locale code).
1086
+ * @param {string} targetLocale - The locale code of the language to translate the content into (BCP 47 locale code).
1087
+ * @param {string[]} [approvedLocale] - An optional array of approved target locales.
1088
+ *
1089
+ * @returns {boolean} - Returns `true` if translation is required, otherwise `false`.
1090
+ */
1091
+ declare function requiresTranslation(sourceLocale: string, targetLocale: string, approvedLocales?: string[], customMapping?: CustomMapping): boolean;
1092
+ /**
1093
+ * Determines the best matching locale from the provided approved locales list.
1094
+ * @param {string | string[]} locales - A single locale or an array of locales sorted in preference order.
1095
+ * @param {string[]} [approvedLocales=this.locales] - An array of approved locales, also sorted by preference.
1096
+ * @returns {string | undefined} - The best matching locale from the approvedLocales list, or undefined if no match is found.
1097
+ */
1098
+ declare function determineLocale(locales: string | string[], approvedLocales?: string[] | undefined, customMapping?: CustomMapping | undefined): string | undefined;
1099
+ /**
1100
+ * Get the text direction for a given locale code using the Intl.Locale API.
1101
+ *
1102
+ * @param {string} locale - A BCP-47 locale code.
1103
+ * @returns {string} - 'rtl' if the locale is right-to-left, otherwise 'ltr'.
1104
+ */
1105
+ declare function getLocaleDirection(locale: string): 'ltr' | 'rtl';
1106
+ /**
1107
+ * Checks if a given BCP 47 locale code is valid.
1108
+ * @param {string} locale - The BCP 47 locale code to validate.
1109
+ * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
1110
+ * @returns {boolean} True if the BCP 47 code is valid, false otherwise.
1111
+ */
1112
+ declare function isValidLocale(locale: string, customMapping?: CustomMapping): boolean;
1113
+ /**
1114
+ * Resolves the alias locale for a given locale.
1115
+ * @param {string} locale - The locale to resolve the alias locale for
1116
+ * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the alias locale
1117
+ * @returns {string} The alias locale
1118
+ */
1119
+ declare function resolveAliasLocale(locale: string, customMapping?: CustomMapping): string;
1120
+ /**
1121
+ * Resolves the canonical locale for a given locale.
1122
+ * @param {string} locale - The locale to resolve the canonical locale for
1123
+ * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the canonical locale
1124
+ * @returns {string} The canonical locale
1125
+ */
1126
+ declare function resolveCanonicalLocale(locale: string, customMapping?: CustomMapping): string;
1127
+ /**
1128
+ * Standardizes a BCP 47 locale code to ensure correct formatting.
1129
+ * @param {string} locale - The BCP 47 locale code to standardize.
1130
+ * @returns {string} The standardized BCP 47 locale code or an empty string if it is an invalid code.
1131
+ */
1132
+ declare function standardizeLocale(locale: string): string;
1133
+ /**
1134
+ * Checks if multiple BCP 47 locale codes represent the same dialect.
1135
+ * @param {string[]} locales - The BCP 47 locale codes to compare.
1136
+ * @returns {boolean} True if all BCP 47 codes represent the same dialect, false otherwise.
1137
+ */
1138
+ declare function isSameDialect(...locales: (string | string[])[]): boolean;
1139
+ /**
1140
+ * Checks if multiple BCP 47 locale codes represent the same language.
1141
+ * @param {string[]} locales - The BCP 47 locale codes to compare.
1142
+ * @returns {boolean} True if all BCP 47 codes represent the same language, false otherwise.
1143
+ */
1144
+ declare function isSameLanguage(...locales: (string | string[])[]): boolean;
1145
+ /**
1146
+ * Checks if a locale is a superset of another locale.
1147
+ * A subLocale is a subset of superLocale if it is an extension of superLocale or are otherwise identical.
1148
+ *
1149
+ * @param {string} superLocale - The locale to check if it is a superset of the other locale.
1150
+ * @param {string} subLocale - The locale to check if it is a subset of the other locale.
1151
+ * @returns {boolean} True if the first locale is a superset of the second locale, false otherwise.
1152
+ */
1153
+ declare function isSupersetLocale(superLocale: string, subLocale: string): boolean;
1154
+ declare const API_VERSION = "2026-03-06.v1";
1155
+ //#endregion
1156
+ export { API_VERSION, GT, determineLocale, formatCurrency, formatCutoff, formatDateTime, formatList, formatListToParts, formatMessage, formatNum, formatRelativeTime, formatRelativeTimeFromDate, getLocaleDirection, getLocaleEmoji, getLocaleName, getLocaleProperties, getRegionProperties, isSameDialect, isSameLanguage, isSupersetLocale, isValidLocale, requiresTranslation, resolveAliasLocale, resolveCanonicalLocale, standardizeLocale };
1157
+ //# sourceMappingURL=index.d.cts.map