generaltranslation 8.0.5 → 8.1.0
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 +12 -0
- package/dist/cache/IntlCache.d.ts +19 -1
- package/dist/cache/types.d.ts +32 -0
- package/dist/errors/formattingErrors.d.ts +1 -0
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +59 -0
- package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +4 -0
- package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +48 -0
- package/dist/id/hashSource.d.ts +4 -6
- package/dist/id/types.d.ts +7 -0
- package/dist/id.cjs.min.cjs +1 -1
- package/dist/id.cjs.min.cjs.map +1 -1
- package/dist/id.d.ts +9 -5
- package/dist/id.esm.min.mjs +1 -1
- package/dist/id.esm.min.mjs.map +1 -1
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.cjs.min.cjs.map +1 -1
- package/dist/index.d.ts +92 -5
- package/dist/index.esm.min.mjs +3 -3
- package/dist/index.esm.min.mjs.map +1 -1
- package/dist/internal.cjs.min.cjs +1 -1
- package/dist/internal.cjs.min.cjs.map +1 -1
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/internal.esm.min.mjs.map +1 -1
- package/dist/translate/submitUserEditDiffs.d.ts +1 -1
- package/dist/types-dir/api/file.d.ts +1 -1
- package/dist/types.d.ts +10 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { DataFormat as DataFormat$1 } from 'src/types';
|
|
2
|
-
|
|
3
1
|
type CustomMapping = Record<string, string | Partial<LocaleProperties>>;
|
|
4
2
|
|
|
5
3
|
type LocaleProperties = {
|
|
@@ -169,7 +167,7 @@ type FileReference = {
|
|
|
169
167
|
branchId: string;
|
|
170
168
|
fileName: string;
|
|
171
169
|
fileFormat: FileFormat;
|
|
172
|
-
dataFormat?: DataFormat
|
|
170
|
+
dataFormat?: DataFormat;
|
|
173
171
|
};
|
|
174
172
|
|
|
175
173
|
type DownloadFileBatchRequest = {
|
|
@@ -331,7 +329,7 @@ type SubmitUserEditDiff = {
|
|
|
331
329
|
branchId: string;
|
|
332
330
|
versionId: string;
|
|
333
331
|
fileId: string;
|
|
334
|
-
localContent
|
|
332
|
+
localContent: string;
|
|
335
333
|
};
|
|
336
334
|
type SubmitUserEditDiffsPayload = {
|
|
337
335
|
diffs: SubmitUserEditDiff[];
|
|
@@ -411,6 +409,23 @@ type CreateBranchResult = {
|
|
|
411
409
|
};
|
|
412
410
|
};
|
|
413
411
|
|
|
412
|
+
/** Type of terminator */
|
|
413
|
+
type CutoffFormatStyle = 'none' | 'ellipsis';
|
|
414
|
+
/** Terminator options */
|
|
415
|
+
interface TerminatorOptions {
|
|
416
|
+
/** The terminator to use */
|
|
417
|
+
terminator?: string;
|
|
418
|
+
/** An optional separator between the terminator and the value */
|
|
419
|
+
separator?: string;
|
|
420
|
+
}
|
|
421
|
+
/** Input formatting options (for constructor) */
|
|
422
|
+
interface CutoffFormatOptions extends TerminatorOptions {
|
|
423
|
+
/** Cutoff length */
|
|
424
|
+
maxChars?: number;
|
|
425
|
+
/** Type of terminator */
|
|
426
|
+
style?: CutoffFormatStyle;
|
|
427
|
+
}
|
|
428
|
+
|
|
414
429
|
/**
|
|
415
430
|
* Type representing the constructor parameters for the GT class.
|
|
416
431
|
* @typedef {Object} GTConstructorParams
|
|
@@ -763,6 +778,38 @@ declare class GT {
|
|
|
763
778
|
source: FileUpload;
|
|
764
779
|
translations: FileUpload[];
|
|
765
780
|
}[], options: UploadFilesOptions): Promise<UploadFilesResponse>;
|
|
781
|
+
/**
|
|
782
|
+
* Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
|
|
783
|
+
*
|
|
784
|
+
* This method uses the GT instance's rendering locales by default for locale-specific terminator selection,
|
|
785
|
+
* but can be overridden with custom locales in the options.
|
|
786
|
+
*
|
|
787
|
+
* @param {string} value - The string value to format with cutoff behavior.
|
|
788
|
+
* @param {Object} [options] - Configuration options for cutoff formatting.
|
|
789
|
+
* @param {string | string[]} [options.locales] - The locales to use for terminator selection. Defaults to instance's rendering locales.
|
|
790
|
+
* @param {number} [options.maxChars] - The maximum number of characters to display.
|
|
791
|
+
* - Undefined values are treated as no cutoff.
|
|
792
|
+
* - Negative values follow .slice() behavior and terminator will be added before the value.
|
|
793
|
+
* - 0 will result in an empty string.
|
|
794
|
+
* - If cutoff results in an empty string, no terminator is added.
|
|
795
|
+
* @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
|
|
796
|
+
* @param {string} [options.terminator] - Optional override the terminator to use.
|
|
797
|
+
* @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
|
|
798
|
+
* - If no terminator is provided, then separator is ignored.
|
|
799
|
+
* @returns {string} The formatted string with terminator applied if cutoff occurs.
|
|
800
|
+
*
|
|
801
|
+
* @example
|
|
802
|
+
* const gt = new GT({ targetLocale: 'en-US' });
|
|
803
|
+
* gt.formatCutoff('Hello, world!', { maxChars: 8 });
|
|
804
|
+
* // Returns: 'Hello, w...'
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* gt.formatCutoff('Hello, world!', { maxChars: -3 });
|
|
808
|
+
* // Returns: '...ld!'
|
|
809
|
+
*/
|
|
810
|
+
formatCutoff(value: string, options?: {
|
|
811
|
+
locales?: string | string[];
|
|
812
|
+
} & CutoffFormatOptions): string;
|
|
766
813
|
/**
|
|
767
814
|
* Formats a message according to the specified locales and options.
|
|
768
815
|
*
|
|
@@ -1098,6 +1145,46 @@ declare class GT {
|
|
|
1098
1145
|
*/
|
|
1099
1146
|
isSupersetLocale(superLocale: string, subLocale: string): boolean;
|
|
1100
1147
|
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
|
|
1150
|
+
*
|
|
1151
|
+
* This standalone function provides cutoff formatting functionality without requiring a GT instance.
|
|
1152
|
+
* The locales parameter is required for proper terminator selection based on the target language.
|
|
1153
|
+
*
|
|
1154
|
+
* @param {string} value - The string value to format with cutoff behavior.
|
|
1155
|
+
* @param {Object} [options] - Configuration options for cutoff formatting.
|
|
1156
|
+
* @param {string | string[]} [options.locales] - The locales to use for terminator selection.
|
|
1157
|
+
* @param {number} [options.maxChars] - The maximum number of characters to display.
|
|
1158
|
+
* - Undefined values are treated as no cutoff.
|
|
1159
|
+
* - Negative values follow .slice() behavior and terminator will be added before the value.
|
|
1160
|
+
* - 0 will result in an empty string.
|
|
1161
|
+
* - If cutoff results in an empty string, no terminator is added.
|
|
1162
|
+
* @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
|
|
1163
|
+
* @param {string} [options.terminator] - Optional override the terminator to use.
|
|
1164
|
+
* @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
|
|
1165
|
+
* - If no terminator is provided, then separator is ignored.
|
|
1166
|
+
* @returns {string} The formatted string with terminator applied if cutoff occurs.
|
|
1167
|
+
*
|
|
1168
|
+
* @example
|
|
1169
|
+
* formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });
|
|
1170
|
+
* // Returns: 'Hello, w...'
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });
|
|
1174
|
+
* // Returns: '...ld!'
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* formatCutoff('Very long text that needs cutting', {
|
|
1178
|
+
* locales: 'en-US',
|
|
1179
|
+
* maxChars: 15,
|
|
1180
|
+
* style: 'ellipsis',
|
|
1181
|
+
* separator: ' '
|
|
1182
|
+
* });
|
|
1183
|
+
* // Returns: 'Very long text ...'
|
|
1184
|
+
*/
|
|
1185
|
+
declare function formatCutoff(value: string, options?: {
|
|
1186
|
+
locales?: string | string[];
|
|
1187
|
+
} & CutoffFormatOptions): string;
|
|
1101
1188
|
/**
|
|
1102
1189
|
* Formats a message according to the specified locales and options.
|
|
1103
1190
|
*
|
|
@@ -1349,4 +1436,4 @@ declare function isSameLanguage(...locales: (string | string[])[]): boolean;
|
|
|
1349
1436
|
*/
|
|
1350
1437
|
declare function isSupersetLocale(superLocale: string, subLocale: string): boolean;
|
|
1351
1438
|
|
|
1352
|
-
export { GT, determineLocale, formatCurrency, formatDateTime, formatList, formatListToParts, formatMessage, formatNum, formatRelativeTime, getLocaleDirection, getLocaleEmoji, getLocaleName, getLocaleProperties, getRegionProperties, isSameDialect, isSameLanguage, isSupersetLocale, isValidLocale, requiresTranslation, resolveAliasLocale, standardizeLocale };
|
|
1439
|
+
export { GT, determineLocale, formatCurrency, formatCutoff, formatDateTime, formatList, formatListToParts, formatMessage, formatNum, formatRelativeTime, getLocaleDirection, getLocaleEmoji, getLocaleName, getLocaleProperties, getRegionProperties, isSameDialect, isSameLanguage, isSupersetLocale, isValidLocale, requiresTranslation, resolveAliasLocale, standardizeLocale };
|