i18next 21.9.2 → 22.0.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/dist/cjs/i18next.js +51 -16
- package/dist/esm/i18next.bundled.js +51 -16
- package/dist/esm/i18next.js +51 -16
- package/dist/esm/package.json +1 -1
- package/dist/umd/i18next.js +51 -16
- package/dist/umd/i18next.min.js +1 -1
- package/i18next.js +51 -16
- package/i18next.min.js +1 -1
- package/index.d.ts +283 -101
- package/package.json +4 -3
package/dist/cjs/i18next.js
CHANGED
|
@@ -1772,6 +1772,21 @@ function parseFormatStr(formatStr) {
|
|
|
1772
1772
|
};
|
|
1773
1773
|
}
|
|
1774
1774
|
|
|
1775
|
+
function createCachedFormatter(fn) {
|
|
1776
|
+
var cache = {};
|
|
1777
|
+
return function invokeFormatter(val, lng, options) {
|
|
1778
|
+
var key = lng + JSON.stringify(options);
|
|
1779
|
+
var formatter = cache[key];
|
|
1780
|
+
|
|
1781
|
+
if (!formatter) {
|
|
1782
|
+
formatter = fn(lng, options);
|
|
1783
|
+
cache[key] = formatter;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
return formatter(val);
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1775
1790
|
var Formatter = function () {
|
|
1776
1791
|
function Formatter() {
|
|
1777
1792
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1781,23 +1796,38 @@ var Formatter = function () {
|
|
|
1781
1796
|
this.logger = baseLogger.create('formatter');
|
|
1782
1797
|
this.options = options;
|
|
1783
1798
|
this.formats = {
|
|
1784
|
-
number: function
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1799
|
+
number: createCachedFormatter(function (lng, options) {
|
|
1800
|
+
var formatter = new Intl.NumberFormat(lng, options);
|
|
1801
|
+
return function (val) {
|
|
1802
|
+
return formatter.format(val);
|
|
1803
|
+
};
|
|
1804
|
+
}),
|
|
1805
|
+
currency: createCachedFormatter(function (lng, options) {
|
|
1806
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
1789
1807
|
style: 'currency'
|
|
1790
|
-
}))
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
},
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
}
|
|
1808
|
+
}));
|
|
1809
|
+
return function (val) {
|
|
1810
|
+
return formatter.format(val);
|
|
1811
|
+
};
|
|
1812
|
+
}),
|
|
1813
|
+
datetime: createCachedFormatter(function (lng, options) {
|
|
1814
|
+
var formatter = new Intl.DateTimeFormat(lng, _objectSpread$4({}, options));
|
|
1815
|
+
return function (val) {
|
|
1816
|
+
return formatter.format(val);
|
|
1817
|
+
};
|
|
1818
|
+
}),
|
|
1819
|
+
relativetime: createCachedFormatter(function (lng, options) {
|
|
1820
|
+
var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$4({}, options));
|
|
1821
|
+
return function (val) {
|
|
1822
|
+
return formatter.format(val, options.range || 'day');
|
|
1823
|
+
};
|
|
1824
|
+
}),
|
|
1825
|
+
list: createCachedFormatter(function (lng, options) {
|
|
1826
|
+
var formatter = new Intl.ListFormat(lng, _objectSpread$4({}, options));
|
|
1827
|
+
return function (val) {
|
|
1828
|
+
return formatter.format(val);
|
|
1829
|
+
};
|
|
1830
|
+
})
|
|
1801
1831
|
};
|
|
1802
1832
|
this.init(options);
|
|
1803
1833
|
}
|
|
@@ -1816,6 +1846,11 @@ var Formatter = function () {
|
|
|
1816
1846
|
value: function add(name, fc) {
|
|
1817
1847
|
this.formats[name.toLowerCase().trim()] = fc;
|
|
1818
1848
|
}
|
|
1849
|
+
}, {
|
|
1850
|
+
key: "addCached",
|
|
1851
|
+
value: function addCached(name, fc) {
|
|
1852
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1853
|
+
}
|
|
1819
1854
|
}, {
|
|
1820
1855
|
key: "format",
|
|
1821
1856
|
value: function format(value, _format, lng, options) {
|
|
@@ -1926,6 +1926,21 @@ function parseFormatStr(formatStr) {
|
|
|
1926
1926
|
};
|
|
1927
1927
|
}
|
|
1928
1928
|
|
|
1929
|
+
function createCachedFormatter(fn) {
|
|
1930
|
+
var cache = {};
|
|
1931
|
+
return function invokeFormatter(val, lng, options) {
|
|
1932
|
+
var key = lng + JSON.stringify(options);
|
|
1933
|
+
var formatter = cache[key];
|
|
1934
|
+
|
|
1935
|
+
if (!formatter) {
|
|
1936
|
+
formatter = fn(lng, options);
|
|
1937
|
+
cache[key] = formatter;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
return formatter(val);
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1929
1944
|
var Formatter = function () {
|
|
1930
1945
|
function Formatter() {
|
|
1931
1946
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1935,23 +1950,38 @@ var Formatter = function () {
|
|
|
1935
1950
|
this.logger = baseLogger.create('formatter');
|
|
1936
1951
|
this.options = options;
|
|
1937
1952
|
this.formats = {
|
|
1938
|
-
number: function
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1953
|
+
number: createCachedFormatter(function (lng, options) {
|
|
1954
|
+
var formatter = new Intl.NumberFormat(lng, options);
|
|
1955
|
+
return function (val) {
|
|
1956
|
+
return formatter.format(val);
|
|
1957
|
+
};
|
|
1958
|
+
}),
|
|
1959
|
+
currency: createCachedFormatter(function (lng, options) {
|
|
1960
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1943
1961
|
style: 'currency'
|
|
1944
|
-
}))
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
},
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
}
|
|
1962
|
+
}));
|
|
1963
|
+
return function (val) {
|
|
1964
|
+
return formatter.format(val);
|
|
1965
|
+
};
|
|
1966
|
+
}),
|
|
1967
|
+
datetime: createCachedFormatter(function (lng, options) {
|
|
1968
|
+
var formatter = new Intl.DateTimeFormat(lng, _objectSpread2({}, options));
|
|
1969
|
+
return function (val) {
|
|
1970
|
+
return formatter.format(val);
|
|
1971
|
+
};
|
|
1972
|
+
}),
|
|
1973
|
+
relativetime: createCachedFormatter(function (lng, options) {
|
|
1974
|
+
var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread2({}, options));
|
|
1975
|
+
return function (val) {
|
|
1976
|
+
return formatter.format(val, options.range || 'day');
|
|
1977
|
+
};
|
|
1978
|
+
}),
|
|
1979
|
+
list: createCachedFormatter(function (lng, options) {
|
|
1980
|
+
var formatter = new Intl.ListFormat(lng, _objectSpread2({}, options));
|
|
1981
|
+
return function (val) {
|
|
1982
|
+
return formatter.format(val);
|
|
1983
|
+
};
|
|
1984
|
+
})
|
|
1955
1985
|
};
|
|
1956
1986
|
this.init(options);
|
|
1957
1987
|
}
|
|
@@ -1970,6 +2000,11 @@ var Formatter = function () {
|
|
|
1970
2000
|
value: function add(name, fc) {
|
|
1971
2001
|
this.formats[name.toLowerCase().trim()] = fc;
|
|
1972
2002
|
}
|
|
2003
|
+
}, {
|
|
2004
|
+
key: "addCached",
|
|
2005
|
+
value: function addCached(name, fc) {
|
|
2006
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
2007
|
+
}
|
|
1973
2008
|
}, {
|
|
1974
2009
|
key: "format",
|
|
1975
2010
|
value: function format(value, _format, lng, options) {
|
package/dist/esm/i18next.js
CHANGED
|
@@ -1758,6 +1758,21 @@ function parseFormatStr(formatStr) {
|
|
|
1758
1758
|
};
|
|
1759
1759
|
}
|
|
1760
1760
|
|
|
1761
|
+
function createCachedFormatter(fn) {
|
|
1762
|
+
var cache = {};
|
|
1763
|
+
return function invokeFormatter(val, lng, options) {
|
|
1764
|
+
var key = lng + JSON.stringify(options);
|
|
1765
|
+
var formatter = cache[key];
|
|
1766
|
+
|
|
1767
|
+
if (!formatter) {
|
|
1768
|
+
formatter = fn(lng, options);
|
|
1769
|
+
cache[key] = formatter;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
return formatter(val);
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1761
1776
|
var Formatter = function () {
|
|
1762
1777
|
function Formatter() {
|
|
1763
1778
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1767,23 +1782,38 @@ var Formatter = function () {
|
|
|
1767
1782
|
this.logger = baseLogger.create('formatter');
|
|
1768
1783
|
this.options = options;
|
|
1769
1784
|
this.formats = {
|
|
1770
|
-
number: function
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1785
|
+
number: createCachedFormatter(function (lng, options) {
|
|
1786
|
+
var formatter = new Intl.NumberFormat(lng, options);
|
|
1787
|
+
return function (val) {
|
|
1788
|
+
return formatter.format(val);
|
|
1789
|
+
};
|
|
1790
|
+
}),
|
|
1791
|
+
currency: createCachedFormatter(function (lng, options) {
|
|
1792
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
1775
1793
|
style: 'currency'
|
|
1776
|
-
}))
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
},
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
}
|
|
1794
|
+
}));
|
|
1795
|
+
return function (val) {
|
|
1796
|
+
return formatter.format(val);
|
|
1797
|
+
};
|
|
1798
|
+
}),
|
|
1799
|
+
datetime: createCachedFormatter(function (lng, options) {
|
|
1800
|
+
var formatter = new Intl.DateTimeFormat(lng, _objectSpread$4({}, options));
|
|
1801
|
+
return function (val) {
|
|
1802
|
+
return formatter.format(val);
|
|
1803
|
+
};
|
|
1804
|
+
}),
|
|
1805
|
+
relativetime: createCachedFormatter(function (lng, options) {
|
|
1806
|
+
var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$4({}, options));
|
|
1807
|
+
return function (val) {
|
|
1808
|
+
return formatter.format(val, options.range || 'day');
|
|
1809
|
+
};
|
|
1810
|
+
}),
|
|
1811
|
+
list: createCachedFormatter(function (lng, options) {
|
|
1812
|
+
var formatter = new Intl.ListFormat(lng, _objectSpread$4({}, options));
|
|
1813
|
+
return function (val) {
|
|
1814
|
+
return formatter.format(val);
|
|
1815
|
+
};
|
|
1816
|
+
})
|
|
1787
1817
|
};
|
|
1788
1818
|
this.init(options);
|
|
1789
1819
|
}
|
|
@@ -1802,6 +1832,11 @@ var Formatter = function () {
|
|
|
1802
1832
|
value: function add(name, fc) {
|
|
1803
1833
|
this.formats[name.toLowerCase().trim()] = fc;
|
|
1804
1834
|
}
|
|
1835
|
+
}, {
|
|
1836
|
+
key: "addCached",
|
|
1837
|
+
value: function addCached(name, fc) {
|
|
1838
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1839
|
+
}
|
|
1805
1840
|
}, {
|
|
1806
1841
|
key: "format",
|
|
1807
1842
|
value: function format(value, _format, lng, options) {
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"
|
|
1
|
+
{"type":"module","version":"22.0.0"}
|
package/dist/umd/i18next.js
CHANGED
|
@@ -1891,6 +1891,21 @@
|
|
|
1891
1891
|
};
|
|
1892
1892
|
}
|
|
1893
1893
|
|
|
1894
|
+
function createCachedFormatter(fn) {
|
|
1895
|
+
var cache = {};
|
|
1896
|
+
return function invokeFormatter(val, lng, options) {
|
|
1897
|
+
var key = lng + JSON.stringify(options);
|
|
1898
|
+
var formatter = cache[key];
|
|
1899
|
+
|
|
1900
|
+
if (!formatter) {
|
|
1901
|
+
formatter = fn(lng, options);
|
|
1902
|
+
cache[key] = formatter;
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
return formatter(val);
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1894
1909
|
var Formatter = function () {
|
|
1895
1910
|
function Formatter() {
|
|
1896
1911
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1900,23 +1915,38 @@
|
|
|
1900
1915
|
this.logger = baseLogger.create('formatter');
|
|
1901
1916
|
this.options = options;
|
|
1902
1917
|
this.formats = {
|
|
1903
|
-
number: function
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1918
|
+
number: createCachedFormatter(function (lng, options) {
|
|
1919
|
+
var formatter = new Intl.NumberFormat(lng, options);
|
|
1920
|
+
return function (val) {
|
|
1921
|
+
return formatter.format(val);
|
|
1922
|
+
};
|
|
1923
|
+
}),
|
|
1924
|
+
currency: createCachedFormatter(function (lng, options) {
|
|
1925
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
1908
1926
|
style: 'currency'
|
|
1909
|
-
}))
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
},
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
}
|
|
1927
|
+
}));
|
|
1928
|
+
return function (val) {
|
|
1929
|
+
return formatter.format(val);
|
|
1930
|
+
};
|
|
1931
|
+
}),
|
|
1932
|
+
datetime: createCachedFormatter(function (lng, options) {
|
|
1933
|
+
var formatter = new Intl.DateTimeFormat(lng, _objectSpread$4({}, options));
|
|
1934
|
+
return function (val) {
|
|
1935
|
+
return formatter.format(val);
|
|
1936
|
+
};
|
|
1937
|
+
}),
|
|
1938
|
+
relativetime: createCachedFormatter(function (lng, options) {
|
|
1939
|
+
var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$4({}, options));
|
|
1940
|
+
return function (val) {
|
|
1941
|
+
return formatter.format(val, options.range || 'day');
|
|
1942
|
+
};
|
|
1943
|
+
}),
|
|
1944
|
+
list: createCachedFormatter(function (lng, options) {
|
|
1945
|
+
var formatter = new Intl.ListFormat(lng, _objectSpread$4({}, options));
|
|
1946
|
+
return function (val) {
|
|
1947
|
+
return formatter.format(val);
|
|
1948
|
+
};
|
|
1949
|
+
})
|
|
1920
1950
|
};
|
|
1921
1951
|
this.init(options);
|
|
1922
1952
|
}
|
|
@@ -1935,6 +1965,11 @@
|
|
|
1935
1965
|
value: function add(name, fc) {
|
|
1936
1966
|
this.formats[name.toLowerCase().trim()] = fc;
|
|
1937
1967
|
}
|
|
1968
|
+
}, {
|
|
1969
|
+
key: "addCached",
|
|
1970
|
+
value: function addCached(name, fc) {
|
|
1971
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1972
|
+
}
|
|
1938
1973
|
}, {
|
|
1939
1974
|
key: "format",
|
|
1940
1975
|
value: function format(value, _format, lng, options) {
|