generaltranslation 8.2.7 → 8.2.8
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/id.d.cts +1 -1
- package/dist/id.d.mts +1 -1
- package/dist/index.cjs +191 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -4
- package/dist/index.d.mts +66 -4
- package/dist/index.mjs +191 -55
- package/dist/index.mjs.map +1 -1
- package/dist/{internal-CTeI8uLd.mjs → internal-B3QbyI_5.mjs} +48 -2
- package/dist/internal-B3QbyI_5.mjs.map +1 -0
- package/dist/{internal-PCKq4YMW.cjs → internal-DIHQF9gs.cjs} +59 -1
- package/dist/internal-DIHQF9gs.cjs.map +1 -0
- package/dist/internal.cjs +3 -1
- package/dist/internal.d.cts +23 -2
- package/dist/internal.d.mts +23 -2
- package/dist/internal.mjs +2 -2
- package/dist/{types-D2fTTTvZ.d.cts → types-BJdoI1d1.d.cts} +6 -2
- package/dist/{types-fUW4_Ole.d.mts → types-DazaDJbs.d.mts} +6 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +1 -1
- package/dist/internal-CTeI8uLd.mjs.map +0 -1
- package/dist/internal-PCKq4YMW.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# generaltranslation
|
|
2
2
|
|
|
3
|
+
## 8.2.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1248](https://github.com/generaltranslation/gt/pull/1248) [`b12d57d`](https://github.com/generaltranslation/gt/commit/b12d57dab1d5cb1f602c5ac24a702b48cda7f11e) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add PO/POT file format support and transformFormat plumbing for API uploads and CLI file downloads.
|
|
8
|
+
|
|
3
9
|
## 8.2.7
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/id.d.cts
CHANGED
package/dist/id.d.mts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_internal = require("./internal-
|
|
24
|
+
const require_internal = require("./internal-DIHQF9gs.cjs");
|
|
25
25
|
const require_ApiError = require("./ApiError-4zIP-twr.cjs");
|
|
26
26
|
const require_id = require("./id-VXBgyXu2.cjs");
|
|
27
27
|
let intl_messageformat = require("intl-messageformat");
|
|
@@ -1469,6 +1469,7 @@ async function processBatches(items, processor, options = {}) {
|
|
|
1469
1469
|
* @returns The result of the API call
|
|
1470
1470
|
*/
|
|
1471
1471
|
async function _enqueueFiles(files, options, config) {
|
|
1472
|
+
require_internal.validateFileFormatTransforms(files);
|
|
1472
1473
|
const result = await processBatches(files, async (batch) => {
|
|
1473
1474
|
const apiResult = await apiRequest(config, "/v2/project/translations/enqueue", {
|
|
1474
1475
|
body: {
|
|
@@ -1476,7 +1477,8 @@ async function _enqueueFiles(files, options, config) {
|
|
|
1476
1477
|
branchId: f.branchId,
|
|
1477
1478
|
fileId: f.fileId,
|
|
1478
1479
|
versionId: f.versionId,
|
|
1479
|
-
fileName: f.fileName
|
|
1480
|
+
fileName: f.fileName,
|
|
1481
|
+
transformFormat: f.transformFormat
|
|
1480
1482
|
})),
|
|
1481
1483
|
targetLocales: options.targetLocales,
|
|
1482
1484
|
sourceLocale: options.sourceLocale,
|
|
@@ -1671,6 +1673,7 @@ async function _uploadSourceFiles(files, options, config) {
|
|
|
1671
1673
|
* @returns Promise resolving to a BatchList with all uploaded files
|
|
1672
1674
|
*/
|
|
1673
1675
|
async function _uploadTranslations(files, options, config) {
|
|
1676
|
+
require_internal.validateFileFormatTransforms(files.map(({ source }) => source));
|
|
1674
1677
|
return processBatches(files, async (batch) => {
|
|
1675
1678
|
return (await apiRequest(config, "/v2/project/files/upload-translations", {
|
|
1676
1679
|
body: {
|
|
@@ -1679,6 +1682,7 @@ async function _uploadTranslations(files, options, config) {
|
|
|
1679
1682
|
content: require_internal.encode(source.content),
|
|
1680
1683
|
fileName: source.fileName,
|
|
1681
1684
|
fileFormat: source.fileFormat,
|
|
1685
|
+
transformFormat: source.transformFormat,
|
|
1682
1686
|
locale: source.locale,
|
|
1683
1687
|
dataFormat: source.dataFormat,
|
|
1684
1688
|
formatMetadata: source.formatMetadata,
|
|
@@ -1953,6 +1957,158 @@ async function _publishFiles(files, config) {
|
|
|
1953
1957
|
return await apiRequest(config, "/v2/project/files/publish", { body: { files } });
|
|
1954
1958
|
}
|
|
1955
1959
|
//#endregion
|
|
1960
|
+
//#region src/LocaleConfig.ts
|
|
1961
|
+
/**
|
|
1962
|
+
* LocaleConfig is a client-safe locale and formatting helper.
|
|
1963
|
+
*
|
|
1964
|
+
* It intentionally does not store project IDs, API keys, runtime URLs, or any
|
|
1965
|
+
* translation credentials. It only stores locale metadata needed to resolve
|
|
1966
|
+
* aliases, choose formatting fallbacks, and format values with Intl.
|
|
1967
|
+
*/
|
|
1968
|
+
var LocaleConfig = class {
|
|
1969
|
+
constructor({ defaultLocale = "en", locales = [], customMapping } = {}) {
|
|
1970
|
+
this.defaultLocale = defaultLocale;
|
|
1971
|
+
this.locales = locales;
|
|
1972
|
+
this.customMapping = customMapping;
|
|
1973
|
+
}
|
|
1974
|
+
get translationLocales() {
|
|
1975
|
+
return this.locales.length ? this.locales : void 0;
|
|
1976
|
+
}
|
|
1977
|
+
resolveCanonicalLocaleList(locales) {
|
|
1978
|
+
return locales.map((locale) => this.resolveCanonicalLocale(locale));
|
|
1979
|
+
}
|
|
1980
|
+
resolveCanonicalLocaleArgs(locales) {
|
|
1981
|
+
return locales.map((locale) => Array.isArray(locale) ? this.resolveCanonicalLocaleList(locale) : this.resolveCanonicalLocale(locale));
|
|
1982
|
+
}
|
|
1983
|
+
toLocaleList(locales) {
|
|
1984
|
+
return Array.isArray(locales) ? locales : [locales];
|
|
1985
|
+
}
|
|
1986
|
+
getFormattingLocales(targetLocale, locales) {
|
|
1987
|
+
return (locales !== void 0 ? this.toLocaleList(locales) : [
|
|
1988
|
+
targetLocale,
|
|
1989
|
+
this.defaultLocale,
|
|
1990
|
+
"en"
|
|
1991
|
+
]).filter((locale) => !!locale).map((locale) => this.resolveCanonicalLocale(locale));
|
|
1992
|
+
}
|
|
1993
|
+
formatNum(value, targetLocale, options = {}) {
|
|
1994
|
+
const { locales, ...intlOptions } = options;
|
|
1995
|
+
return _formatNum({
|
|
1996
|
+
value,
|
|
1997
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1998
|
+
options: intlOptions
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
formatDateTime(value, targetLocale, options = {}) {
|
|
2002
|
+
const { locales, ...intlOptions } = options;
|
|
2003
|
+
return _formatDateTime({
|
|
2004
|
+
value,
|
|
2005
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
2006
|
+
options: intlOptions
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
formatCurrency(value, currency, targetLocale, options = {}) {
|
|
2010
|
+
const { locales, ...intlOptions } = options;
|
|
2011
|
+
return _formatCurrency({
|
|
2012
|
+
value,
|
|
2013
|
+
currency,
|
|
2014
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
2015
|
+
options: intlOptions
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
formatRelativeTime(value, unit, targetLocale, options = {}) {
|
|
2019
|
+
const { locales, ...intlOptions } = options;
|
|
2020
|
+
return _formatRelativeTime({
|
|
2021
|
+
value,
|
|
2022
|
+
unit,
|
|
2023
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
2024
|
+
options: intlOptions
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
formatRelativeTimeFromDate(date, targetLocale, options = {}) {
|
|
2028
|
+
const { locales, baseDate, ...intlOptions } = options;
|
|
2029
|
+
return _formatRelativeTimeFromDate({
|
|
2030
|
+
date,
|
|
2031
|
+
baseDate: baseDate ?? /* @__PURE__ */ new Date(),
|
|
2032
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
2033
|
+
options: intlOptions
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
formatCutoff(value, targetLocale, options = {}) {
|
|
2037
|
+
const { locales, ...formatOptions } = options;
|
|
2038
|
+
return _formatCutoff({
|
|
2039
|
+
value,
|
|
2040
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
2041
|
+
options: formatOptions
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2044
|
+
formatMessage(message, targetLocale, options = {}) {
|
|
2045
|
+
const { locales, variables, dataFormat } = options;
|
|
2046
|
+
if (dataFormat === "STRING") return _formatMessageString(message);
|
|
2047
|
+
return _formatMessageICU(message, this.getFormattingLocales(targetLocale, locales), variables);
|
|
2048
|
+
}
|
|
2049
|
+
formatList(array, targetLocale, options = {}) {
|
|
2050
|
+
const { locales, ...intlOptions } = options;
|
|
2051
|
+
return _formatList({
|
|
2052
|
+
value: array,
|
|
2053
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
2054
|
+
options: intlOptions
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
formatListToParts(array, targetLocale, options = {}) {
|
|
2058
|
+
const { locales, ...intlOptions } = options;
|
|
2059
|
+
return _formatListToParts({
|
|
2060
|
+
value: array,
|
|
2061
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
2062
|
+
options: intlOptions
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
getLocaleName(locale) {
|
|
2066
|
+
return _getLocaleName(locale, this.defaultLocale, this.customMapping);
|
|
2067
|
+
}
|
|
2068
|
+
getLocaleEmoji(locale) {
|
|
2069
|
+
return _getLocaleEmoji(locale, this.customMapping);
|
|
2070
|
+
}
|
|
2071
|
+
getLocaleProperties(locale) {
|
|
2072
|
+
return _getLocaleProperties(locale, this.defaultLocale, this.customMapping);
|
|
2073
|
+
}
|
|
2074
|
+
requiresTranslation(targetLocale, sourceLocale = this.defaultLocale, approvedLocales = this.translationLocales) {
|
|
2075
|
+
return _requiresTranslation(this.resolveCanonicalLocale(sourceLocale), this.resolveCanonicalLocale(targetLocale), approvedLocales ? this.resolveCanonicalLocaleList(approvedLocales) : void 0, this.customMapping);
|
|
2076
|
+
}
|
|
2077
|
+
determineLocale(locales, approvedLocales = this.locales) {
|
|
2078
|
+
const approvedLocalePairs = approvedLocales.map((locale) => ({
|
|
2079
|
+
locale,
|
|
2080
|
+
canonicalLocale: this.resolveCanonicalLocale(locale)
|
|
2081
|
+
}));
|
|
2082
|
+
const resolvedLocale = _determineLocale(Array.isArray(locales) ? this.resolveCanonicalLocaleList(locales) : this.resolveCanonicalLocale(locales), approvedLocalePairs.map(({ canonicalLocale }) => canonicalLocale), this.customMapping);
|
|
2083
|
+
if (!resolvedLocale) return void 0;
|
|
2084
|
+
return approvedLocalePairs.find(({ canonicalLocale }) => canonicalLocale === resolvedLocale)?.locale || this.resolveAliasLocale(resolvedLocale);
|
|
2085
|
+
}
|
|
2086
|
+
getLocaleDirection(locale) {
|
|
2087
|
+
return _getLocaleDirection(this.resolveCanonicalLocale(locale));
|
|
2088
|
+
}
|
|
2089
|
+
isValidLocale(locale) {
|
|
2090
|
+
return _isValidLocale(locale, this.customMapping);
|
|
2091
|
+
}
|
|
2092
|
+
resolveCanonicalLocale(locale) {
|
|
2093
|
+
return _resolveCanonicalLocale(locale, this.customMapping);
|
|
2094
|
+
}
|
|
2095
|
+
resolveAliasLocale(locale) {
|
|
2096
|
+
return _resolveAliasLocale(locale, this.customMapping);
|
|
2097
|
+
}
|
|
2098
|
+
standardizeLocale(locale) {
|
|
2099
|
+
return _standardizeLocale(locale);
|
|
2100
|
+
}
|
|
2101
|
+
isSameDialect(...locales) {
|
|
2102
|
+
return _isSameDialect(...this.resolveCanonicalLocaleArgs(locales));
|
|
2103
|
+
}
|
|
2104
|
+
isSameLanguage(...locales) {
|
|
2105
|
+
return _isSameLanguage(...this.resolveCanonicalLocaleArgs(locales));
|
|
2106
|
+
}
|
|
2107
|
+
isSupersetLocale(superLocale, subLocale) {
|
|
2108
|
+
return _isSupersetLocale(this.resolveCanonicalLocale(superLocale), this.resolveCanonicalLocale(subLocale));
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
//#endregion
|
|
1956
2112
|
//#region src/index.ts
|
|
1957
2113
|
/**
|
|
1958
2114
|
* GT is the core driver for the General Translation library.
|
|
@@ -1969,6 +2125,10 @@ async function _publishFiles(files, config) {
|
|
|
1969
2125
|
* });
|
|
1970
2126
|
*/
|
|
1971
2127
|
var GT = class {
|
|
2128
|
+
/** Client-safe locale and formatting helpers */
|
|
2129
|
+
get localeConfig() {
|
|
2130
|
+
return this._localeConfig;
|
|
2131
|
+
}
|
|
1972
2132
|
/**
|
|
1973
2133
|
* Constructs an instance of the GT class.
|
|
1974
2134
|
*
|
|
@@ -1985,7 +2145,6 @@ var GT = class {
|
|
|
1985
2145
|
* });
|
|
1986
2146
|
*/
|
|
1987
2147
|
constructor(params = {}) {
|
|
1988
|
-
this._renderingLocales = [];
|
|
1989
2148
|
if (typeof process !== "undefined") {
|
|
1990
2149
|
this.apiKey ||= process.env?.GT_API_KEY;
|
|
1991
2150
|
this.devApiKey ||= process.env?.GT_DEV_API_KEY;
|
|
@@ -2005,10 +2164,6 @@ var GT = class {
|
|
|
2005
2164
|
this.targetLocale = _standardizeLocale(targetLocale);
|
|
2006
2165
|
if (!_isValidLocale(this.targetLocale, customMapping)) throw new Error(invalidLocaleError(this.targetLocale));
|
|
2007
2166
|
}
|
|
2008
|
-
this._renderingLocales = [];
|
|
2009
|
-
if (this.sourceLocale) this._renderingLocales.push(this.sourceLocale);
|
|
2010
|
-
if (this.targetLocale) this._renderingLocales.push(this.targetLocale);
|
|
2011
|
-
this._renderingLocales.push("en");
|
|
2012
2167
|
if (locales) {
|
|
2013
2168
|
const result = [];
|
|
2014
2169
|
const invalidLocales = [];
|
|
@@ -2025,6 +2180,11 @@ var GT = class {
|
|
|
2025
2180
|
this.customMapping = customMapping;
|
|
2026
2181
|
this.reverseCustomMapping = Object.fromEntries(Object.entries(customMapping).filter(([, value]) => value && typeof value === "object" && "code" in value).map(([key, value]) => [value.code, key]));
|
|
2027
2182
|
}
|
|
2183
|
+
this._localeConfig = new LocaleConfig({
|
|
2184
|
+
defaultLocale: this.sourceLocale,
|
|
2185
|
+
locales: this.locales ?? [],
|
|
2186
|
+
customMapping: this.customMapping
|
|
2187
|
+
});
|
|
2028
2188
|
}
|
|
2029
2189
|
_getTranslationConfig() {
|
|
2030
2190
|
return {
|
|
@@ -2521,10 +2681,7 @@ var GT = class {
|
|
|
2521
2681
|
* // Returns: '...ld!'
|
|
2522
2682
|
*/
|
|
2523
2683
|
formatCutoff(value, options) {
|
|
2524
|
-
return formatCutoff(value,
|
|
2525
|
-
locales: this._renderingLocales,
|
|
2526
|
-
...options
|
|
2527
|
-
});
|
|
2684
|
+
return this.localeConfig.formatCutoff(value, this.targetLocale, options);
|
|
2528
2685
|
}
|
|
2529
2686
|
/**
|
|
2530
2687
|
* Formats a message according to the specified locales and options.
|
|
@@ -2543,10 +2700,7 @@ var GT = class {
|
|
|
2543
2700
|
* // Returns: "Bonjour John"
|
|
2544
2701
|
*/
|
|
2545
2702
|
formatMessage(message, options) {
|
|
2546
|
-
return formatMessage(message,
|
|
2547
|
-
locales: this._renderingLocales,
|
|
2548
|
-
...options
|
|
2549
|
-
});
|
|
2703
|
+
return this.localeConfig.formatMessage(message, this.targetLocale, options);
|
|
2550
2704
|
}
|
|
2551
2705
|
/**
|
|
2552
2706
|
* Formats a number according to the specified locales and options.
|
|
@@ -2562,10 +2716,7 @@ var GT = class {
|
|
|
2562
2716
|
* // Returns: "$1,234.56"
|
|
2563
2717
|
*/
|
|
2564
2718
|
formatNum(number, options) {
|
|
2565
|
-
return formatNum(number,
|
|
2566
|
-
locales: this._renderingLocales,
|
|
2567
|
-
...options
|
|
2568
|
-
});
|
|
2719
|
+
return this.localeConfig.formatNum(number, this.targetLocale, options);
|
|
2569
2720
|
}
|
|
2570
2721
|
/**
|
|
2571
2722
|
* Formats a date according to the specified locales and options.
|
|
@@ -2581,10 +2732,7 @@ var GT = class {
|
|
|
2581
2732
|
* // Returns: "Thursday, March 14, 2024 at 2:30:45 PM GMT-7"
|
|
2582
2733
|
*/
|
|
2583
2734
|
formatDateTime(date, options) {
|
|
2584
|
-
return formatDateTime(date,
|
|
2585
|
-
locales: this._renderingLocales,
|
|
2586
|
-
...options
|
|
2587
|
-
});
|
|
2735
|
+
return this.localeConfig.formatDateTime(date, this.targetLocale, options);
|
|
2588
2736
|
}
|
|
2589
2737
|
/**
|
|
2590
2738
|
* Formats a currency value according to the specified locales and options.
|
|
@@ -2601,10 +2749,7 @@ var GT = class {
|
|
|
2601
2749
|
* // Returns: "$1,234.56"
|
|
2602
2750
|
*/
|
|
2603
2751
|
formatCurrency(value, currency, options) {
|
|
2604
|
-
return formatCurrency(value, currency,
|
|
2605
|
-
locales: this._renderingLocales,
|
|
2606
|
-
...options
|
|
2607
|
-
});
|
|
2752
|
+
return this.localeConfig.formatCurrency(value, currency, this.targetLocale, options);
|
|
2608
2753
|
}
|
|
2609
2754
|
/**
|
|
2610
2755
|
* Formats a list of items according to the specified locales and options.
|
|
@@ -2620,11 +2765,7 @@ var GT = class {
|
|
|
2620
2765
|
* // Returns: "apple, banana, and orange"
|
|
2621
2766
|
*/
|
|
2622
2767
|
formatList(array, options) {
|
|
2623
|
-
return
|
|
2624
|
-
value: array,
|
|
2625
|
-
locales: options?.locales || this._renderingLocales,
|
|
2626
|
-
options
|
|
2627
|
-
});
|
|
2768
|
+
return this.localeConfig.formatList(array, this.targetLocale, options);
|
|
2628
2769
|
}
|
|
2629
2770
|
/**
|
|
2630
2771
|
* Formats a list of items according to the specified locales and options.
|
|
@@ -2639,11 +2780,7 @@ var GT = class {
|
|
|
2639
2780
|
* // Returns: ['apple', ', ', 42, ' and ', '{ foo: "bar" }']
|
|
2640
2781
|
*/
|
|
2641
2782
|
formatListToParts(array, options) {
|
|
2642
|
-
return
|
|
2643
|
-
value: array,
|
|
2644
|
-
locales: options?.locales || this._renderingLocales,
|
|
2645
|
-
options
|
|
2646
|
-
});
|
|
2783
|
+
return this.localeConfig.formatListToParts(array, this.targetLocale, options);
|
|
2647
2784
|
}
|
|
2648
2785
|
/**
|
|
2649
2786
|
* Formats a relative time value according to the specified locales and options.
|
|
@@ -2660,10 +2797,7 @@ var GT = class {
|
|
|
2660
2797
|
* // Returns: "yesterday"
|
|
2661
2798
|
*/
|
|
2662
2799
|
formatRelativeTime(value, unit, options) {
|
|
2663
|
-
return formatRelativeTime(value, unit,
|
|
2664
|
-
locales: this._renderingLocales,
|
|
2665
|
-
...options
|
|
2666
|
-
});
|
|
2800
|
+
return this.localeConfig.formatRelativeTime(value, unit, this.targetLocale, options);
|
|
2667
2801
|
}
|
|
2668
2802
|
/**
|
|
2669
2803
|
* Formats a relative time string from a Date, automatically selecting the best unit.
|
|
@@ -2678,10 +2812,7 @@ var GT = class {
|
|
|
2678
2812
|
* // Returns: "1 hour ago"
|
|
2679
2813
|
*/
|
|
2680
2814
|
formatRelativeTimeFromDate(date, options) {
|
|
2681
|
-
return formatRelativeTimeFromDate(date,
|
|
2682
|
-
locales: this._renderingLocales,
|
|
2683
|
-
...options
|
|
2684
|
-
});
|
|
2815
|
+
return this.localeConfig.formatRelativeTimeFromDate(date, this.targetLocale, options);
|
|
2685
2816
|
}
|
|
2686
2817
|
/**
|
|
2687
2818
|
* Retrieves the display name of a locale code using Intl.DisplayNames, returning an empty string if no name is found.
|
|
@@ -2696,7 +2827,7 @@ var GT = class {
|
|
|
2696
2827
|
*/
|
|
2697
2828
|
getLocaleName(locale = this.targetLocale) {
|
|
2698
2829
|
if (!locale) throw new Error(noTargetLocaleProvidedError("getLocaleName"));
|
|
2699
|
-
return
|
|
2830
|
+
return this.localeConfig.getLocaleName(locale);
|
|
2700
2831
|
}
|
|
2701
2832
|
/**
|
|
2702
2833
|
* Retrieves an emoji based on a given locale code.
|
|
@@ -2712,7 +2843,7 @@ var GT = class {
|
|
|
2712
2843
|
*/
|
|
2713
2844
|
getLocaleEmoji(locale = this.targetLocale) {
|
|
2714
2845
|
if (!locale) throw new Error(noTargetLocaleProvidedError("getLocaleEmoji"));
|
|
2715
|
-
return getLocaleEmoji(locale
|
|
2846
|
+
return this.localeConfig.getLocaleEmoji(locale);
|
|
2716
2847
|
}
|
|
2717
2848
|
/**
|
|
2718
2849
|
* Generates linguistic details for a given locale code.
|
|
@@ -2748,7 +2879,7 @@ var GT = class {
|
|
|
2748
2879
|
*/
|
|
2749
2880
|
getLocaleProperties(locale = this.targetLocale) {
|
|
2750
2881
|
if (!locale) throw new Error(noTargetLocaleProvidedError("getLocaleProperties"));
|
|
2751
|
-
return getLocaleProperties(locale
|
|
2882
|
+
return this.localeConfig.getLocaleProperties(locale);
|
|
2752
2883
|
}
|
|
2753
2884
|
/**
|
|
2754
2885
|
* Retrieves multiple properties for a given region code, including:
|
|
@@ -2822,6 +2953,7 @@ var GT = class {
|
|
|
2822
2953
|
requiresTranslation(sourceLocale = this.sourceLocale, targetLocale = this.targetLocale, approvedLocales = this.locales, customMapping = this.customMapping) {
|
|
2823
2954
|
if (!sourceLocale) throw new Error(noSourceLocaleProvidedError("requiresTranslation"));
|
|
2824
2955
|
if (!targetLocale) throw new Error(noTargetLocaleProvidedError("requiresTranslation"));
|
|
2956
|
+
if (customMapping === this.customMapping) return this.localeConfig.requiresTranslation(targetLocale, sourceLocale, approvedLocales);
|
|
2825
2957
|
return _requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping);
|
|
2826
2958
|
}
|
|
2827
2959
|
/**
|
|
@@ -2836,6 +2968,7 @@ var GT = class {
|
|
|
2836
2968
|
* // Returns: "fr-FR"
|
|
2837
2969
|
*/
|
|
2838
2970
|
determineLocale(locales, approvedLocales = this.locales || [], customMapping = this.customMapping) {
|
|
2971
|
+
if (customMapping === this.customMapping) return this.localeConfig.determineLocale(locales, approvedLocales ?? []);
|
|
2839
2972
|
return _determineLocale(locales, approvedLocales, customMapping);
|
|
2840
2973
|
}
|
|
2841
2974
|
/**
|
|
@@ -2851,7 +2984,7 @@ var GT = class {
|
|
|
2851
2984
|
*/
|
|
2852
2985
|
getLocaleDirection(locale = this.targetLocale) {
|
|
2853
2986
|
if (!locale) throw new Error(noTargetLocaleProvidedError("getLocaleDirection"));
|
|
2854
|
-
return getLocaleDirection(locale);
|
|
2987
|
+
return this.localeConfig.getLocaleDirection(locale);
|
|
2855
2988
|
}
|
|
2856
2989
|
/**
|
|
2857
2990
|
* Checks if a given BCP 47 locale code is valid.
|
|
@@ -2867,7 +3000,8 @@ var GT = class {
|
|
|
2867
3000
|
*/
|
|
2868
3001
|
isValidLocale(locale = this.targetLocale, customMapping = this.customMapping) {
|
|
2869
3002
|
if (!locale) throw new Error(noTargetLocaleProvidedError("isValidLocale"));
|
|
2870
|
-
return isValidLocale(locale
|
|
3003
|
+
if (customMapping === this.customMapping) return this.localeConfig.isValidLocale(locale);
|
|
3004
|
+
return _isValidLocale(locale, customMapping);
|
|
2871
3005
|
}
|
|
2872
3006
|
/**
|
|
2873
3007
|
* Resolves the canonical locale for a given locale.
|
|
@@ -2877,6 +3011,7 @@ var GT = class {
|
|
|
2877
3011
|
*/
|
|
2878
3012
|
resolveCanonicalLocale(locale = this.targetLocale, customMapping = this.customMapping) {
|
|
2879
3013
|
if (!locale) throw new Error(noTargetLocaleProvidedError("resolveCanonicalLocale"));
|
|
3014
|
+
if (customMapping === this.customMapping) return this.localeConfig.resolveCanonicalLocale(locale);
|
|
2880
3015
|
return _resolveCanonicalLocale(locale, customMapping);
|
|
2881
3016
|
}
|
|
2882
3017
|
/**
|
|
@@ -2887,6 +3022,7 @@ var GT = class {
|
|
|
2887
3022
|
*/
|
|
2888
3023
|
resolveAliasLocale(locale, customMapping = this.customMapping) {
|
|
2889
3024
|
if (!locale) throw new Error(noTargetLocaleProvidedError("resolveAliasLocale"));
|
|
3025
|
+
if (customMapping === this.customMapping) return this.localeConfig.resolveAliasLocale(locale);
|
|
2890
3026
|
return _resolveAliasLocale(locale, customMapping);
|
|
2891
3027
|
}
|
|
2892
3028
|
/**
|
|
@@ -2902,7 +3038,7 @@ var GT = class {
|
|
|
2902
3038
|
*/
|
|
2903
3039
|
standardizeLocale(locale = this.targetLocale) {
|
|
2904
3040
|
if (!locale) throw new Error(noTargetLocaleProvidedError("standardizeLocale"));
|
|
2905
|
-
return
|
|
3041
|
+
return this.localeConfig.standardizeLocale(locale);
|
|
2906
3042
|
}
|
|
2907
3043
|
/**
|
|
2908
3044
|
* Checks if multiple BCP 47 locale codes represent the same dialect.
|
|
@@ -2918,7 +3054,7 @@ var GT = class {
|
|
|
2918
3054
|
* // Returns: true
|
|
2919
3055
|
*/
|
|
2920
3056
|
isSameDialect(...locales) {
|
|
2921
|
-
return isSameDialect(...locales);
|
|
3057
|
+
return this.localeConfig.isSameDialect(...locales);
|
|
2922
3058
|
}
|
|
2923
3059
|
/**
|
|
2924
3060
|
* Checks if multiple BCP 47 locale codes represent the same language.
|
|
@@ -2931,7 +3067,7 @@ var GT = class {
|
|
|
2931
3067
|
* // Returns: true
|
|
2932
3068
|
*/
|
|
2933
3069
|
isSameLanguage(...locales) {
|
|
2934
|
-
return
|
|
3070
|
+
return this.localeConfig.isSameLanguage(...locales);
|
|
2935
3071
|
}
|
|
2936
3072
|
/**
|
|
2937
3073
|
* Checks if a locale is a superset of another locale.
|
|
@@ -2948,7 +3084,7 @@ var GT = class {
|
|
|
2948
3084
|
* // Returns: false
|
|
2949
3085
|
*/
|
|
2950
3086
|
isSupersetLocale(superLocale, subLocale) {
|
|
2951
|
-
return isSupersetLocale(superLocale, subLocale);
|
|
3087
|
+
return this.localeConfig.isSupersetLocale(superLocale, subLocale);
|
|
2952
3088
|
}
|
|
2953
3089
|
};
|
|
2954
3090
|
/**
|
|
@@ -3326,6 +3462,7 @@ const API_VERSION = API_VERSION$1;
|
|
|
3326
3462
|
//#endregion
|
|
3327
3463
|
exports.API_VERSION = API_VERSION;
|
|
3328
3464
|
exports.GT = GT;
|
|
3465
|
+
exports.LocaleConfig = LocaleConfig;
|
|
3329
3466
|
exports.__toESM = __toESM;
|
|
3330
3467
|
exports.determineLocale = determineLocale;
|
|
3331
3468
|
exports.formatCurrency = formatCurrency;
|