generaltranslation 8.2.8 → 8.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/{ApiError-4zIP-twr.cjs → ApiError-CZ45tkW6.cjs} +1 -1
- package/dist/{ApiError-4zIP-twr.cjs.map → ApiError-CZ45tkW6.cjs.map} +1 -1
- package/dist/{ApiError-Bv7vlzyQ.mjs → ApiError-IYfaOR30.mjs} +1 -1
- package/dist/{ApiError-Bv7vlzyQ.mjs.map → ApiError-IYfaOR30.mjs.map} +1 -1
- package/dist/IntlCache-Ccg_cQPR.mjs +195 -0
- package/dist/IntlCache-Ccg_cQPR.mjs.map +1 -0
- package/dist/IntlCache-k2qfrDqB.cjs +212 -0
- package/dist/IntlCache-k2qfrDqB.cjs.map +1 -0
- package/dist/base64-C1sogiix.mjs +70 -0
- package/dist/base64-C1sogiix.mjs.map +1 -0
- package/dist/base64-CUcEPEC5.cjs +111 -0
- package/dist/base64-CUcEPEC5.cjs.map +1 -0
- package/dist/core-CJMv4fMa.d.cts +209 -0
- package/dist/core-DOrYXXpO.mjs +1487 -0
- package/dist/core-DOrYXXpO.mjs.map +1 -0
- package/dist/core-DtPj_ruw.d.mts +209 -0
- package/dist/core-LS3Pia40.cjs +1666 -0
- package/dist/core-LS3Pia40.cjs.map +1 -0
- package/dist/core.cjs +8 -0
- package/dist/core.d.cts +2 -0
- package/dist/core.d.mts +2 -0
- package/dist/core.mjs +2 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{id-CPbVYREY.mjs → id-BmOyfaug.mjs} +2 -2
- package/dist/{id-CPbVYREY.mjs.map → id-BmOyfaug.mjs.map} +1 -1
- package/dist/{id-VXBgyXu2.cjs → id-COlX5v3V.cjs} +6 -6
- package/dist/{id-VXBgyXu2.cjs.map → id-COlX5v3V.cjs.map} +1 -1
- package/dist/id.cjs +1 -1
- package/dist/id.d.cts +1 -1
- package/dist/id.d.mts +1 -1
- package/dist/id.mjs +1 -1
- package/dist/index.cjs +59 -1518
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -162
- package/dist/index.d.mts +4 -162
- package/dist/index.mjs +6 -1441
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +602 -44
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/internal.mjs +562 -2
- package/dist/internal.mjs.map +1 -0
- package/dist/{sha2-DKowBr6H.cjs → isVariable-B08mggBy.cjs} +18 -18
- package/dist/isVariable-B08mggBy.cjs.map +1 -0
- package/dist/{stableStringify-DgDlE_pD.mjs → isVariable-CYsKFHvR.mjs} +19 -19
- package/dist/isVariable-CYsKFHvR.mjs.map +1 -0
- package/dist/{types-DazaDJbs.d.mts → types-Dfy_sRLD.d.mts} +1 -1
- package/dist/{types-BJdoI1d1.d.cts → types-mZeu4HS3.d.cts} +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +17 -1
- package/dist/internal-B3QbyI_5.mjs +0 -820
- package/dist/internal-B3QbyI_5.mjs.map +0 -1
- package/dist/internal-DIHQF9gs.cjs +0 -1070
- package/dist/internal-DIHQF9gs.cjs.map +0 -1
- package/dist/sha2-DKowBr6H.cjs.map +0 -1
- package/dist/stableStringify-DgDlE_pD.mjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as standardizeLocale, c as CutoffFormatOptions, i as resolveCanonicalLocale, n as formatMessage, o as LocaleConfig, r as isValidLocale, s as LocaleConfigConstructorParams, t as formatCutoff } from "./core-CJMv4fMa.cjs";
|
|
2
|
+
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-mZeu4HS3.cjs";
|
|
2
3
|
|
|
3
4
|
//#region src/translate/setupProject.d.ts
|
|
4
5
|
type SetupProjectResult = {
|
|
@@ -53,84 +54,6 @@ type CreateBranchResult = {
|
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
56
|
//#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/LocaleConfig.d.ts
|
|
75
|
-
type LocaleConfigConstructorParams = {
|
|
76
|
-
defaultLocale?: string;
|
|
77
|
-
locales?: string[];
|
|
78
|
-
customMapping?: CustomMapping;
|
|
79
|
-
};
|
|
80
|
-
type LocalesOption = {
|
|
81
|
-
locales?: string | string[];
|
|
82
|
-
};
|
|
83
|
-
type WithLocales<T = object> = T & LocalesOption;
|
|
84
|
-
/**
|
|
85
|
-
* LocaleConfig is a client-safe locale and formatting helper.
|
|
86
|
-
*
|
|
87
|
-
* It intentionally does not store project IDs, API keys, runtime URLs, or any
|
|
88
|
-
* translation credentials. It only stores locale metadata needed to resolve
|
|
89
|
-
* aliases, choose formatting fallbacks, and format values with Intl.
|
|
90
|
-
*/
|
|
91
|
-
declare class LocaleConfig {
|
|
92
|
-
readonly defaultLocale: string;
|
|
93
|
-
readonly locales: string[];
|
|
94
|
-
readonly customMapping?: CustomMapping;
|
|
95
|
-
constructor({
|
|
96
|
-
defaultLocale,
|
|
97
|
-
locales,
|
|
98
|
-
customMapping
|
|
99
|
-
}?: LocaleConfigConstructorParams);
|
|
100
|
-
private get translationLocales();
|
|
101
|
-
private resolveCanonicalLocaleList;
|
|
102
|
-
private resolveCanonicalLocaleArgs;
|
|
103
|
-
private toLocaleList;
|
|
104
|
-
private getFormattingLocales;
|
|
105
|
-
formatNum(value: number, targetLocale?: string, options?: WithLocales<Intl.NumberFormatOptions>): string;
|
|
106
|
-
formatDateTime(value: Date, targetLocale?: string, options?: WithLocales<Intl.DateTimeFormatOptions>): string;
|
|
107
|
-
formatCurrency(value: number, currency: string, targetLocale?: string, options?: WithLocales<Intl.NumberFormatOptions>): string;
|
|
108
|
-
formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, targetLocale?: string, options?: WithLocales<Intl.RelativeTimeFormatOptions>): string;
|
|
109
|
-
formatRelativeTimeFromDate(date: Date, targetLocale?: string, options?: WithLocales<Intl.RelativeTimeFormatOptions & {
|
|
110
|
-
baseDate?: Date;
|
|
111
|
-
}>): string;
|
|
112
|
-
formatCutoff(value: string, targetLocale?: string, options?: WithLocales<CutoffFormatOptions>): string;
|
|
113
|
-
formatMessage(message: string, targetLocale?: string, options?: WithLocales<{
|
|
114
|
-
variables?: FormatVariables;
|
|
115
|
-
dataFormat?: StringFormat;
|
|
116
|
-
}>): string;
|
|
117
|
-
formatList(array: Array<string | number>, targetLocale?: string, options?: WithLocales<Intl.ListFormatOptions>): string;
|
|
118
|
-
formatListToParts<T>(array: Array<T>, targetLocale?: string, options?: WithLocales<Intl.ListFormatOptions>): (string | T)[];
|
|
119
|
-
getLocaleName(locale: string): string;
|
|
120
|
-
getLocaleEmoji(locale: string): string;
|
|
121
|
-
getLocaleProperties(locale: string): LocaleProperties;
|
|
122
|
-
requiresTranslation(targetLocale: string, sourceLocale?: string, approvedLocales?: string[] | undefined): boolean;
|
|
123
|
-
determineLocale(locales: string | string[], approvedLocales?: string[]): string | undefined;
|
|
124
|
-
getLocaleDirection(locale: string): "ltr" | "rtl";
|
|
125
|
-
isValidLocale(locale: string): boolean;
|
|
126
|
-
resolveCanonicalLocale(locale: string): string;
|
|
127
|
-
resolveAliasLocale(locale: string): string;
|
|
128
|
-
standardizeLocale(locale: string): string;
|
|
129
|
-
isSameDialect(...locales: (string | string[])[]): boolean;
|
|
130
|
-
isSameLanguage(...locales: (string | string[])[]): boolean;
|
|
131
|
-
isSupersetLocale(superLocale: string, subLocale: string): boolean;
|
|
132
|
-
}
|
|
133
|
-
//#endregion
|
|
134
57
|
//#region src/index.d.ts
|
|
135
58
|
/**
|
|
136
59
|
* Type representing the constructor parameters for the GT class.
|
|
@@ -189,9 +112,9 @@ declare class GT {
|
|
|
189
112
|
reverseCustomMapping?: Record<string, string>;
|
|
190
113
|
/** Lazily derived custom mapping for regions */
|
|
191
114
|
customRegionMapping?: CustomRegionMapping;
|
|
192
|
-
/**
|
|
115
|
+
/** Runtime-safe locale and formatting helpers (backing field) */
|
|
193
116
|
private _localeConfig;
|
|
194
|
-
/**
|
|
117
|
+
/** Runtime-safe locale and formatting helpers */
|
|
195
118
|
get localeConfig(): LocaleConfig;
|
|
196
119
|
/**
|
|
197
120
|
* Constructs an instance of the GT class.
|
|
@@ -902,67 +825,6 @@ declare class GT {
|
|
|
902
825
|
*/
|
|
903
826
|
isSupersetLocale(superLocale: string, subLocale: string): boolean;
|
|
904
827
|
}
|
|
905
|
-
/**
|
|
906
|
-
* Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
|
|
907
|
-
*
|
|
908
|
-
* This standalone function provides cutoff formatting functionality without requiring a GT instance.
|
|
909
|
-
* The locales parameter is required for proper terminator selection based on the target language.
|
|
910
|
-
*
|
|
911
|
-
* @param {string} value - The string value to format with cutoff behavior.
|
|
912
|
-
* @param {Object} [options] - Configuration options for cutoff formatting.
|
|
913
|
-
* @param {string | string[]} [options.locales] - The locales to use for terminator selection.
|
|
914
|
-
* @param {number} [options.maxChars] - The maximum number of characters to display.
|
|
915
|
-
* - Undefined values are treated as no cutoff.
|
|
916
|
-
* - Negative values follow .slice() behavior and terminator will be added before the value.
|
|
917
|
-
* - 0 will result in an empty string.
|
|
918
|
-
* - If cutoff results in an empty string, no terminator is added.
|
|
919
|
-
* @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
|
|
920
|
-
* @param {string} [options.terminator] - Optional override the terminator to use.
|
|
921
|
-
* @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
|
|
922
|
-
* - If no terminator is provided, then separator is ignored.
|
|
923
|
-
* @returns {string} The formatted string with terminator applied if cutoff occurs.
|
|
924
|
-
*
|
|
925
|
-
* @example
|
|
926
|
-
* formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });
|
|
927
|
-
* // Returns: 'Hello, w...'
|
|
928
|
-
*
|
|
929
|
-
* @example
|
|
930
|
-
* formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });
|
|
931
|
-
* // Returns: '...ld!'
|
|
932
|
-
*
|
|
933
|
-
* @example
|
|
934
|
-
* formatCutoff('Very long text that needs cutting', {
|
|
935
|
-
* locales: 'en-US',
|
|
936
|
-
* maxChars: 15,
|
|
937
|
-
* style: 'ellipsis',
|
|
938
|
-
* separator: ' '
|
|
939
|
-
* });
|
|
940
|
-
* // Returns: 'Very long text ...'
|
|
941
|
-
*/
|
|
942
|
-
declare function formatCutoff(value: string, options?: {
|
|
943
|
-
locales?: string | string[];
|
|
944
|
-
} & CutoffFormatOptions): string;
|
|
945
|
-
/**
|
|
946
|
-
* Formats a message according to the specified locales and options.
|
|
947
|
-
*
|
|
948
|
-
* @param {string} message - The message to format.
|
|
949
|
-
* @param {string | string[]} [locales='en'] - The locales to use for formatting.
|
|
950
|
-
* @param {FormatVariables} [variables={}] - The variables to use for formatting.
|
|
951
|
-
* @param {StringFormat} [dataFormat='ICU'] - The format of the message. (When STRING, the message is returned as is)
|
|
952
|
-
* @returns {string} The formatted message.
|
|
953
|
-
*
|
|
954
|
-
* @example
|
|
955
|
-
* formatMessage('Hello {name}', { name: 'John' });
|
|
956
|
-
* // Returns: "Hello John"
|
|
957
|
-
*
|
|
958
|
-
* formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });
|
|
959
|
-
* // Returns: "Bonjour John"
|
|
960
|
-
*/
|
|
961
|
-
declare function formatMessage(message: string, options?: {
|
|
962
|
-
locales?: string | string[];
|
|
963
|
-
variables?: FormatVariables;
|
|
964
|
-
dataFormat?: StringFormat;
|
|
965
|
-
}): string;
|
|
966
828
|
/**
|
|
967
829
|
* Formats a number according to the specified locales and options.
|
|
968
830
|
* @param {Object} params - The parameters for the number formatting.
|
|
@@ -1165,13 +1027,6 @@ declare function determineLocale(locales: string | string[], approvedLocales?: s
|
|
|
1165
1027
|
* @returns {string} - 'rtl' if the locale is right-to-left, otherwise 'ltr'.
|
|
1166
1028
|
*/
|
|
1167
1029
|
declare function getLocaleDirection(locale: string): 'ltr' | 'rtl';
|
|
1168
|
-
/**
|
|
1169
|
-
* Checks if a given BCP 47 locale code is valid.
|
|
1170
|
-
* @param {string} locale - The BCP 47 locale code to validate.
|
|
1171
|
-
* @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
|
|
1172
|
-
* @returns {boolean} True if the BCP 47 code is valid, false otherwise.
|
|
1173
|
-
*/
|
|
1174
|
-
declare function isValidLocale(locale: string, customMapping?: CustomMapping): boolean;
|
|
1175
1030
|
/**
|
|
1176
1031
|
* Resolves the alias locale for a given locale.
|
|
1177
1032
|
* @param {string} locale - The locale to resolve the alias locale for
|
|
@@ -1179,19 +1034,6 @@ declare function isValidLocale(locale: string, customMapping?: CustomMapping): b
|
|
|
1179
1034
|
* @returns {string} The alias locale
|
|
1180
1035
|
*/
|
|
1181
1036
|
declare function resolveAliasLocale(locale: string, customMapping?: CustomMapping): string;
|
|
1182
|
-
/**
|
|
1183
|
-
* Resolves the canonical locale for a given locale.
|
|
1184
|
-
* @param {string} locale - The locale to resolve the canonical locale for
|
|
1185
|
-
* @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the canonical locale
|
|
1186
|
-
* @returns {string} The canonical locale
|
|
1187
|
-
*/
|
|
1188
|
-
declare function resolveCanonicalLocale(locale: string, customMapping?: CustomMapping): string;
|
|
1189
|
-
/**
|
|
1190
|
-
* Standardizes a BCP 47 locale code to ensure correct formatting.
|
|
1191
|
-
* @param {string} locale - The BCP 47 locale code to standardize.
|
|
1192
|
-
* @returns {string} The standardized BCP 47 locale code or an empty string if it is an invalid code.
|
|
1193
|
-
*/
|
|
1194
|
-
declare function standardizeLocale(locale: string): string;
|
|
1195
1037
|
/**
|
|
1196
1038
|
* Checks if multiple BCP 47 locale codes represent the same dialect.
|
|
1197
1039
|
* @param {string[]} locales - The BCP 47 locale codes to compare.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as standardizeLocale, c as CutoffFormatOptions, i as resolveCanonicalLocale, n as formatMessage, o as LocaleConfig, r as isValidLocale, s as LocaleConfigConstructorParams, t as formatCutoff } from "./core-DtPj_ruw.mjs";
|
|
2
|
+
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-Dfy_sRLD.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/translate/setupProject.d.ts
|
|
4
5
|
type SetupProjectResult = {
|
|
@@ -53,84 +54,6 @@ type CreateBranchResult = {
|
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
56
|
//#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/LocaleConfig.d.ts
|
|
75
|
-
type LocaleConfigConstructorParams = {
|
|
76
|
-
defaultLocale?: string;
|
|
77
|
-
locales?: string[];
|
|
78
|
-
customMapping?: CustomMapping;
|
|
79
|
-
};
|
|
80
|
-
type LocalesOption = {
|
|
81
|
-
locales?: string | string[];
|
|
82
|
-
};
|
|
83
|
-
type WithLocales<T = object> = T & LocalesOption;
|
|
84
|
-
/**
|
|
85
|
-
* LocaleConfig is a client-safe locale and formatting helper.
|
|
86
|
-
*
|
|
87
|
-
* It intentionally does not store project IDs, API keys, runtime URLs, or any
|
|
88
|
-
* translation credentials. It only stores locale metadata needed to resolve
|
|
89
|
-
* aliases, choose formatting fallbacks, and format values with Intl.
|
|
90
|
-
*/
|
|
91
|
-
declare class LocaleConfig {
|
|
92
|
-
readonly defaultLocale: string;
|
|
93
|
-
readonly locales: string[];
|
|
94
|
-
readonly customMapping?: CustomMapping;
|
|
95
|
-
constructor({
|
|
96
|
-
defaultLocale,
|
|
97
|
-
locales,
|
|
98
|
-
customMapping
|
|
99
|
-
}?: LocaleConfigConstructorParams);
|
|
100
|
-
private get translationLocales();
|
|
101
|
-
private resolveCanonicalLocaleList;
|
|
102
|
-
private resolveCanonicalLocaleArgs;
|
|
103
|
-
private toLocaleList;
|
|
104
|
-
private getFormattingLocales;
|
|
105
|
-
formatNum(value: number, targetLocale?: string, options?: WithLocales<Intl.NumberFormatOptions>): string;
|
|
106
|
-
formatDateTime(value: Date, targetLocale?: string, options?: WithLocales<Intl.DateTimeFormatOptions>): string;
|
|
107
|
-
formatCurrency(value: number, currency: string, targetLocale?: string, options?: WithLocales<Intl.NumberFormatOptions>): string;
|
|
108
|
-
formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, targetLocale?: string, options?: WithLocales<Intl.RelativeTimeFormatOptions>): string;
|
|
109
|
-
formatRelativeTimeFromDate(date: Date, targetLocale?: string, options?: WithLocales<Intl.RelativeTimeFormatOptions & {
|
|
110
|
-
baseDate?: Date;
|
|
111
|
-
}>): string;
|
|
112
|
-
formatCutoff(value: string, targetLocale?: string, options?: WithLocales<CutoffFormatOptions>): string;
|
|
113
|
-
formatMessage(message: string, targetLocale?: string, options?: WithLocales<{
|
|
114
|
-
variables?: FormatVariables;
|
|
115
|
-
dataFormat?: StringFormat;
|
|
116
|
-
}>): string;
|
|
117
|
-
formatList(array: Array<string | number>, targetLocale?: string, options?: WithLocales<Intl.ListFormatOptions>): string;
|
|
118
|
-
formatListToParts<T>(array: Array<T>, targetLocale?: string, options?: WithLocales<Intl.ListFormatOptions>): (string | T)[];
|
|
119
|
-
getLocaleName(locale: string): string;
|
|
120
|
-
getLocaleEmoji(locale: string): string;
|
|
121
|
-
getLocaleProperties(locale: string): LocaleProperties;
|
|
122
|
-
requiresTranslation(targetLocale: string, sourceLocale?: string, approvedLocales?: string[] | undefined): boolean;
|
|
123
|
-
determineLocale(locales: string | string[], approvedLocales?: string[]): string | undefined;
|
|
124
|
-
getLocaleDirection(locale: string): "ltr" | "rtl";
|
|
125
|
-
isValidLocale(locale: string): boolean;
|
|
126
|
-
resolveCanonicalLocale(locale: string): string;
|
|
127
|
-
resolveAliasLocale(locale: string): string;
|
|
128
|
-
standardizeLocale(locale: string): string;
|
|
129
|
-
isSameDialect(...locales: (string | string[])[]): boolean;
|
|
130
|
-
isSameLanguage(...locales: (string | string[])[]): boolean;
|
|
131
|
-
isSupersetLocale(superLocale: string, subLocale: string): boolean;
|
|
132
|
-
}
|
|
133
|
-
//#endregion
|
|
134
57
|
//#region src/index.d.ts
|
|
135
58
|
/**
|
|
136
59
|
* Type representing the constructor parameters for the GT class.
|
|
@@ -189,9 +112,9 @@ declare class GT {
|
|
|
189
112
|
reverseCustomMapping?: Record<string, string>;
|
|
190
113
|
/** Lazily derived custom mapping for regions */
|
|
191
114
|
customRegionMapping?: CustomRegionMapping;
|
|
192
|
-
/**
|
|
115
|
+
/** Runtime-safe locale and formatting helpers (backing field) */
|
|
193
116
|
private _localeConfig;
|
|
194
|
-
/**
|
|
117
|
+
/** Runtime-safe locale and formatting helpers */
|
|
195
118
|
get localeConfig(): LocaleConfig;
|
|
196
119
|
/**
|
|
197
120
|
* Constructs an instance of the GT class.
|
|
@@ -902,67 +825,6 @@ declare class GT {
|
|
|
902
825
|
*/
|
|
903
826
|
isSupersetLocale(superLocale: string, subLocale: string): boolean;
|
|
904
827
|
}
|
|
905
|
-
/**
|
|
906
|
-
* Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
|
|
907
|
-
*
|
|
908
|
-
* This standalone function provides cutoff formatting functionality without requiring a GT instance.
|
|
909
|
-
* The locales parameter is required for proper terminator selection based on the target language.
|
|
910
|
-
*
|
|
911
|
-
* @param {string} value - The string value to format with cutoff behavior.
|
|
912
|
-
* @param {Object} [options] - Configuration options for cutoff formatting.
|
|
913
|
-
* @param {string | string[]} [options.locales] - The locales to use for terminator selection.
|
|
914
|
-
* @param {number} [options.maxChars] - The maximum number of characters to display.
|
|
915
|
-
* - Undefined values are treated as no cutoff.
|
|
916
|
-
* - Negative values follow .slice() behavior and terminator will be added before the value.
|
|
917
|
-
* - 0 will result in an empty string.
|
|
918
|
-
* - If cutoff results in an empty string, no terminator is added.
|
|
919
|
-
* @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
|
|
920
|
-
* @param {string} [options.terminator] - Optional override the terminator to use.
|
|
921
|
-
* @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
|
|
922
|
-
* - If no terminator is provided, then separator is ignored.
|
|
923
|
-
* @returns {string} The formatted string with terminator applied if cutoff occurs.
|
|
924
|
-
*
|
|
925
|
-
* @example
|
|
926
|
-
* formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });
|
|
927
|
-
* // Returns: 'Hello, w...'
|
|
928
|
-
*
|
|
929
|
-
* @example
|
|
930
|
-
* formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });
|
|
931
|
-
* // Returns: '...ld!'
|
|
932
|
-
*
|
|
933
|
-
* @example
|
|
934
|
-
* formatCutoff('Very long text that needs cutting', {
|
|
935
|
-
* locales: 'en-US',
|
|
936
|
-
* maxChars: 15,
|
|
937
|
-
* style: 'ellipsis',
|
|
938
|
-
* separator: ' '
|
|
939
|
-
* });
|
|
940
|
-
* // Returns: 'Very long text ...'
|
|
941
|
-
*/
|
|
942
|
-
declare function formatCutoff(value: string, options?: {
|
|
943
|
-
locales?: string | string[];
|
|
944
|
-
} & CutoffFormatOptions): string;
|
|
945
|
-
/**
|
|
946
|
-
* Formats a message according to the specified locales and options.
|
|
947
|
-
*
|
|
948
|
-
* @param {string} message - The message to format.
|
|
949
|
-
* @param {string | string[]} [locales='en'] - The locales to use for formatting.
|
|
950
|
-
* @param {FormatVariables} [variables={}] - The variables to use for formatting.
|
|
951
|
-
* @param {StringFormat} [dataFormat='ICU'] - The format of the message. (When STRING, the message is returned as is)
|
|
952
|
-
* @returns {string} The formatted message.
|
|
953
|
-
*
|
|
954
|
-
* @example
|
|
955
|
-
* formatMessage('Hello {name}', { name: 'John' });
|
|
956
|
-
* // Returns: "Hello John"
|
|
957
|
-
*
|
|
958
|
-
* formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });
|
|
959
|
-
* // Returns: "Bonjour John"
|
|
960
|
-
*/
|
|
961
|
-
declare function formatMessage(message: string, options?: {
|
|
962
|
-
locales?: string | string[];
|
|
963
|
-
variables?: FormatVariables;
|
|
964
|
-
dataFormat?: StringFormat;
|
|
965
|
-
}): string;
|
|
966
828
|
/**
|
|
967
829
|
* Formats a number according to the specified locales and options.
|
|
968
830
|
* @param {Object} params - The parameters for the number formatting.
|
|
@@ -1165,13 +1027,6 @@ declare function determineLocale(locales: string | string[], approvedLocales?: s
|
|
|
1165
1027
|
* @returns {string} - 'rtl' if the locale is right-to-left, otherwise 'ltr'.
|
|
1166
1028
|
*/
|
|
1167
1029
|
declare function getLocaleDirection(locale: string): 'ltr' | 'rtl';
|
|
1168
|
-
/**
|
|
1169
|
-
* Checks if a given BCP 47 locale code is valid.
|
|
1170
|
-
* @param {string} locale - The BCP 47 locale code to validate.
|
|
1171
|
-
* @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
|
|
1172
|
-
* @returns {boolean} True if the BCP 47 code is valid, false otherwise.
|
|
1173
|
-
*/
|
|
1174
|
-
declare function isValidLocale(locale: string, customMapping?: CustomMapping): boolean;
|
|
1175
1030
|
/**
|
|
1176
1031
|
* Resolves the alias locale for a given locale.
|
|
1177
1032
|
* @param {string} locale - The locale to resolve the alias locale for
|
|
@@ -1179,19 +1034,6 @@ declare function isValidLocale(locale: string, customMapping?: CustomMapping): b
|
|
|
1179
1034
|
* @returns {string} The alias locale
|
|
1180
1035
|
*/
|
|
1181
1036
|
declare function resolveAliasLocale(locale: string, customMapping?: CustomMapping): string;
|
|
1182
|
-
/**
|
|
1183
|
-
* Resolves the canonical locale for a given locale.
|
|
1184
|
-
* @param {string} locale - The locale to resolve the canonical locale for
|
|
1185
|
-
* @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the canonical locale
|
|
1186
|
-
* @returns {string} The canonical locale
|
|
1187
|
-
*/
|
|
1188
|
-
declare function resolveCanonicalLocale(locale: string, customMapping?: CustomMapping): string;
|
|
1189
|
-
/**
|
|
1190
|
-
* Standardizes a BCP 47 locale code to ensure correct formatting.
|
|
1191
|
-
* @param {string} locale - The BCP 47 locale code to standardize.
|
|
1192
|
-
* @returns {string} The standardized BCP 47 locale code or an empty string if it is an invalid code.
|
|
1193
|
-
*/
|
|
1194
|
-
declare function standardizeLocale(locale: string): string;
|
|
1195
1037
|
/**
|
|
1196
1038
|
* Checks if multiple BCP 47 locale codes represent the same dialect.
|
|
1197
1039
|
* @param {string[]} locales - The BCP 47 locale codes to compare.
|