generaltranslation 9.4.0 → 9.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -62,6 +62,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
62
62
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
63
63
  }
64
64
  };
65
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
+ if (ar || !(i in from)) {
68
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
+ ar[i] = from[i];
70
+ }
71
+ }
72
+ return to.concat(ar || Array.prototype.slice.call(from));
73
+ };
65
74
  import { libraryDefaultLocale } from './settings/settings';
66
75
  import { noSourceLocaleProvidedError, noTargetLocaleProvidedError, } from './logging/errors';
67
76
  import { gtInstanceLogger } from './logging/logger';
@@ -229,7 +238,7 @@ var GT = /** @class */ (function (_super) {
229
238
  case 0:
230
239
  this._validateAuth('setupProject');
231
240
  options = __assign(__assign({}, options), { locales: (_a = options === null || options === void 0 ? void 0 : options.locales) === null || _a === void 0 ? void 0 : _a.map(function (locale) {
232
- return _this.resolveCanonicalLocale(locale);
241
+ return _this.resolveServiceLocale(locale);
233
242
  }) });
234
243
  return [4 /*yield*/, _setupProject(files, this._getTranslationConfig(), options)];
235
244
  case 1: return [2 /*return*/, _b.sent()];
@@ -301,7 +310,7 @@ var GT = /** @class */ (function (_super) {
301
310
  */
302
311
  GT.prototype.enqueueFiles = function (files, options) {
303
312
  return __awaiter(this, void 0, void 0, function () {
304
- var mergedOptions, error, error;
313
+ var mergedOptions, error, error, targetLocaleIdentities, result;
305
314
  var _this = this;
306
315
  var _a, _b;
307
316
  return __generator(this, function (_c) {
@@ -323,12 +332,15 @@ var GT = /** @class */ (function (_super) {
323
332
  gtInstanceLogger.error(error);
324
333
  throw new Error(error);
325
334
  }
326
- // Replace target locales with canonical locales
327
- mergedOptions = __assign(__assign({}, mergedOptions), { targetLocales: mergedOptions.targetLocales.map(function (locale) {
328
- return _this.resolveCanonicalLocale(locale);
335
+ targetLocaleIdentities = __spreadArray([], mergedOptions.targetLocales, true);
336
+ // Convert configured identities at the service boundary.
337
+ mergedOptions = __assign(__assign({}, mergedOptions), { sourceLocale: this.resolveServiceLocale(mergedOptions.sourceLocale), targetLocales: mergedOptions.targetLocales.map(function (locale) {
338
+ return _this.resolveServiceLocale(locale);
329
339
  }) });
330
340
  return [4 /*yield*/, _enqueueFiles(files, mergedOptions, this._getTranslationConfig())];
331
- case 1: return [2 /*return*/, _c.sent()];
341
+ case 1:
342
+ result = _c.sent();
343
+ return [2 /*return*/, __assign(__assign({}, result), { locales: targetLocaleIdentities })];
332
344
  }
333
345
  });
334
346
  });
@@ -360,12 +372,20 @@ var GT = /** @class */ (function (_super) {
360
372
  */
361
373
  GT.prototype.publishFiles = function (files) {
362
374
  return __awaiter(this, void 0, void 0, function () {
375
+ var result;
376
+ var _this = this;
363
377
  return __generator(this, function (_a) {
364
378
  switch (_a.label) {
365
379
  case 0:
366
380
  this._validateAuth('publishFiles');
367
381
  return [4 /*yield*/, _publishFiles(files, this._getTranslationConfig())];
368
- case 1: return [2 /*return*/, _a.sent()];
382
+ case 1:
383
+ result = _a.sent();
384
+ return [2 /*return*/, {
385
+ results: result.results.map(function (item) { return (__assign(__assign({}, item), (item.locale && {
386
+ locale: _this.resolveServiceResponseLocale(item.locale),
387
+ }))); }),
388
+ }];
369
389
  }
370
390
  });
371
391
  });
@@ -384,7 +404,7 @@ var GT = /** @class */ (function (_super) {
384
404
  switch (_a.label) {
385
405
  case 0:
386
406
  this._validateAuth('submitUserEditDiffs');
387
- normalized = __assign(__assign({}, payload), { diffs: (payload.diffs || []).map(function (d) { return (__assign(__assign({}, d), { locale: _this.resolveCanonicalLocale(d.locale) })); }) });
407
+ normalized = __assign(__assign({}, payload), { diffs: (payload.diffs || []).map(function (d) { return (__assign(__assign({}, d), { locale: _this.resolveServiceLocale(d.locale) })); }) });
388
408
  return [4 /*yield*/, _submitUserEditDiffs(normalized, this._getTranslationConfig())];
389
409
  case 1:
390
410
  _a.sent();
@@ -421,13 +441,19 @@ var GT = /** @class */ (function (_super) {
421
441
  */
422
442
  GT.prototype.getProjectInfo = function () {
423
443
  return __awaiter(this, arguments, void 0, function (options) {
444
+ var result;
445
+ var _this = this;
424
446
  if (options === void 0) { options = {}; }
425
447
  return __generator(this, function (_a) {
426
448
  switch (_a.label) {
427
449
  case 0:
428
450
  this._validateAuth('getProjectInfo');
429
451
  return [4 /*yield*/, _getProjectInfo(options, this._getTranslationConfig())];
430
- case 1: return [2 /*return*/, _a.sent()];
452
+ case 1:
453
+ result = _a.sent();
454
+ return [2 /*return*/, __assign(__assign({}, result), { defaultLocale: this.resolveServiceResponseLocale(result.defaultLocale), currentLocales: result.currentLocales.map(function (locale) {
455
+ return _this.resolveServiceResponseLocale(locale);
456
+ }) })];
431
457
  }
432
458
  });
433
459
  });
@@ -444,15 +470,19 @@ var GT = /** @class */ (function (_super) {
444
470
  // Validation
445
471
  this._validateAuth('queryFileData');
446
472
  // Replace target locales with canonical locales
447
- data.translatedFiles = (_a = data.translatedFiles) === null || _a === void 0 ? void 0 : _a.map(function (item) { return (__assign(__assign({}, item), { locale: _this.resolveCanonicalLocale(item.locale) })); });
473
+ data.translatedFiles = (_a = data.translatedFiles) === null || _a === void 0 ? void 0 : _a.map(function (item) { return (__assign(__assign({}, item), { locale: _this.resolveServiceLocale(item.locale) })); });
448
474
  return [4 /*yield*/, _queryFileData(data, options, this._getTranslationConfig())];
449
475
  case 1:
450
476
  result = _d.sent();
451
477
  // Resolve canonical locales
452
- result.translatedFiles = (_b = result.translatedFiles) === null || _b === void 0 ? void 0 : _b.map(function (item) { return (__assign(__assign({}, item), (item.locale && { locale: _this.resolveAliasLocale(item.locale) }))); });
478
+ result.translatedFiles = (_b = result.translatedFiles) === null || _b === void 0 ? void 0 : _b.map(function (item) { return (__assign(__assign({}, item), (item.locale && {
479
+ locale: _this.resolveServiceResponseLocale(item.locale),
480
+ }))); });
453
481
  result.sourceFiles = (_c = result.sourceFiles) === null || _c === void 0 ? void 0 : _c.map(function (item) { return (__assign(__assign(__assign({}, item), (item.sourceLocale && {
454
- sourceLocale: _this.resolveAliasLocale(item.sourceLocale),
455
- })), { locales: item.locales.map(function (locale) { return _this.resolveAliasLocale(locale); }) })); });
482
+ sourceLocale: _this.resolveServiceResponseLocale(item.sourceLocale),
483
+ })), { locales: item.locales.map(function (locale) {
484
+ return _this.resolveServiceResponseLocale(locale);
485
+ }) })); });
456
486
  return [2 /*return*/, result];
457
487
  }
458
488
  });
@@ -485,13 +515,15 @@ var GT = /** @class */ (function (_super) {
485
515
  return [4 /*yield*/, _querySourceFile(data, options, this._getTranslationConfig())];
486
516
  case 1:
487
517
  result = _a.sent();
488
- // Replace locales with canonical locales
489
- result.translations = result.translations.map(function (item) { return (__assign(__assign({}, item), (item.locale && { locale: _this.resolveAliasLocale(item.locale) }))); });
518
+ // Restore configured identities from service language codes.
519
+ result.translations = result.translations.map(function (item) { return (__assign(__assign({}, item), (item.locale && {
520
+ locale: _this.resolveServiceResponseLocale(item.locale),
521
+ }))); });
490
522
  result.sourceFile.locales = result.sourceFile.locales.map(function (locale) {
491
- return _this.resolveAliasLocale(locale);
523
+ return _this.resolveServiceResponseLocale(locale);
492
524
  });
493
525
  if (result.sourceFile.sourceLocale) {
494
- result.sourceFile.sourceLocale = this.resolveAliasLocale(result.sourceFile.sourceLocale);
526
+ result.sourceFile.sourceLocale = this.resolveServiceResponseLocale(result.sourceFile.sourceLocale);
495
527
  }
496
528
  return [2 /*return*/, result];
497
529
  }
@@ -523,11 +555,11 @@ var GT = /** @class */ (function (_super) {
523
555
  return [4 /*yield*/, _getProjectData(projectId, options, this._getTranslationConfig())];
524
556
  case 1:
525
557
  result = _a.sent();
526
- // Replace locales with canonical locales
558
+ // Restore configured identities from service language codes.
527
559
  result.currentLocales = result.currentLocales.map(function (item) {
528
- return _this.resolveAliasLocale(item);
560
+ return _this.resolveServiceResponseLocale(item);
529
561
  });
530
- result.defaultLocale = this.resolveAliasLocale(result.defaultLocale);
562
+ result.defaultLocale = this.resolveServiceResponseLocale(result.defaultLocale);
531
563
  return [2 /*return*/, result];
532
564
  }
533
565
  });
@@ -569,7 +601,7 @@ var GT = /** @class */ (function (_super) {
569
601
  fileId: file.fileId,
570
602
  branchId: file.branchId,
571
603
  locale: file.locale
572
- ? this.resolveCanonicalLocale(file.locale)
604
+ ? this.resolveServiceLocale(file.locale)
573
605
  : undefined,
574
606
  versionId: file.versionId,
575
607
  useLatestAvailableVersion: file.useLatestAvailableVersion,
@@ -600,7 +632,7 @@ var GT = /** @class */ (function (_super) {
600
632
  */
601
633
  GT.prototype.downloadFileBatch = function (requests_1) {
602
634
  return __awaiter(this, arguments, void 0, function (requests, options) {
603
- var result;
635
+ var requestedFiles, result;
604
636
  var _this = this;
605
637
  if (options === void 0) { options = {}; }
606
638
  return __generator(this, function (_a) {
@@ -608,16 +640,37 @@ var GT = /** @class */ (function (_super) {
608
640
  case 0:
609
641
  // Validation
610
642
  this._validateAuth('downloadFileBatch');
611
- requests = requests.map(function (request) { return (__assign(__assign({}, request), { locale: request.locale
612
- ? _this.resolveCanonicalLocale(request.locale)
613
- : undefined })); });
643
+ requestedFiles = new Map();
644
+ requests = requests.map(function (request) {
645
+ var _a;
646
+ var locale = request.locale
647
+ ? _this.resolveServiceLocale(request.locale)
648
+ : undefined;
649
+ if (locale) {
650
+ var key = JSON.stringify([request.fileId, locale]);
651
+ var group = (_a = requestedFiles.get(key)) !== null && _a !== void 0 ? _a : [];
652
+ group.push(request);
653
+ requestedFiles.set(key, group);
654
+ }
655
+ return __assign(__assign({}, request), { locale: locale });
656
+ });
614
657
  return [4 /*yield*/, _downloadFileBatch(requests, options, this._getTranslationConfig())];
615
658
  case 1:
616
659
  result = _a.sent();
617
660
  return [2 /*return*/, {
618
- files: result.data.map(function (file) { return (__assign(__assign({}, file), (file.locale && {
619
- locale: _this.resolveAliasLocale(file.locale),
620
- }))); }),
661
+ files: result.data.map(function (file) {
662
+ var _a;
663
+ if (!file.locale)
664
+ return file;
665
+ var serviceLocale = _this.standardizeLocale(file.locale);
666
+ var matchingRequests = ((_a = requestedFiles.get(JSON.stringify([file.fileId, serviceLocale]))) !== null && _a !== void 0 ? _a : []).filter(function (request) {
667
+ return (!request.branchId || request.branchId === file.branchId) &&
668
+ (!request.versionId || request.versionId === file.versionId);
669
+ });
670
+ return __assign(__assign({}, file), { locale: matchingRequests.length === 1
671
+ ? matchingRequests[0].locale
672
+ : _this.resolveServiceResponseLocale(file.locale) });
673
+ }),
621
674
  count: result.count,
622
675
  }];
623
676
  }
@@ -646,9 +699,9 @@ var GT = /** @class */ (function (_super) {
646
699
  case 0:
647
700
  // Validation
648
701
  this._validateAuth('uploadSourceFiles');
649
- mergedOptions = __assign(__assign({}, options), { sourceLocale: this.resolveCanonicalLocale((_b = (_a = options.sourceLocale) !== null && _a !== void 0 ? _a : this.sourceLocale) !== null && _b !== void 0 ? _b : libraryDefaultLocale) });
702
+ mergedOptions = __assign(__assign({}, options), { sourceLocale: this.resolveServiceLocale((_b = (_a = options.sourceLocale) !== null && _a !== void 0 ? _a : this.sourceLocale) !== null && _b !== void 0 ? _b : libraryDefaultLocale) });
650
703
  // resolve canonical locales
651
- files = files.map(function (f) { return (__assign(__assign({}, f), { source: __assign(__assign({}, f.source), { locale: _this.resolveCanonicalLocale(f.source.locale) }) })); });
704
+ files = files.map(function (f) { return (__assign(__assign({}, f), { source: __assign(__assign({}, f.source), { locale: _this.resolveServiceLocale(f.source.locale) }) })); });
652
705
  return [4 /*yield*/, _uploadSourceFiles(files, mergedOptions, this._getTranslationConfig())];
653
706
  case 1:
654
707
  result = _c.sent();
@@ -716,8 +769,8 @@ var GT = /** @class */ (function (_super) {
716
769
  gtInstanceLogger.error(error);
717
770
  throw new Error(error);
718
771
  }
719
- mergedOptions.sourceLocale = this.resolveCanonicalLocale(mergedOptions.sourceLocale);
720
- targetFiles = files.map(function (f) { return (__assign(__assign({}, f), { translations: f.translations.map(function (t) { return (__assign(__assign({}, t), { locale: _this.resolveCanonicalLocale(t.locale) })); }) })); });
772
+ mergedOptions.sourceLocale = this.resolveServiceLocale(mergedOptions.sourceLocale);
773
+ targetFiles = files.map(function (f) { return (__assign(__assign({}, f), { source: __assign(__assign({}, f.source), { locale: _this.resolveServiceLocale(f.source.locale) }), translations: f.translations.map(function (t) { return (__assign(__assign({}, t), { locale: _this.resolveServiceLocale(t.locale) })); }) })); });
721
774
  return [4 /*yield*/, _uploadTranslations(targetFiles, mergedOptions, this._getTranslationConfig())];
722
775
  case 1:
723
776
  result = _b.sent();
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { l as defaultTimeout } from "./unwrapApiResult-BzGfPw75.mjs";
2
- import { a as gtInstanceLogger, c as translationRequestFailedError, i as fetchLogger, l as translationTimeoutError, n as validateResponse, o as noSourceLocaleProvidedError, r as fetchWithTimeout, s as noTargetLocaleProvidedError, t as GTRuntime } from "./runtime-BiKgjDUI.mjs";
2
+ import { a as gtInstanceLogger, c as translationRequestFailedError, i as fetchLogger, l as translationTimeoutError, n as validateResponse, o as noSourceLocaleProvidedError, r as fetchWithTimeout, s as noTargetLocaleProvidedError, t as GTRuntime } from "./runtime-Bcp4F2ME.mjs";
3
3
  import { c as decode, f as isSupportedFileFormatTransform, n as declareVar, p as API_VERSION, r as decodeVars, t as derive, u as encode } from "./derive-CTzR56T_.mjs";
4
4
  import { n as isBinaryFileFormat } from "./file-Dga6cyM8.mjs";
5
5
  import { LocaleConfig, determineLocale, formatCurrency, formatCutoff, formatDateTime, formatList, formatListToParts, formatMessage, formatNum, formatRelativeTime, formatRelativeTimeFromDate, getLocaleDirection, getLocaleEmoji, getLocaleName, getLocaleProperties, getRegionProperties, isSameDialect, isSameLanguage, isSupersetLocale, isValidLocale, requiresTranslation, resolveAliasLocale, resolveCanonicalLocale, standardizeLocale } from "@generaltranslation/format";
@@ -772,7 +772,7 @@ var GT = class extends GTRuntime {
772
772
  this._validateAuth("setupProject");
773
773
  options = {
774
774
  ...options,
775
- locales: options?.locales?.map((locale) => this.resolveCanonicalLocale(locale))
775
+ locales: options?.locales?.map((locale) => this.resolveServiceLocale(locale))
776
776
  };
777
777
  return await _setupProject(files, this._getTranslationConfig(), options);
778
778
  }
@@ -837,11 +837,16 @@ var GT = class extends GTRuntime {
837
837
  gtInstanceLogger.error(error);
838
838
  throw new Error(error);
839
839
  }
840
+ const targetLocaleIdentities = [...mergedOptions.targetLocales];
840
841
  mergedOptions = {
841
842
  ...mergedOptions,
842
- targetLocales: mergedOptions.targetLocales.map((locale) => this.resolveCanonicalLocale(locale))
843
+ sourceLocale: this.resolveServiceLocale(mergedOptions.sourceLocale),
844
+ targetLocales: mergedOptions.targetLocales.map((locale) => this.resolveServiceLocale(locale))
845
+ };
846
+ return {
847
+ ...await _enqueueFiles(files, mergedOptions, this._getTranslationConfig()),
848
+ locales: targetLocaleIdentities
843
849
  };
844
- return await _enqueueFiles(files, mergedOptions, this._getTranslationConfig());
845
850
  }
846
851
  /**
847
852
  * Creates or upserts a file tag, associating a set of source files
@@ -862,7 +867,10 @@ var GT = class extends GTRuntime {
862
867
  */
863
868
  async publishFiles(files) {
864
869
  this._validateAuth("publishFiles");
865
- return await _publishFiles(files, this._getTranslationConfig());
870
+ return { results: (await _publishFiles(files, this._getTranslationConfig())).results.map((item) => ({
871
+ ...item,
872
+ ...item.locale && { locale: this.resolveServiceResponseLocale(item.locale) }
873
+ })) };
866
874
  }
867
875
  /**
868
876
  * Submits user edit diffs for existing translations so future generations preserve user intent.
@@ -876,7 +884,7 @@ var GT = class extends GTRuntime {
876
884
  ...payload,
877
885
  diffs: (payload.diffs || []).map((d) => ({
878
886
  ...d,
879
- locale: this.resolveCanonicalLocale(d.locale)
887
+ locale: this.resolveServiceLocale(d.locale)
880
888
  }))
881
889
  }, this._getTranslationConfig());
882
890
  }
@@ -908,23 +916,28 @@ var GT = class extends GTRuntime {
908
916
  */
909
917
  async getProjectInfo(options = {}) {
910
918
  this._validateAuth("getProjectInfo");
911
- return await _getProjectInfo(options, this._getTranslationConfig());
919
+ const result = await _getProjectInfo(options, this._getTranslationConfig());
920
+ return {
921
+ ...result,
922
+ defaultLocale: this.resolveServiceResponseLocale(result.defaultLocale),
923
+ currentLocales: result.currentLocales.map((locale) => this.resolveServiceResponseLocale(locale))
924
+ };
912
925
  }
913
926
  async queryFileData(data, options = {}) {
914
927
  this._validateAuth("queryFileData");
915
928
  data.translatedFiles = data.translatedFiles?.map((item) => ({
916
929
  ...item,
917
- locale: this.resolveCanonicalLocale(item.locale)
930
+ locale: this.resolveServiceLocale(item.locale)
918
931
  }));
919
932
  const result = await _queryFileData(data, options, this._getTranslationConfig());
920
933
  result.translatedFiles = result.translatedFiles?.map((item) => ({
921
934
  ...item,
922
- ...item.locale && { locale: this.resolveAliasLocale(item.locale) }
935
+ ...item.locale && { locale: this.resolveServiceResponseLocale(item.locale) }
923
936
  }));
924
937
  result.sourceFiles = result.sourceFiles?.map((item) => ({
925
938
  ...item,
926
- ...item.sourceLocale && { sourceLocale: this.resolveAliasLocale(item.sourceLocale) },
927
- locales: item.locales.map((locale) => this.resolveAliasLocale(locale))
939
+ ...item.sourceLocale && { sourceLocale: this.resolveServiceResponseLocale(item.sourceLocale) },
940
+ locales: item.locales.map((locale) => this.resolveServiceResponseLocale(locale))
928
941
  }));
929
942
  return result;
930
943
  }
@@ -947,10 +960,10 @@ var GT = class extends GTRuntime {
947
960
  const result = await _querySourceFile(data, options, this._getTranslationConfig());
948
961
  result.translations = result.translations.map((item) => ({
949
962
  ...item,
950
- ...item.locale && { locale: this.resolveAliasLocale(item.locale) }
963
+ ...item.locale && { locale: this.resolveServiceResponseLocale(item.locale) }
951
964
  }));
952
- result.sourceFile.locales = result.sourceFile.locales.map((locale) => this.resolveAliasLocale(locale));
953
- if (result.sourceFile.sourceLocale) result.sourceFile.sourceLocale = this.resolveAliasLocale(result.sourceFile.sourceLocale);
965
+ result.sourceFile.locales = result.sourceFile.locales.map((locale) => this.resolveServiceResponseLocale(locale));
966
+ if (result.sourceFile.sourceLocale) result.sourceFile.sourceLocale = this.resolveServiceResponseLocale(result.sourceFile.sourceLocale);
954
967
  return result;
955
968
  }
956
969
  /**
@@ -968,8 +981,8 @@ var GT = class extends GTRuntime {
968
981
  async getProjectData(projectId, options = {}) {
969
982
  this._validateAuth("getProjectData");
970
983
  const result = await _getProjectData(projectId, options, this._getTranslationConfig());
971
- result.currentLocales = result.currentLocales.map((item) => this.resolveAliasLocale(item));
972
- result.defaultLocale = this.resolveAliasLocale(result.defaultLocale);
984
+ result.currentLocales = result.currentLocales.map((item) => this.resolveServiceResponseLocale(item));
985
+ result.defaultLocale = this.resolveServiceResponseLocale(result.defaultLocale);
973
986
  return result;
974
987
  }
975
988
  /**
@@ -998,7 +1011,7 @@ var GT = class extends GTRuntime {
998
1011
  return (await _downloadFileBatch([{
999
1012
  fileId: file.fileId,
1000
1013
  branchId: file.branchId,
1001
- locale: file.locale ? this.resolveCanonicalLocale(file.locale) : void 0,
1014
+ locale: file.locale ? this.resolveServiceLocale(file.locale) : void 0,
1002
1015
  versionId: file.versionId,
1003
1016
  useLatestAvailableVersion: file.useLatestAvailableVersion
1004
1017
  }], options, this._getTranslationConfig())).data?.[0]?.data ?? "";
@@ -1021,16 +1034,31 @@ var GT = class extends GTRuntime {
1021
1034
  */
1022
1035
  async downloadFileBatch(requests, options = {}) {
1023
1036
  this._validateAuth("downloadFileBatch");
1024
- requests = requests.map((request) => ({
1025
- ...request,
1026
- locale: request.locale ? this.resolveCanonicalLocale(request.locale) : void 0
1027
- }));
1037
+ const requestedFiles = /* @__PURE__ */ new Map();
1038
+ requests = requests.map((request) => {
1039
+ const locale = request.locale ? this.resolveServiceLocale(request.locale) : void 0;
1040
+ if (locale) {
1041
+ const key = JSON.stringify([request.fileId, locale]);
1042
+ const group = requestedFiles.get(key) ?? [];
1043
+ group.push(request);
1044
+ requestedFiles.set(key, group);
1045
+ }
1046
+ return {
1047
+ ...request,
1048
+ locale
1049
+ };
1050
+ });
1028
1051
  const result = await _downloadFileBatch(requests, options, this._getTranslationConfig());
1029
1052
  return {
1030
- files: result.data.map((file) => ({
1031
- ...file,
1032
- ...file.locale && { locale: this.resolveAliasLocale(file.locale) }
1033
- })),
1053
+ files: result.data.map((file) => {
1054
+ if (!file.locale) return file;
1055
+ const serviceLocale = this.standardizeLocale(file.locale);
1056
+ const matchingRequests = (requestedFiles.get(JSON.stringify([file.fileId, serviceLocale])) ?? []).filter((request) => (!request.branchId || request.branchId === file.branchId) && (!request.versionId || request.versionId === file.versionId));
1057
+ return {
1058
+ ...file,
1059
+ locale: matchingRequests.length === 1 ? matchingRequests[0].locale : this.resolveServiceResponseLocale(file.locale)
1060
+ };
1061
+ }),
1034
1062
  count: result.count
1035
1063
  };
1036
1064
  }
@@ -1050,13 +1078,13 @@ var GT = class extends GTRuntime {
1050
1078
  this._validateAuth("uploadSourceFiles");
1051
1079
  const mergedOptions = {
1052
1080
  ...options,
1053
- sourceLocale: this.resolveCanonicalLocale(options.sourceLocale ?? this.sourceLocale ?? "en")
1081
+ sourceLocale: this.resolveServiceLocale(options.sourceLocale ?? this.sourceLocale ?? "en")
1054
1082
  };
1055
1083
  files = files.map((f) => ({
1056
1084
  ...f,
1057
1085
  source: {
1058
1086
  ...f.source,
1059
- locale: this.resolveCanonicalLocale(f.source.locale)
1087
+ locale: this.resolveServiceLocale(f.source.locale)
1060
1088
  }
1061
1089
  }));
1062
1090
  const result = await _uploadSourceFiles(files, mergedOptions, this._getTranslationConfig());
@@ -1107,12 +1135,16 @@ var GT = class extends GTRuntime {
1107
1135
  gtInstanceLogger.error(error);
1108
1136
  throw new Error(error);
1109
1137
  }
1110
- mergedOptions.sourceLocale = this.resolveCanonicalLocale(mergedOptions.sourceLocale);
1138
+ mergedOptions.sourceLocale = this.resolveServiceLocale(mergedOptions.sourceLocale);
1111
1139
  const result = await _uploadTranslations(files.map((f) => ({
1112
1140
  ...f,
1141
+ source: {
1142
+ ...f.source,
1143
+ locale: this.resolveServiceLocale(f.source.locale)
1144
+ },
1113
1145
  translations: f.translations.map((t) => ({
1114
1146
  ...t,
1115
- locale: this.resolveCanonicalLocale(t.locale)
1147
+ locale: this.resolveServiceLocale(t.locale)
1116
1148
  }))
1117
1149
  })), mergedOptions, this._getTranslationConfig());
1118
1150
  return {