generaltranslation 7.4.2 → 7.5.0-alpha.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 +6 -0
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.cjs.min.cjs.map +1 -1
- package/dist/index.d.ts +36 -6
- package/dist/index.esm.min.mjs +3 -3
- package/dist/index.esm.min.mjs.map +1 -1
- package/dist/locales/customLocaleMapping.d.ts +1 -0
- package/dist/locales/getLocaleProperties.d.ts +9 -0
- package/dist/locales/resolveAliasLocale.d.ts +8 -0
- package/dist/translate/uploadFiles.d.ts +1 -0
- package/dist/types-dir/uploadFiles.d.ts +23 -0
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -4,6 +4,7 @@ import { JsxChildren } from './internal';
|
|
4
4
|
import { FileTranslationQuery } from './types-dir/checkFileTranslations';
|
5
5
|
import { CheckTranslationStatusOptions, TranslationStatusResult } from './types-dir/translationStatus';
|
6
6
|
import { CustomRegionMapping } from './locales/getRegionProperties';
|
7
|
+
import { FileUpload, UploadFilesOptions } from './types-dir/uploadFiles';
|
7
8
|
/**
|
8
9
|
* Type representing the constructor parameters for the GT class.
|
9
10
|
* @typedef {Object} GTConstructorParams
|
@@ -59,6 +60,8 @@ export declare class GT {
|
|
59
60
|
_renderingLocales: string[];
|
60
61
|
/** Custom mapping for locale codes to their names */
|
61
62
|
customMapping?: CustomMapping;
|
63
|
+
/** Lazily derived reverse custom mapping for alias locales */
|
64
|
+
reverseCustomMapping?: Record<string, string>;
|
62
65
|
/** Lazily derived custom mapping for regions */
|
63
66
|
customRegionMapping?: CustomRegionMapping;
|
64
67
|
/**
|
@@ -316,6 +319,10 @@ export declare class GT {
|
|
316
319
|
translateMany(sources: Entry[], globalMetadata?: {
|
317
320
|
targetLocale: string;
|
318
321
|
} & EntryMetadata): Promise<TranslateManyResult>;
|
322
|
+
uploadFiles(files: {
|
323
|
+
source: FileUpload;
|
324
|
+
translations: FileUpload[];
|
325
|
+
}[], options: UploadFilesOptions): Promise<any>;
|
319
326
|
/**
|
320
327
|
* Formats a message according to the specified locales and options.
|
321
328
|
*
|
@@ -531,7 +538,7 @@ export declare class GT {
|
|
531
538
|
* gt.requiresTranslation('en-US', 'es-ES');
|
532
539
|
* // Returns: true
|
533
540
|
*/
|
534
|
-
requiresTranslation(sourceLocale?: string | undefined, targetLocale?: string | undefined, approvedLocales?: string[] | undefined): boolean;
|
541
|
+
requiresTranslation(sourceLocale?: string | undefined, targetLocale?: string | undefined, approvedLocales?: string[] | undefined, customMapping?: CustomMapping | undefined): boolean;
|
535
542
|
/**
|
536
543
|
* Determines the best matching locale from the provided approved locales list.
|
537
544
|
*
|
@@ -543,7 +550,7 @@ export declare class GT {
|
|
543
550
|
* gt.determineLocale(['fr-CA', 'fr-FR'], ['en-US', 'fr-FR', 'es-ES']);
|
544
551
|
* // Returns: "fr-FR"
|
545
552
|
*/
|
546
|
-
determineLocale(locales: string | string[], approvedLocales?: string[] | undefined): string | undefined;
|
553
|
+
determineLocale(locales: string | string[], approvedLocales?: string[] | undefined, customMapping?: CustomMapping | undefined): string | undefined;
|
547
554
|
/**
|
548
555
|
* Gets the text direction for a given locale code.
|
549
556
|
*
|
@@ -560,6 +567,7 @@ export declare class GT {
|
|
560
567
|
* Checks if a given BCP 47 locale code is valid.
|
561
568
|
*
|
562
569
|
* @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate
|
570
|
+
* @param {customMapping} [customMapping=this.customMapping] - The custom mapping to use for validation
|
563
571
|
* @returns {boolean} True if the locale code is valid, false otherwise
|
564
572
|
* @throws {Error} If no target locale is provided
|
565
573
|
*
|
@@ -567,7 +575,21 @@ export declare class GT {
|
|
567
575
|
* gt.isValidLocale('en-US');
|
568
576
|
* // Returns: true
|
569
577
|
*/
|
570
|
-
isValidLocale(locale?: string | undefined): boolean;
|
578
|
+
isValidLocale(locale?: string | undefined, customMapping?: CustomMapping | undefined): boolean;
|
579
|
+
/**
|
580
|
+
* Resolves the canonical locale for a given locale.
|
581
|
+
* @param locale - The locale to resolve the canonical locale for
|
582
|
+
* @param customMapping - The custom mapping to use for resolving the canonical locale
|
583
|
+
* @returns The canonical locale
|
584
|
+
*/
|
585
|
+
resolveCanonicalLocale(locale?: string | undefined, customMapping?: CustomMapping | undefined): string;
|
586
|
+
/**
|
587
|
+
* Resolves the alias locale for a given locale.
|
588
|
+
* @param locale - The locale to resolve the alias locale for
|
589
|
+
* @param customMapping - The custom mapping to use for resolving the alias locale
|
590
|
+
* @returns The alias locale
|
591
|
+
*/
|
592
|
+
resolveAliasLocale(locale: string, customMapping?: CustomMapping | undefined): string;
|
571
593
|
/**
|
572
594
|
* Standardizes a BCP 47 locale code to ensure correct formatting.
|
573
595
|
*
|
@@ -765,14 +787,14 @@ export declare function getLocaleProperties(locale: string, defaultLocale?: stri
|
|
765
787
|
*
|
766
788
|
* @returns {boolean} - Returns `true` if translation is required, otherwise `false`.
|
767
789
|
*/
|
768
|
-
export declare function requiresTranslation(sourceLocale: string, targetLocale: string, approvedLocales?: string[]): boolean;
|
790
|
+
export declare function requiresTranslation(sourceLocale: string, targetLocale: string, approvedLocales?: string[], customMapping?: CustomMapping): boolean;
|
769
791
|
/**
|
770
792
|
* Determines the best matching locale from the provided approved locales list.
|
771
793
|
* @param {string | string[]} locales - A single locale or an array of locales sorted in preference order.
|
772
794
|
* @param {string[]} [approvedLocales=this.locales] - An array of approved locales, also sorted by preference.
|
773
795
|
* @returns {string | undefined} - The best matching locale from the approvedLocales list, or undefined if no match is found.
|
774
796
|
*/
|
775
|
-
export declare function determineLocale(locales: string | string[], approvedLocales?: string[] | undefined): string | undefined;
|
797
|
+
export declare function determineLocale(locales: string | string[], approvedLocales?: string[] | undefined, customMapping?: CustomMapping | undefined): string | undefined;
|
776
798
|
/**
|
777
799
|
* Get the text direction for a given locale code using the Intl.Locale API.
|
778
800
|
*
|
@@ -783,9 +805,17 @@ export declare function getLocaleDirection(locale: string): 'ltr' | 'rtl';
|
|
783
805
|
/**
|
784
806
|
* Checks if a given BCP 47 locale code is valid.
|
785
807
|
* @param {string} locale - The BCP 47 locale code to validate.
|
808
|
+
* @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
|
786
809
|
* @returns {boolean} True if the BCP 47 code is valid, false otherwise.
|
787
810
|
*/
|
788
|
-
export declare function isValidLocale(locale: string): boolean;
|
811
|
+
export declare function isValidLocale(locale: string, customMapping?: CustomMapping): boolean;
|
812
|
+
/**
|
813
|
+
* Resolves the alias locale for a given locale.
|
814
|
+
* @param {string} locale - The locale to resolve the alias locale for
|
815
|
+
* @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the alias locale
|
816
|
+
* @returns {string} The alias locale
|
817
|
+
*/
|
818
|
+
export declare function resolveAliasLocale(locale: string, customMapping?: CustomMapping): string;
|
789
819
|
/**
|
790
820
|
* Standardizes a BCP 47 locale code to ensure correct formatting.
|
791
821
|
* @param {string} locale - The BCP 47 locale code to standardize.
|