generaltranslation 8.2.13 → 8.2.14

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 (127) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{ApiError-IYfaOR30.mjs → ApiError-0DxxIHLp.mjs} +1 -1
  3. package/dist/{ApiError-CZ45tkW6.cjs.map → ApiError-0DxxIHLp.mjs.map} +1 -1
  4. package/dist/{ApiError-CZ45tkW6.cjs → ApiError-D-IBuHj6.cjs} +1 -1
  5. package/dist/{ApiError-IYfaOR30.mjs.map → ApiError-D-IBuHj6.cjs.map} +1 -1
  6. package/dist/LocaleConfig.d.ts +1 -59
  7. package/dist/LocaleConfig.js +1 -225
  8. package/dist/{base64-2fu94Klt.cjs → base64-C6BHySOc.cjs} +17 -1
  9. package/dist/base64-C6BHySOc.cjs.map +1 -0
  10. package/dist/{base64-DH0STixb.mjs → base64-CWITCfhU.mjs} +6 -2
  11. package/dist/base64-CWITCfhU.mjs.map +1 -0
  12. package/dist/core.cjs +9 -8
  13. package/dist/core.d.cts +1 -2
  14. package/dist/core.d.mts +1 -2
  15. package/dist/core.d.ts +1 -128
  16. package/dist/core.js +1 -137
  17. package/dist/core.mjs +2 -2
  18. package/dist/derive/indexVars.d.ts +1 -1
  19. package/dist/errors.cjs +1 -1
  20. package/dist/errors.mjs +1 -1
  21. package/dist/id/types.d.ts +1 -1
  22. package/dist/{id-CyiXsQrY.cjs → id-C2orn1MA.cjs} +2 -2
  23. package/dist/{id-CyiXsQrY.cjs.map → id-C2orn1MA.cjs.map} +1 -1
  24. package/dist/{id-DbD7K-HL.mjs → id-DEaFhGqX.mjs} +2 -2
  25. package/dist/{id-DbD7K-HL.mjs.map → id-DEaFhGqX.mjs.map} +1 -1
  26. package/dist/id.cjs +1 -1
  27. package/dist/id.d.cts +1 -1
  28. package/dist/id.d.mts +1 -1
  29. package/dist/id.mjs +1 -1
  30. package/dist/index.cjs +368 -385
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +4 -242
  33. package/dist/index.d.mts +4 -242
  34. package/dist/index.d.ts +5 -238
  35. package/dist/index.js +3 -322
  36. package/dist/index.mjs +215 -352
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/internal.cjs +6 -6
  39. package/dist/internal.cjs.map +1 -1
  40. package/dist/internal.d.cts +6 -5
  41. package/dist/internal.d.mts +6 -5
  42. package/dist/internal.mjs +4 -4
  43. package/dist/internal.mjs.map +1 -1
  44. package/dist/{isVariable-B08mggBy.cjs → isVariable-Ba1gLXdB.cjs} +1 -1
  45. package/dist/{isVariable-B08mggBy.cjs.map → isVariable-Ba1gLXdB.cjs.map} +1 -1
  46. package/dist/{isVariable-CYsKFHvR.mjs → isVariable-fAKEB7gF.mjs} +1 -1
  47. package/dist/{isVariable-CYsKFHvR.mjs.map → isVariable-fAKEB7gF.mjs.map} +1 -1
  48. package/dist/locales/getPluralForm.js +2 -2
  49. package/dist/logging/logger.d.ts +0 -3
  50. package/dist/logging/logger.js +0 -3
  51. package/dist/{types-AHtYZIP-.d.mts → types-73XFwmhH.d.mts} +7 -106
  52. package/dist/{types-Bf8_Apq_.d.cts → types-YrrGRHBP.d.cts} +7 -106
  53. package/dist/types-dir/api/enqueueEntries.d.ts +1 -1
  54. package/dist/types-dir/api/enqueueFiles.d.ts +1 -1
  55. package/dist/types-dir/api/fetchTranslations.d.ts +1 -1
  56. package/dist/types-dir/api/file.d.ts +1 -1
  57. package/dist/types-dir/api/translate.d.ts +1 -1
  58. package/dist/types-dir/api/uploadFiles.d.ts +1 -1
  59. package/dist/types.cjs +7 -16
  60. package/dist/types.d.cts +2 -2
  61. package/dist/types.d.mts +2 -2
  62. package/dist/types.d.ts +10 -12
  63. package/dist/types.js +1 -2
  64. package/dist/types.mjs +1 -15
  65. package/package.json +3 -2
  66. package/dist/IntlCache-CAW8tKhd.cjs +0 -212
  67. package/dist/IntlCache-CAW8tKhd.cjs.map +0 -1
  68. package/dist/IntlCache-WZk0rKvj.mjs +0 -195
  69. package/dist/IntlCache-WZk0rKvj.mjs.map +0 -1
  70. package/dist/base64-2fu94Klt.cjs.map +0 -1
  71. package/dist/base64-DH0STixb.mjs.map +0 -1
  72. package/dist/cache/IntlCache.d.ts +0 -26
  73. package/dist/cache/IntlCache.js +0 -84
  74. package/dist/cache/types.d.ts +0 -32
  75. package/dist/cache/types.js +0 -1
  76. package/dist/core-7RP541eY.cjs +0 -1677
  77. package/dist/core-7RP541eY.cjs.map +0 -1
  78. package/dist/core-I9pWGafA.d.mts +0 -209
  79. package/dist/core-TLJoDpJP.d.cts +0 -209
  80. package/dist/core-isLphYAZ.mjs +0 -1498
  81. package/dist/core-isLphYAZ.mjs.map +0 -1
  82. package/dist/errors/formattingErrors.d.ts +0 -1
  83. package/dist/errors/formattingErrors.js +0 -3
  84. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +0 -59
  85. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.js +0 -147
  86. package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +0 -4
  87. package/dist/formatting/custom-formats/CutoffFormat/constants.js +0 -30
  88. package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +0 -48
  89. package/dist/formatting/custom-formats/CutoffFormat/types.js +0 -2
  90. package/dist/formatting/format.d.ts +0 -1
  91. package/dist/formatting/format.js +0 -257
  92. package/dist/locales/customLocaleMapping.d.ts +0 -11
  93. package/dist/locales/customLocaleMapping.js +0 -23
  94. package/dist/locales/determineLocale.d.ts +0 -1
  95. package/dist/locales/determineLocale.js +0 -72
  96. package/dist/locales/getLocaleDirection.d.ts +0 -1
  97. package/dist/locales/getLocaleDirection.js +0 -89
  98. package/dist/locales/getLocaleEmoji.d.ts +0 -2
  99. package/dist/locales/getLocaleEmoji.js +0 -319
  100. package/dist/locales/getLocaleName.d.ts +0 -1
  101. package/dist/locales/getLocaleName.js +0 -45
  102. package/dist/locales/getLocaleProperties.d.ts +0 -32
  103. package/dist/locales/getLocaleProperties.js +0 -220
  104. package/dist/locales/getRegionProperties.d.ts +0 -7
  105. package/dist/locales/getRegionProperties.js +0 -61
  106. package/dist/locales/isSameDialect.d.ts +0 -1
  107. package/dist/locales/isSameDialect.js +0 -41
  108. package/dist/locales/isSameLanguage.d.ts +0 -1
  109. package/dist/locales/isSameLanguage.js +0 -20
  110. package/dist/locales/isSupersetLocale.d.ts +0 -1
  111. package/dist/locales/isSupersetLocale.js +0 -22
  112. package/dist/locales/isValidLocale.d.ts +0 -1
  113. package/dist/locales/isValidLocale.js +0 -75
  114. package/dist/locales/requiresTranslation.d.ts +0 -1
  115. package/dist/locales/requiresTranslation.js +0 -32
  116. package/dist/locales/resolveAliasLocale.d.ts +0 -8
  117. package/dist/locales/resolveAliasLocale.js +0 -21
  118. package/dist/locales/resolveCanonicalLocale.d.ts +0 -8
  119. package/dist/locales/resolveCanonicalLocale.js +0 -13
  120. package/dist/logging/warnings.d.ts +0 -2
  121. package/dist/logging/warnings.js +0 -2
  122. package/dist/types-dir/jsx/content.d.ts +0 -61
  123. package/dist/types-dir/jsx/content.js +0 -11
  124. package/dist/types-dir/jsx/variables.d.ts +0 -9
  125. package/dist/types-dir/jsx/variables.js +0 -1
  126. package/dist/types.cjs.map +0 -1
  127. package/dist/types.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # generaltranslation
2
2
 
3
+ ## 8.2.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1397](https://github.com/generaltranslation/gt/pull/1397) [`73f3ac1`](https://github.com/generaltranslation/gt/commit/73f3ac1308df11c1e6230c13c1999bfc5f6afc99) Thanks [@bgub](https://github.com/bgub)! - Extract locale and formatting primitives into the new `@generaltranslation/format` package and update `generaltranslation/core` to re-export the shared helpers.
8
+
9
+ - [#1408](https://github.com/generaltranslation/gt/pull/1408) [`425d3e4`](https://github.com/generaltranslation/gt/commit/425d3e4e6c61afd108c65c27f7693ba2470b33c6) Thanks [@bgub](https://github.com/bgub)! - Use @generaltranslation/format directly for shared formatting and locale helpers.
10
+
11
+ - Updated dependencies [[`73f3ac1`](https://github.com/generaltranslation/gt/commit/73f3ac1308df11c1e6230c13c1999bfc5f6afc99)]:
12
+ - @generaltranslation/format@0.1.0
13
+
3
14
  ## 8.2.13
4
15
 
5
16
  ### Patch Changes
@@ -16,4 +16,4 @@ var ApiError = class extends Error {
16
16
  //#endregion
17
17
  export { ApiError as t };
18
18
 
19
- //# sourceMappingURL=ApiError-IYfaOR30.mjs.map
19
+ //# sourceMappingURL=ApiError-0DxxIHLp.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApiError-CZ45tkW6.cjs","names":[],"sources":["../src/errors/ApiError.ts"],"sourcesContent":["export class ApiError extends Error {\n public code: number;\n public message: string;\n\n constructor(error: string, code: number, message: string) {\n super(error);\n this.name = 'ApiError';\n this.code = code;\n this.message = message;\n }\n\n getCode() {\n return this.code;\n }\n\n getMessage() {\n return this.message;\n }\n}\n"],"mappings":";AAAA,IAAa,WAAb,cAA8B,MAAM;CAIlC,YAAY,OAAe,MAAc,SAAiB;AACxD,QAAM,MAAM;AACZ,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,UAAU;;CAGjB,UAAU;AACR,SAAO,KAAK;;CAGd,aAAa;AACX,SAAO,KAAK"}
1
+ {"version":3,"file":"ApiError-0DxxIHLp.mjs","names":[],"sources":["../src/errors/ApiError.ts"],"sourcesContent":["export class ApiError extends Error {\n public code: number;\n public message: string;\n\n constructor(error: string, code: number, message: string) {\n super(error);\n this.name = 'ApiError';\n this.code = code;\n this.message = message;\n }\n\n getCode() {\n return this.code;\n }\n\n getMessage() {\n return this.message;\n }\n}\n"],"mappings":";AAAA,IAAa,WAAb,cAA8B,MAAM;CAIlC,YAAY,OAAe,MAAc,SAAiB;AACxD,QAAM,MAAM;AACZ,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,UAAU;;CAGjB,UAAU;AACR,SAAO,KAAK;;CAGd,aAAa;AACX,SAAO,KAAK"}
@@ -21,4 +21,4 @@ Object.defineProperty(exports, "ApiError", {
21
21
  }
22
22
  });
23
23
 
24
- //# sourceMappingURL=ApiError-CZ45tkW6.cjs.map
24
+ //# sourceMappingURL=ApiError-D-IBuHj6.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApiError-IYfaOR30.mjs","names":[],"sources":["../src/errors/ApiError.ts"],"sourcesContent":["export class ApiError extends Error {\n public code: number;\n public message: string;\n\n constructor(error: string, code: number, message: string) {\n super(error);\n this.name = 'ApiError';\n this.code = code;\n this.message = message;\n }\n\n getCode() {\n return this.code;\n }\n\n getMessage() {\n return this.message;\n }\n}\n"],"mappings":";AAAA,IAAa,WAAb,cAA8B,MAAM;CAIlC,YAAY,OAAe,MAAc,SAAiB;AACxD,QAAM,MAAM;AACZ,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,UAAU;;CAGjB,UAAU;AACR,SAAO,KAAK;;CAGd,aAAa;AACX,SAAO,KAAK"}
1
+ {"version":3,"file":"ApiError-D-IBuHj6.cjs","names":[],"sources":["../src/errors/ApiError.ts"],"sourcesContent":["export class ApiError extends Error {\n public code: number;\n public message: string;\n\n constructor(error: string, code: number, message: string) {\n super(error);\n this.name = 'ApiError';\n this.code = code;\n this.message = message;\n }\n\n getCode() {\n return this.code;\n }\n\n getMessage() {\n return this.message;\n }\n}\n"],"mappings":";AAAA,IAAa,WAAb,cAA8B,MAAM;CAIlC,YAAY,OAAe,MAAc,SAAiB;AACxD,QAAM,MAAM;AACZ,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,UAAU;;CAGjB,UAAU;AACR,SAAO,KAAK;;CAGd,aAAa;AACX,SAAO,KAAK"}
@@ -1,59 +1 @@
1
- import { CustomMapping, FormatVariables } from './types';
2
- import { CutoffFormatOptions } from './formatting/custom-formats/CutoffFormat/types';
3
- import { StringFormat } from './types-dir/jsx/content';
4
- export type LocaleConfigConstructorParams = {
5
- defaultLocale?: string;
6
- locales?: string[];
7
- customMapping?: CustomMapping;
8
- };
9
- type LocalesOption = {
10
- locales?: string | string[];
11
- };
12
- type WithLocales<T = object> = T & LocalesOption;
13
- /**
14
- * LocaleConfig contains the locale and formatting primitives exposed through
15
- * the core entrypoint.
16
- *
17
- * It intentionally does not store project IDs, API keys, runtime URLs, or any
18
- * translation credentials. It only stores locale metadata needed to resolve
19
- * aliases, choose formatting fallbacks, and format values with Intl.
20
- */
21
- export declare class LocaleConfig {
22
- readonly defaultLocale: string;
23
- readonly locales: string[];
24
- readonly customMapping?: CustomMapping;
25
- constructor({ defaultLocale, locales, customMapping, }?: LocaleConfigConstructorParams);
26
- private get translationLocales();
27
- private resolveCanonicalLocaleList;
28
- private resolveCanonicalLocaleArgs;
29
- private toLocaleList;
30
- private getFormattingLocales;
31
- formatNum(value: number, targetLocale?: string, options?: WithLocales<Intl.NumberFormatOptions>): string;
32
- formatDateTime(value: Date, targetLocale?: string, options?: WithLocales<Intl.DateTimeFormatOptions>): string;
33
- formatCurrency(value: number, currency: string, targetLocale?: string, options?: WithLocales<Intl.NumberFormatOptions>): string;
34
- formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, targetLocale?: string, options?: WithLocales<Intl.RelativeTimeFormatOptions>): string;
35
- formatRelativeTimeFromDate(date: Date, targetLocale?: string, options?: WithLocales<Intl.RelativeTimeFormatOptions & {
36
- baseDate?: Date;
37
- }>): string;
38
- formatCutoff(value: string, targetLocale?: string, options?: WithLocales<CutoffFormatOptions>): string;
39
- formatMessage(message: string, targetLocale?: string, options?: WithLocales<{
40
- variables?: FormatVariables;
41
- dataFormat?: StringFormat;
42
- }>): string;
43
- formatList(array: Array<string | number>, targetLocale?: string, options?: WithLocales<Intl.ListFormatOptions>): string;
44
- formatListToParts<T>(array: Array<T>, targetLocale?: string, options?: WithLocales<Intl.ListFormatOptions>): (string | T)[];
45
- getLocaleName(locale: string): string;
46
- getLocaleEmoji(locale: string): string;
47
- getLocaleProperties(locale: string): import("./types").LocaleProperties;
48
- requiresTranslation(targetLocale: string, sourceLocale?: string, approvedLocales?: string[] | undefined): boolean;
49
- determineLocale(locales: string | string[], approvedLocales?: string[]): string | undefined;
50
- getLocaleDirection(locale: string): "ltr" | "rtl";
51
- isValidLocale(locale: string): boolean;
52
- resolveCanonicalLocale(locale: string): string;
53
- resolveAliasLocale(locale: string): string;
54
- standardizeLocale(locale: string): string;
55
- isSameDialect(...locales: (string | string[])[]): boolean;
56
- isSameLanguage(...locales: (string | string[])[]): boolean;
57
- isSupersetLocale(superLocale: string, subLocale: string): boolean;
58
- }
59
- export {};
1
+ export { LocaleConfig, type LocaleConfigConstructorParams, } from '@generaltranslation/format';
@@ -1,225 +1 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { _formatCurrency, _formatCutoff, _formatDateTime, _formatList, _formatListToParts, _formatMessageICU, _formatMessageString, _formatNum, _formatRelativeTime, _formatRelativeTimeFromDate, } from './formatting/format';
13
- import _requiresTranslation from './locales/requiresTranslation';
14
- import _determineLocale from './locales/determineLocale';
15
- import _isSameLanguage from './locales/isSameLanguage';
16
- import _getLocaleProperties from './locales/getLocaleProperties';
17
- import _getLocaleEmoji from './locales/getLocaleEmoji';
18
- import { _isValidLocale, _standardizeLocale } from './locales/isValidLocale';
19
- import { _getLocaleName } from './locales/getLocaleName';
20
- import { _getLocaleDirection } from './locales/getLocaleDirection';
21
- import { libraryDefaultLocale } from './settings/settings';
22
- import _isSameDialect from './locales/isSameDialect';
23
- import _isSupersetLocale from './locales/isSupersetLocale';
24
- import { _resolveAliasLocale } from './locales/resolveAliasLocale';
25
- import { _resolveCanonicalLocale } from './locales/resolveCanonicalLocale';
26
- /**
27
- * LocaleConfig contains the locale and formatting primitives exposed through
28
- * the core entrypoint.
29
- *
30
- * It intentionally does not store project IDs, API keys, runtime URLs, or any
31
- * translation credentials. It only stores locale metadata needed to resolve
32
- * aliases, choose formatting fallbacks, and format values with Intl.
33
- */
34
- var LocaleConfig = /** @class */ (function () {
35
- function LocaleConfig(_a) {
36
- var _b = _a === void 0 ? {} : _a, _c = _b.defaultLocale, defaultLocale = _c === void 0 ? libraryDefaultLocale : _c, _d = _b.locales, locales = _d === void 0 ? [] : _d, customMapping = _b.customMapping;
37
- this.defaultLocale = defaultLocale;
38
- this.locales = locales;
39
- this.customMapping = customMapping;
40
- }
41
- Object.defineProperty(LocaleConfig.prototype, "translationLocales", {
42
- get: function () {
43
- return this.locales.length ? this.locales : undefined;
44
- },
45
- enumerable: false,
46
- configurable: true
47
- });
48
- LocaleConfig.prototype.resolveCanonicalLocaleList = function (locales) {
49
- var _this = this;
50
- return locales.map(function (locale) { return _this.resolveCanonicalLocale(locale); });
51
- };
52
- LocaleConfig.prototype.resolveCanonicalLocaleArgs = function (locales) {
53
- var _this = this;
54
- return locales.map(function (locale) {
55
- return Array.isArray(locale)
56
- ? _this.resolveCanonicalLocaleList(locale)
57
- : _this.resolveCanonicalLocale(locale);
58
- });
59
- };
60
- LocaleConfig.prototype.toLocaleList = function (locales) {
61
- return Array.isArray(locales) ? locales : [locales];
62
- };
63
- LocaleConfig.prototype.getFormattingLocales = function (targetLocale, locales) {
64
- var _this = this;
65
- var localeList = locales !== undefined
66
- ? this.toLocaleList(locales)
67
- : [targetLocale, this.defaultLocale, libraryDefaultLocale];
68
- return localeList
69
- .filter(function (locale) { return !!locale; })
70
- .map(function (locale) { return _this.resolveCanonicalLocale(locale); });
71
- };
72
- LocaleConfig.prototype.formatNum = function (value, targetLocale, options) {
73
- if (options === void 0) { options = {}; }
74
- var locales = options.locales, intlOptions = __rest(options, ["locales"]);
75
- return _formatNum({
76
- value: value,
77
- locales: this.getFormattingLocales(targetLocale, locales),
78
- options: intlOptions,
79
- });
80
- };
81
- LocaleConfig.prototype.formatDateTime = function (value, targetLocale, options) {
82
- if (options === void 0) { options = {}; }
83
- var locales = options.locales, intlOptions = __rest(options, ["locales"]);
84
- return _formatDateTime({
85
- value: value,
86
- locales: this.getFormattingLocales(targetLocale, locales),
87
- options: intlOptions,
88
- });
89
- };
90
- LocaleConfig.prototype.formatCurrency = function (value, currency, targetLocale, options) {
91
- if (options === void 0) { options = {}; }
92
- var locales = options.locales, intlOptions = __rest(options, ["locales"]);
93
- return _formatCurrency({
94
- value: value,
95
- currency: currency,
96
- locales: this.getFormattingLocales(targetLocale, locales),
97
- options: intlOptions,
98
- });
99
- };
100
- LocaleConfig.prototype.formatRelativeTime = function (value, unit, targetLocale, options) {
101
- if (options === void 0) { options = {}; }
102
- var locales = options.locales, intlOptions = __rest(options, ["locales"]);
103
- return _formatRelativeTime({
104
- value: value,
105
- unit: unit,
106
- locales: this.getFormattingLocales(targetLocale, locales),
107
- options: intlOptions,
108
- });
109
- };
110
- LocaleConfig.prototype.formatRelativeTimeFromDate = function (date, targetLocale, options) {
111
- if (options === void 0) { options = {}; }
112
- var locales = options.locales, baseDate = options.baseDate, intlOptions = __rest(options, ["locales", "baseDate"]);
113
- return _formatRelativeTimeFromDate({
114
- date: date,
115
- baseDate: baseDate !== null && baseDate !== void 0 ? baseDate : new Date(),
116
- locales: this.getFormattingLocales(targetLocale, locales),
117
- options: intlOptions,
118
- });
119
- };
120
- LocaleConfig.prototype.formatCutoff = function (value, targetLocale, options) {
121
- if (options === void 0) { options = {}; }
122
- var locales = options.locales, formatOptions = __rest(options, ["locales"]);
123
- return _formatCutoff({
124
- value: value,
125
- locales: this.getFormattingLocales(targetLocale, locales),
126
- options: formatOptions,
127
- });
128
- };
129
- LocaleConfig.prototype.formatMessage = function (message, targetLocale, options) {
130
- if (options === void 0) { options = {}; }
131
- var locales = options.locales, variables = options.variables, dataFormat = options.dataFormat;
132
- if (dataFormat === 'STRING')
133
- return _formatMessageString(message);
134
- return _formatMessageICU(message, this.getFormattingLocales(targetLocale, locales), variables);
135
- };
136
- LocaleConfig.prototype.formatList = function (array, targetLocale, options) {
137
- if (options === void 0) { options = {}; }
138
- var locales = options.locales, intlOptions = __rest(options, ["locales"]);
139
- return _formatList({
140
- value: array,
141
- locales: this.getFormattingLocales(targetLocale, locales),
142
- options: intlOptions,
143
- });
144
- };
145
- LocaleConfig.prototype.formatListToParts = function (array, targetLocale, options) {
146
- if (options === void 0) { options = {}; }
147
- var locales = options.locales, intlOptions = __rest(options, ["locales"]);
148
- return _formatListToParts({
149
- value: array,
150
- locales: this.getFormattingLocales(targetLocale, locales),
151
- options: intlOptions,
152
- });
153
- };
154
- LocaleConfig.prototype.getLocaleName = function (locale) {
155
- return _getLocaleName(locale, this.defaultLocale, this.customMapping);
156
- };
157
- LocaleConfig.prototype.getLocaleEmoji = function (locale) {
158
- return _getLocaleEmoji(locale, this.customMapping);
159
- };
160
- LocaleConfig.prototype.getLocaleProperties = function (locale) {
161
- return _getLocaleProperties(locale, this.defaultLocale, this.customMapping);
162
- };
163
- LocaleConfig.prototype.requiresTranslation = function (targetLocale, sourceLocale, approvedLocales) {
164
- if (sourceLocale === void 0) { sourceLocale = this.defaultLocale; }
165
- if (approvedLocales === void 0) { approvedLocales = this.translationLocales; }
166
- return _requiresTranslation(this.resolveCanonicalLocale(sourceLocale), this.resolveCanonicalLocale(targetLocale), approvedLocales
167
- ? this.resolveCanonicalLocaleList(approvedLocales)
168
- : undefined, this.customMapping);
169
- };
170
- LocaleConfig.prototype.determineLocale = function (locales, approvedLocales) {
171
- var _this = this;
172
- var _a;
173
- if (approvedLocales === void 0) { approvedLocales = this.locales; }
174
- var approvedLocalePairs = approvedLocales.map(function (locale) { return ({
175
- locale: locale,
176
- canonicalLocale: _this.resolveCanonicalLocale(locale),
177
- }); });
178
- var resolvedLocale = _determineLocale(Array.isArray(locales)
179
- ? this.resolveCanonicalLocaleList(locales)
180
- : this.resolveCanonicalLocale(locales), approvedLocalePairs.map(function (_a) {
181
- var canonicalLocale = _a.canonicalLocale;
182
- return canonicalLocale;
183
- }), this.customMapping);
184
- if (!resolvedLocale)
185
- return undefined;
186
- return (((_a = approvedLocalePairs.find(function (_a) {
187
- var canonicalLocale = _a.canonicalLocale;
188
- return canonicalLocale === resolvedLocale;
189
- })) === null || _a === void 0 ? void 0 : _a.locale) || this.resolveAliasLocale(resolvedLocale));
190
- };
191
- LocaleConfig.prototype.getLocaleDirection = function (locale) {
192
- return _getLocaleDirection(this.resolveCanonicalLocale(locale));
193
- };
194
- LocaleConfig.prototype.isValidLocale = function (locale) {
195
- return _isValidLocale(locale, this.customMapping);
196
- };
197
- LocaleConfig.prototype.resolveCanonicalLocale = function (locale) {
198
- return _resolveCanonicalLocale(locale, this.customMapping);
199
- };
200
- LocaleConfig.prototype.resolveAliasLocale = function (locale) {
201
- return _resolveAliasLocale(locale, this.customMapping);
202
- };
203
- LocaleConfig.prototype.standardizeLocale = function (locale) {
204
- return _standardizeLocale(locale);
205
- };
206
- LocaleConfig.prototype.isSameDialect = function () {
207
- var locales = [];
208
- for (var _i = 0; _i < arguments.length; _i++) {
209
- locales[_i] = arguments[_i];
210
- }
211
- return _isSameDialect.apply(void 0, this.resolveCanonicalLocaleArgs(locales));
212
- };
213
- LocaleConfig.prototype.isSameLanguage = function () {
214
- var locales = [];
215
- for (var _i = 0; _i < arguments.length; _i++) {
216
- locales[_i] = arguments[_i];
217
- }
218
- return _isSameLanguage.apply(void 0, this.resolveCanonicalLocaleArgs(locales));
219
- };
220
- LocaleConfig.prototype.isSupersetLocale = function (superLocale, subLocale) {
221
- return _isSupersetLocale(this.resolveCanonicalLocale(superLocale), this.resolveCanonicalLocale(subLocale));
222
- };
223
- return LocaleConfig;
224
- }());
225
- export { LocaleConfig };
1
+ export { LocaleConfig, } from '@generaltranslation/format';
@@ -1,3 +1,7 @@
1
+ //#region src/settings/settings.ts
2
+ const libraryDefaultLocale = "en";
3
+ const defaultTimeout = 6e4;
4
+ //#endregion
1
5
  //#region src/settings/settingsUrls.ts
2
6
  const defaultCacheUrl = "https://cdn.gtx.dev";
3
7
  const defaultBaseUrl = "https://api2.gtx.dev";
@@ -89,6 +93,12 @@ Object.defineProperty(exports, "defaultRuntimeApiUrl", {
89
93
  return defaultRuntimeApiUrl;
90
94
  }
91
95
  });
96
+ Object.defineProperty(exports, "defaultTimeout", {
97
+ enumerable: true,
98
+ get: function() {
99
+ return defaultTimeout;
100
+ }
101
+ });
92
102
  Object.defineProperty(exports, "encode", {
93
103
  enumerable: true,
94
104
  get: function() {
@@ -101,6 +111,12 @@ Object.defineProperty(exports, "isSupportedFileFormatTransform", {
101
111
  return isSupportedFileFormatTransform;
102
112
  }
103
113
  });
114
+ Object.defineProperty(exports, "libraryDefaultLocale", {
115
+ enumerable: true,
116
+ get: function() {
117
+ return libraryDefaultLocale;
118
+ }
119
+ });
104
120
  Object.defineProperty(exports, "validateFileFormatTransforms", {
105
121
  enumerable: true,
106
122
  get: function() {
@@ -108,4 +124,4 @@ Object.defineProperty(exports, "validateFileFormatTransforms", {
108
124
  }
109
125
  });
110
126
 
111
- //# sourceMappingURL=base64-2fu94Klt.cjs.map
127
+ //# sourceMappingURL=base64-C6BHySOc.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64-C6BHySOc.cjs","names":[],"sources":["../src/settings/settings.ts","../src/settings/settingsUrls.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/utils/base64.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\n","export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api2.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://runtime2.gtx.dev' as const;\n","import type { FileFormat } from '../types-dir/api/file';\n\nconst SUPPORTED_TRANSFORMATIONS = {\n GTJSON: ['GTJSON'],\n JSON: ['JSON'],\n PO: ['PO'],\n // POT templates can produce translated PO catalog files.\n POT: ['POT', 'PO'],\n YAML: ['YAML'],\n MDX: ['MDX'],\n MD: ['MD'],\n TS: ['TS'],\n JS: ['JS'],\n HTML: ['HTML'],\n TXT: ['TXT'],\n TWILIO_CONTENT_JSON: ['TWILIO_CONTENT_JSON'],\n} as const satisfies Record<FileFormat, FileFormat[]>;\n\n/**\n * This function checks if a file format transformation is supported during translation\n * @param from - The source file format.\n * @param to - The target file format.\n * @returns True if the transformation is supported, false otherwise\n */\nexport function isSupportedFileFormatTransform(\n from: FileFormat,\n to: FileFormat\n): boolean {\n const toFormats: FileFormat[] | undefined = SUPPORTED_TRANSFORMATIONS[from];\n return toFormats?.includes(to) ?? false;\n}\n","import type { FileFormat } from '../../types-dir/api/file';\nimport { isSupportedFileFormatTransform } from '../../utils/isSupportedFileFormatTransform';\n\nexport type FileFormatTransformInput = {\n fileFormat?: FileFormat;\n transformFormat?: FileFormat;\n fileName?: string;\n fileId?: string;\n};\n\n/**\n * Returns a user-facing validation error when a requested file format transform\n * is missing source format context or is not currently supported.\n */\nexport function getFileFormatTransformError(\n file: FileFormatTransformInput\n): string | undefined {\n if (!file.transformFormat) return undefined;\n const fileLabel = file.fileName ?? file.fileId ?? 'unknown file';\n if (!file.fileFormat) {\n return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n }\n if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) {\n return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n }\n return undefined;\n}\n\n/**\n * Validates file format transforms before sending upload/enqueue requests.\n */\nexport function validateFileFormatTransforms(\n files: FileFormatTransformInput[]\n): void {\n for (const file of files) {\n const error = getFileFormatTransformError(file);\n if (error) throw new Error(error);\n }\n}\n","// Encode a string to base64\nexport function encode(data: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path.\n return Buffer.from(data, 'utf8').toString('base64');\n }\n // Browser path.\n const bytes = new TextEncoder().encode(data);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n// Decode a base64 string to a string\nexport function decode(base64: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path.\n return Buffer.from(base64, 'base64').toString('utf8');\n }\n // Browser path.\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return new TextDecoder().decode(bytes);\n}\n"],"mappings":";AAAA,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;;;ACD9B,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;;;ACApC,MAAM,4BAA4B;CAChC,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,OAAO;CACd,IAAI,CAAC,KAAK;CAEV,KAAK,CAAC,OAAO,KAAK;CAClB,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,qBAAqB,CAAC,sBAAsB;CAC7C;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;;;;;ACfpC,SAAgB,4BACd,MACoB;AACpB,KAAI,CAAC,KAAK,gBAAiB,QAAO,KAAA;CAClC,MAAM,YAAY,KAAK,YAAY,KAAK,UAAU;AAClD,KAAI,CAAC,KAAK,WACR,QAAO,+DAA+D;AAExE,KAAI,CAAC,+BAA+B,KAAK,YAAY,KAAK,gBAAgB,CACxE,QAAO,sCAAsC,KAAK,WAAW,MAAM,KAAK;;;;;AAQ5E,SAAgB,6BACd,OACM;AACN,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,4BAA4B,KAAK;AAC/C,MAAI,MAAO,OAAM,IAAI,MAAM,MAAM;;;;;ACnCrC,SAAgB,OAAO,MAAsB;AAC3C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,SAAS;CAGrD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK;CAC5C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,WAAU,OAAO,aAAa,MAAM,GAAG;AAEzC,QAAO,KAAK,OAAO;;AAIrB,SAAgB,OAAO,QAAwB;AAC7C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,QAAQ,SAAS,CAAC,SAAS,OAAO;CAGvD,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,OAAO;AAC3C,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,OAAM,KAAK,OAAO,WAAW,EAAE;AAEjC,QAAO,IAAI,aAAa,CAAC,OAAO,MAAM"}
@@ -1,3 +1,7 @@
1
+ //#region src/settings/settings.ts
2
+ const libraryDefaultLocale = "en";
3
+ const defaultTimeout = 6e4;
4
+ //#endregion
1
5
  //#region src/settings/settingsUrls.ts
2
6
  const defaultCacheUrl = "https://cdn.gtx.dev";
3
7
  const defaultBaseUrl = "https://api2.gtx.dev";
@@ -65,6 +69,6 @@ function decode(base64) {
65
69
  return new TextDecoder().decode(bytes);
66
70
  }
67
71
  //#endregion
68
- export { defaultBaseUrl as a, isSupportedFileFormatTransform as i, encode as n, defaultCacheUrl as o, validateFileFormatTransforms as r, defaultRuntimeApiUrl as s, decode as t };
72
+ export { defaultBaseUrl as a, defaultTimeout as c, isSupportedFileFormatTransform as i, libraryDefaultLocale as l, encode as n, defaultCacheUrl as o, validateFileFormatTransforms as r, defaultRuntimeApiUrl as s, decode as t };
69
73
 
70
- //# sourceMappingURL=base64-DH0STixb.mjs.map
74
+ //# sourceMappingURL=base64-CWITCfhU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64-CWITCfhU.mjs","names":[],"sources":["../src/settings/settings.ts","../src/settings/settingsUrls.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/utils/base64.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\n","export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api2.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://runtime2.gtx.dev' as const;\n","import type { FileFormat } from '../types-dir/api/file';\n\nconst SUPPORTED_TRANSFORMATIONS = {\n GTJSON: ['GTJSON'],\n JSON: ['JSON'],\n PO: ['PO'],\n // POT templates can produce translated PO catalog files.\n POT: ['POT', 'PO'],\n YAML: ['YAML'],\n MDX: ['MDX'],\n MD: ['MD'],\n TS: ['TS'],\n JS: ['JS'],\n HTML: ['HTML'],\n TXT: ['TXT'],\n TWILIO_CONTENT_JSON: ['TWILIO_CONTENT_JSON'],\n} as const satisfies Record<FileFormat, FileFormat[]>;\n\n/**\n * This function checks if a file format transformation is supported during translation\n * @param from - The source file format.\n * @param to - The target file format.\n * @returns True if the transformation is supported, false otherwise\n */\nexport function isSupportedFileFormatTransform(\n from: FileFormat,\n to: FileFormat\n): boolean {\n const toFormats: FileFormat[] | undefined = SUPPORTED_TRANSFORMATIONS[from];\n return toFormats?.includes(to) ?? false;\n}\n","import type { FileFormat } from '../../types-dir/api/file';\nimport { isSupportedFileFormatTransform } from '../../utils/isSupportedFileFormatTransform';\n\nexport type FileFormatTransformInput = {\n fileFormat?: FileFormat;\n transformFormat?: FileFormat;\n fileName?: string;\n fileId?: string;\n};\n\n/**\n * Returns a user-facing validation error when a requested file format transform\n * is missing source format context or is not currently supported.\n */\nexport function getFileFormatTransformError(\n file: FileFormatTransformInput\n): string | undefined {\n if (!file.transformFormat) return undefined;\n const fileLabel = file.fileName ?? file.fileId ?? 'unknown file';\n if (!file.fileFormat) {\n return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n }\n if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) {\n return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n }\n return undefined;\n}\n\n/**\n * Validates file format transforms before sending upload/enqueue requests.\n */\nexport function validateFileFormatTransforms(\n files: FileFormatTransformInput[]\n): void {\n for (const file of files) {\n const error = getFileFormatTransformError(file);\n if (error) throw new Error(error);\n }\n}\n","// Encode a string to base64\nexport function encode(data: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path.\n return Buffer.from(data, 'utf8').toString('base64');\n }\n // Browser path.\n const bytes = new TextEncoder().encode(data);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n// Decode a base64 string to a string\nexport function decode(base64: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path.\n return Buffer.from(base64, 'base64').toString('utf8');\n }\n // Browser path.\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return new TextDecoder().decode(bytes);\n}\n"],"mappings":";AAAA,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;;;ACD9B,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;;;ACApC,MAAM,4BAA4B;CAChC,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,OAAO;CACd,IAAI,CAAC,KAAK;CAEV,KAAK,CAAC,OAAO,KAAK;CAClB,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,qBAAqB,CAAC,sBAAsB;CAC7C;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;;;;;ACfpC,SAAgB,4BACd,MACoB;AACpB,KAAI,CAAC,KAAK,gBAAiB,QAAO,KAAA;CAClC,MAAM,YAAY,KAAK,YAAY,KAAK,UAAU;AAClD,KAAI,CAAC,KAAK,WACR,QAAO,+DAA+D;AAExE,KAAI,CAAC,+BAA+B,KAAK,YAAY,KAAK,gBAAgB,CACxE,QAAO,sCAAsC,KAAK,WAAW,MAAM,KAAK;;;;;AAQ5E,SAAgB,6BACd,OACM;AACN,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,4BAA4B,KAAK;AAC/C,MAAI,MAAO,OAAM,IAAI,MAAM,MAAM;;;;;ACnCrC,SAAgB,OAAO,MAAsB;AAC3C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,SAAS;CAGrD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK;CAC5C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,WAAU,OAAO,aAAa,MAAM,GAAG;AAEzC,QAAO,KAAK,OAAO;;AAIrB,SAAgB,OAAO,QAAwB;AAC7C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,QAAQ,SAAS,CAAC,SAAS,OAAO;CAGvD,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,OAAO;AAC3C,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,OAAM,KAAK,OAAO,WAAW,EAAE;AAEjC,QAAO,IAAI,aAAa,CAAC,OAAO,MAAM"}
package/dist/core.cjs CHANGED
@@ -1,8 +1,9 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_core = require("./core-7RP541eY.cjs");
3
- exports.LocaleConfig = require_core.LocaleConfig;
4
- exports.formatCutoff = require_core.formatCutoff;
5
- exports.formatMessage = require_core.formatMessage;
6
- exports.isValidLocale = require_core.isValidLocale;
7
- exports.resolveCanonicalLocale = require_core.resolveCanonicalLocale;
8
- exports.standardizeLocale = require_core.standardizeLocale;
1
+ var _generaltranslation_format = require("@generaltranslation/format");
2
+ Object.keys(_generaltranslation_format).forEach(function(k) {
3
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
4
+ enumerable: true,
5
+ get: function() {
6
+ return _generaltranslation_format[k];
7
+ }
8
+ });
9
+ });
package/dist/core.d.cts CHANGED
@@ -1,2 +1 @@
1
- import { a as standardizeLocale, i as resolveCanonicalLocale, n as formatMessage, o as LocaleConfig, r as isValidLocale, s as LocaleConfigConstructorParams, t as formatCutoff } from "./core-TLJoDpJP.cjs";
2
- export { LocaleConfig, LocaleConfigConstructorParams, formatCutoff, formatMessage, isValidLocale, resolveCanonicalLocale, standardizeLocale };
1
+ export * from "@generaltranslation/format";
package/dist/core.d.mts CHANGED
@@ -1,2 +1 @@
1
- import { a as standardizeLocale, i as resolveCanonicalLocale, n as formatMessage, o as LocaleConfig, r as isValidLocale, s as LocaleConfigConstructorParams, t as formatCutoff } from "./core-I9pWGafA.mjs";
2
- export { LocaleConfig, LocaleConfigConstructorParams, formatCutoff, formatMessage, isValidLocale, resolveCanonicalLocale, standardizeLocale };
1
+ export * from "@generaltranslation/format";
package/dist/core.d.ts CHANGED
@@ -1,128 +1 @@
1
- import type { CutoffFormatOptions } from './formatting/custom-formats/CutoffFormat/types';
2
- import type { CustomMapping, FormatVariables } from './types';
3
- import type { StringFormat } from './types-dir/jsx/content';
4
- export { LocaleConfig, type LocaleConfigConstructorParams, } from './LocaleConfig';
5
- /**
6
- * Core formatting and locale helpers.
7
- *
8
- * This entry point exposes deterministic locale and formatting primitives. It
9
- * does not export the GT service client, project credentials, network
10
- * translation methods, file APIs, or other server/service concerns from the
11
- * root `generaltranslation` facade.
12
- *
13
- * This entry point is intended for framework and shared packages that need
14
- * locale metadata or formatting behavior without pulling in the full
15
- * translation API surface.
16
- */
17
- /**
18
- * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
19
- *
20
- * This standalone function provides cutoff formatting functionality without requiring a GT instance.
21
- * The locales parameter is required for proper terminator selection based on the target language.
22
- *
23
- * @param {string} value - The string value to format with cutoff behavior.
24
- * @param {Object} [options] - Configuration options for cutoff formatting.
25
- * @param {string | string[]} [options.locales] - The locales to use for terminator selection.
26
- * @param {number} [options.maxChars] - The maximum number of characters to display.
27
- * - Undefined values are treated as no cutoff.
28
- * - Negative values follow .slice() behavior and terminator will be added before the value.
29
- * - 0 will result in an empty string.
30
- * - If cutoff results in an empty string, no terminator is added.
31
- * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
32
- * @param {string} [options.terminator] - Optional override the terminator to use.
33
- * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
34
- * - If no terminator is provided, then separator is ignored.
35
- * @returns {string} The formatted string with terminator applied if cutoff occurs.
36
- *
37
- * @example
38
- * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });
39
- * // Returns: 'Hello, …'
40
- *
41
- * @example
42
- * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });
43
- * // Returns: '…d!'
44
- *
45
- * @example
46
- * formatCutoff('Very long text that needs cutting', {
47
- * locales: 'en-US',
48
- * maxChars: 15,
49
- * style: 'ellipsis',
50
- * separator: ' '
51
- * });
52
- * // Returns: 'Very long tex …'
53
- */
54
- export declare function formatCutoff(value: string, options?: {
55
- locales?: string | string[];
56
- } & CutoffFormatOptions): string;
57
- /**
58
- * Formats a message according to the specified locales and options.
59
- *
60
- * @param {string} message - The message to format.
61
- * @param {Object} [options] - Configuration options for message formatting.
62
- * @param {string | string[]} [options.locales] - The locales to use for formatting.
63
- * @param {FormatVariables} [options.variables] - The variables to use for formatting.
64
- * @param {StringFormat} [options.dataFormat='ICU'] - The format of the message. When STRING, the message is returned as is.
65
- * @returns {string} The formatted message.
66
- *
67
- * @example
68
- * formatMessage('Hello {name}', { variables: { name: 'John' } });
69
- * // Returns: "Hello John"
70
- *
71
- * @example
72
- * formatMessage('Hello {name}', {
73
- * locales: ['fr'],
74
- * variables: { name: 'John' }
75
- * });
76
- */
77
- export declare function formatMessage(message: string, options?: {
78
- locales?: string | string[];
79
- variables?: FormatVariables;
80
- dataFormat?: StringFormat;
81
- }): string;
82
- /**
83
- * Checks if a given BCP 47 locale code is valid.
84
- *
85
- * @param {string} locale - The BCP 47 locale code to validate.
86
- * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
87
- * @returns {boolean} True if the BCP 47 code is valid, false otherwise.
88
- *
89
- * @example
90
- * isValidLocale('en-US');
91
- * // Returns: true
92
- *
93
- * @example
94
- * isValidLocale('en_US');
95
- * // Returns: false
96
- */
97
- export declare function isValidLocale(locale: string, customMapping?: CustomMapping): boolean;
98
- /**
99
- * Resolves the canonical locale for a given locale.
100
- *
101
- * @param {string} locale - The locale to resolve the canonical locale for.
102
- * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the canonical locale.
103
- * @returns {string} The canonical locale, or the input locale when no canonical mapping exists.
104
- *
105
- * @example
106
- * resolveCanonicalLocale('en-US');
107
- * // Returns: 'en-US'
108
- *
109
- * @example
110
- * resolveCanonicalLocale('en', { en: 'en-US' });
111
- * // Returns: 'en-US'
112
- */
113
- export declare function resolveCanonicalLocale(locale: string, customMapping?: CustomMapping): string;
114
- /**
115
- * Standardizes a BCP 47 locale code to ensure correct formatting.
116
- *
117
- * @param {string} locale - The BCP 47 locale code to standardize.
118
- * @returns {string} The standardized BCP 47 locale code, or the input string if it cannot be standardized.
119
- *
120
- * @example
121
- * standardizeLocale('en-us');
122
- * // Returns: 'en-US'
123
- *
124
- * @example
125
- * standardizeLocale('not a locale');
126
- * // Returns: 'not a locale'
127
- */
128
- export declare function standardizeLocale(locale: string): string;
1
+ export * from '@generaltranslation/format';