@esmate/utils 1.0.7 → 1.0.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/dist/locale.d.ts +4 -4
- package/dist/locale.js +5 -5
- package/package.json +1 -1
package/dist/locale.d.ts
CHANGED
|
@@ -3,23 +3,23 @@ export interface TimeZone {
|
|
|
3
3
|
value: string;
|
|
4
4
|
offset: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function getTimeZones(locale?: string): TimeZone[];
|
|
7
7
|
export declare function getCurrentTimeZone(): string;
|
|
8
8
|
interface Language {
|
|
9
9
|
name: string;
|
|
10
10
|
value: string;
|
|
11
11
|
}
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function getLanguages(locale?: string): Language[];
|
|
13
13
|
export declare function getCurrentLanguage(): string;
|
|
14
14
|
interface Country {
|
|
15
15
|
name: string;
|
|
16
16
|
value: string;
|
|
17
17
|
}
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function getCountries(locale?: string): Country[];
|
|
19
19
|
export declare function getCurrentCountry(): string;
|
|
20
20
|
interface Currency {
|
|
21
21
|
name: string;
|
|
22
22
|
value: string;
|
|
23
23
|
}
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function getCurrencies(locale?: string): Currency[];
|
|
25
25
|
export {};
|
package/dist/locale.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_iso_3166_1_0ebcf719__ from "iso-3166-1";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_iso_639_1_39eb3c8b__ from "iso-639-1";
|
|
3
|
-
function
|
|
3
|
+
function getTimeZones(locale = "en-US") {
|
|
4
4
|
const timeZones = Intl.supportedValuesOf("timeZone");
|
|
5
5
|
const getOffset = (timeZone)=>{
|
|
6
6
|
const offset = new Intl.DateTimeFormat(locale, {
|
|
@@ -22,7 +22,7 @@ function getTimeZoneList(locale = "en-US") {
|
|
|
22
22
|
function getCurrentTimeZone() {
|
|
23
23
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function getLanguages(locale = "en-US") {
|
|
26
26
|
const codes = __WEBPACK_EXTERNAL_MODULE_iso_639_1_39eb3c8b__["default"].getAllCodes().sort((a, b)=>a.localeCompare(b));
|
|
27
27
|
return codes.map((code)=>{
|
|
28
28
|
const name = new Intl.DisplayNames([
|
|
@@ -39,7 +39,7 @@ function getLanguageList(locale = "en-US") {
|
|
|
39
39
|
function getCurrentLanguage() {
|
|
40
40
|
return (navigator.language || "en-US").split("-")[0];
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function getCountries(locale = "en-US") {
|
|
43
43
|
const countryList = __WEBPACK_EXTERNAL_MODULE_iso_3166_1_0ebcf719__["default"].all().map((country)=>({
|
|
44
44
|
name: country.country,
|
|
45
45
|
code: country.alpha2
|
|
@@ -59,7 +59,7 @@ function getCountryList(locale = "en-US") {
|
|
|
59
59
|
function getCurrentCountry() {
|
|
60
60
|
return (navigator.language || "en-US").split("-")[1];
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function getCurrencies(locale = "en-US") {
|
|
63
63
|
const codes = Intl.supportedValuesOf("currency");
|
|
64
64
|
return codes.map((code)=>{
|
|
65
65
|
const name = new Intl.DisplayNames([
|
|
@@ -74,4 +74,4 @@ function getCurrencyList(locale = "en-US") {
|
|
|
74
74
|
};
|
|
75
75
|
}).sort((a, b)=>a.name.localeCompare(b.name));
|
|
76
76
|
}
|
|
77
|
-
export {
|
|
77
|
+
export { getCountries, getCurrencies, getCurrentCountry, getCurrentLanguage, getCurrentTimeZone, getLanguages, getTimeZones };
|