next-translate 1.3.2 → 1.3.5
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/README.md +2 -0
- package/index.d.ts +1 -0
- package/lib/cjs/plugin/templateWithHoc.js +1 -1
- package/lib/cjs/plugin/templateWithLoader.js +1 -1
- package/lib/cjs/transCore.js +2 -2
- package/lib/esm/plugin/templateWithHoc.js +1 -1
- package/lib/esm/plugin/templateWithLoader.js +2 -2
- package/lib/esm/transCore.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -959,6 +959,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
959
959
|
<td align="center"><a href="https://github.com/testerez"><img src="https://avatars.githubusercontent.com/u/815236?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tom Esterez</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=testerez" title="Code">💻</a></td>
|
|
960
960
|
<td align="center"><a href="http://www.dan-needham.com"><img src="https://avatars.githubusercontent.com/u/1122983?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dan Needham</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=dndhm" title="Code">💻</a> <a href="https://github.com/vinissimus/next-translate/commits?author=dndhm" title="Tests">⚠️</a> <a href="https://github.com/vinissimus/next-translate/commits?author=dndhm" title="Documentation">📖</a></td>
|
|
961
961
|
<td align="center"><a href="https://www.youtube.com/BrunoAntunesPT"><img src="https://avatars.githubusercontent.com/u/9042965?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bruno Antunes</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=bmvantunes" title="Code">💻</a></td>
|
|
962
|
+
<td align="center"><a href="https://github.com/kaan-atakan"><img src="https://avatars.githubusercontent.com/u/56063979?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaan Atakan</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=kaan-atakan" title="Code">💻</a></td>
|
|
963
|
+
<td align="center"><a href="https://github.com/groomain"><img src="https://avatars.githubusercontent.com/u/3601848?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Romain</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=groomain" title="Code">💻</a></td>
|
|
962
964
|
</tr>
|
|
963
965
|
</table>
|
|
964
966
|
|
package/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ function templateWithHoc(code, _a) {
|
|
|
5
5
|
var _b = _a === void 0 ? {} : _a, _c = _b.skipInitialProps, skipInitialProps = _c === void 0 ? false : _c, _d = _b.typescript, typescript = _d === void 0 ? false : _d, _e = _b.pageName, pageName = _e === void 0 ? '__Page_Next_Translate__' : _e, _f = _b.hasLoadLocaleFrom, hasLoadLocaleFrom = _f === void 0 ? false : _f;
|
|
6
6
|
var tokenToReplace = "__CODE_TOKEN_".concat(Date.now().toString(16), "__");
|
|
7
7
|
var codeWithoutComments = code.replace(utils_1.clearCommentsRgx, '');
|
|
8
|
-
var modifiedCode =
|
|
8
|
+
var modifiedCode = code.replace(/export +default/g, "const ".concat(pageName, " ="));
|
|
9
9
|
var _g = codeWithoutComments.match(/export +default +(function|class) +([A-Z]\w*)/) || [], componentName = _g[2];
|
|
10
10
|
if (componentName) {
|
|
11
11
|
modifiedCode = modifiedCode.replace(new RegExp("\\W".concat(componentName, "\\.getInitialProps"), 'g'), "".concat(pageName, ".getInitialProps"));
|
|
@@ -4,7 +4,7 @@ var utils_1 = require("./utils");
|
|
|
4
4
|
function templateWithLoader(rawCode, _a) {
|
|
5
5
|
var _b = _a === void 0 ? {} : _a, _c = _b.page, page = _c === void 0 ? '' : _c, _d = _b.typescript, typescript = _d === void 0 ? false : _d, _e = _b.loader, loader = _e === void 0 ? 'getStaticProps' : _e, _f = _b.hasLoader, hasLoader = _f === void 0 ? false : _f, _g = _b.hasLoadLocaleFrom, hasLoadLocaleFrom = _g === void 0 ? false : _g, _h = _b.revalidate, revalidate = _h === void 0 ? 0 : _h;
|
|
6
6
|
var tokenToReplace = "__CODE_TOKEN_".concat(Date.now().toString(16), "__");
|
|
7
|
-
var modifiedCode = rawCode
|
|
7
|
+
var modifiedCode = rawCode;
|
|
8
8
|
if (hasLoader) {
|
|
9
9
|
modifiedCode = modifiedCode
|
|
10
10
|
.replace(new RegExp("(const|var|let|async +function|function|import|import {.* as) +".concat(loader, "\\W")), function (v) {
|
package/lib/cjs/transCore.js
CHANGED
|
@@ -94,7 +94,7 @@ function plural(pluralRules, dic, key, config, query) {
|
|
|
94
94
|
if (getDicValue(dic, numKey, config) !== undefined)
|
|
95
95
|
return numKey;
|
|
96
96
|
var pluralKey = "".concat(key, "_").concat(pluralRules.select(query.count));
|
|
97
|
-
if (
|
|
97
|
+
if (getDicValue(dic, pluralKey, config) !== undefined) {
|
|
98
98
|
return pluralKey;
|
|
99
99
|
}
|
|
100
100
|
var nestedNumKey = "".concat(key, ".").concat(query.count);
|
|
@@ -113,7 +113,7 @@ function interpolation(_a) {
|
|
|
113
113
|
return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
114
114
|
};
|
|
115
115
|
var _b = config.interpolation || {}, _c = _b.format, format = _c === void 0 ? null : _c, _d = _b.prefix, prefix = _d === void 0 ? '{{' : _d, _e = _b.suffix, suffix = _e === void 0 ? '}}' : _e;
|
|
116
|
-
var regexEnd = suffix === '' ? '' : "\\s
|
|
116
|
+
var regexEnd = suffix === '' ? '' : "(?:[\\s,]+([\\w-]*))?\\s*".concat(escapeRegex(suffix));
|
|
117
117
|
return Object.keys(query).reduce(function (all, varKey) {
|
|
118
118
|
var regex = new RegExp("".concat(escapeRegex(prefix), "\\s*").concat(varKey).concat(regexEnd), 'gm');
|
|
119
119
|
return all.replace(regex, function (_match, $1) {
|
|
@@ -3,7 +3,7 @@ export default function templateWithHoc(code, _a) {
|
|
|
3
3
|
var _b = _a === void 0 ? {} : _a, _c = _b.skipInitialProps, skipInitialProps = _c === void 0 ? false : _c, _d = _b.typescript, typescript = _d === void 0 ? false : _d, _e = _b.pageName, pageName = _e === void 0 ? '__Page_Next_Translate__' : _e, _f = _b.hasLoadLocaleFrom, hasLoadLocaleFrom = _f === void 0 ? false : _f;
|
|
4
4
|
var tokenToReplace = "__CODE_TOKEN_".concat(Date.now().toString(16), "__");
|
|
5
5
|
var codeWithoutComments = code.replace(clearCommentsRgx, '');
|
|
6
|
-
var modifiedCode =
|
|
6
|
+
var modifiedCode = code.replace(/export +default/g, "const ".concat(pageName, " ="));
|
|
7
7
|
var _g = codeWithoutComments.match(/export +default +(function|class) +([A-Z]\w*)/) || [], componentName = _g[2];
|
|
8
8
|
if (componentName) {
|
|
9
9
|
modifiedCode = modifiedCode.replace(new RegExp("\\W".concat(componentName, "\\.getInitialProps"), 'g'), "".concat(pageName, ".getInitialProps"));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { overwriteLoadLocales } from './utils';
|
|
2
2
|
export default function templateWithLoader(rawCode, _a) {
|
|
3
3
|
var _b = _a === void 0 ? {} : _a, _c = _b.page, page = _c === void 0 ? '' : _c, _d = _b.typescript, typescript = _d === void 0 ? false : _d, _e = _b.loader, loader = _e === void 0 ? 'getStaticProps' : _e, _f = _b.hasLoader, hasLoader = _f === void 0 ? false : _f, _g = _b.hasLoadLocaleFrom, hasLoadLocaleFrom = _g === void 0 ? false : _g, _h = _b.revalidate, revalidate = _h === void 0 ? 0 : _h;
|
|
4
4
|
var tokenToReplace = "__CODE_TOKEN_".concat(Date.now().toString(16), "__");
|
|
5
|
-
var modifiedCode = rawCode
|
|
5
|
+
var modifiedCode = rawCode;
|
|
6
6
|
if (hasLoader) {
|
|
7
7
|
modifiedCode = modifiedCode
|
|
8
8
|
.replace(new RegExp("(const|var|let|async +function|function|import|import {.* as) +".concat(loader, "\\W")), function (v) {
|
package/lib/esm/transCore.js
CHANGED
|
@@ -91,7 +91,7 @@ function plural(pluralRules, dic, key, config, query) {
|
|
|
91
91
|
if (getDicValue(dic, numKey, config) !== undefined)
|
|
92
92
|
return numKey;
|
|
93
93
|
var pluralKey = "".concat(key, "_").concat(pluralRules.select(query.count));
|
|
94
|
-
if (
|
|
94
|
+
if (getDicValue(dic, pluralKey, config) !== undefined) {
|
|
95
95
|
return pluralKey;
|
|
96
96
|
}
|
|
97
97
|
var nestedNumKey = "".concat(key, ".").concat(query.count);
|
|
@@ -110,7 +110,7 @@ function interpolation(_a) {
|
|
|
110
110
|
return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
111
111
|
};
|
|
112
112
|
var _b = config.interpolation || {}, _c = _b.format, format = _c === void 0 ? null : _c, _d = _b.prefix, prefix = _d === void 0 ? '{{' : _d, _e = _b.suffix, suffix = _e === void 0 ? '}}' : _e;
|
|
113
|
-
var regexEnd = suffix === '' ? '' : "\\s
|
|
113
|
+
var regexEnd = suffix === '' ? '' : "(?:[\\s,]+([\\w-]*))?\\s*".concat(escapeRegex(suffix));
|
|
114
114
|
return Object.keys(query).reduce(function (all, varKey) {
|
|
115
115
|
var regex = new RegExp("".concat(escapeRegex(prefix), "\\s*").concat(varKey).concat(regexEnd), 'gm');
|
|
116
116
|
return all.replace(regex, function (_match, $1) {
|