@lingui/core 5.3.2 → 5.3.3
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/index.cjs +21 -6
- package/dist/index.mjs +21 -6
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const unraw = require('unraw');
|
|
4
3
|
const compileMessage = require('@lingui/message-utils/compileMessage');
|
|
5
4
|
|
|
6
5
|
const isString = (s) => typeof s === "string";
|
|
@@ -109,7 +108,23 @@ const formats = {
|
|
|
109
108
|
time: time
|
|
110
109
|
};
|
|
111
110
|
|
|
112
|
-
const
|
|
111
|
+
const ESCAPE_SEQUENCE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/;
|
|
112
|
+
const decodeEscapeSequences = (str) => {
|
|
113
|
+
return str.replace(
|
|
114
|
+
// Same pattern but with capturing groups for extracting values during replacement
|
|
115
|
+
/\\u([a-fA-F0-9]{4})|\\x([a-fA-F0-9]{2})/g,
|
|
116
|
+
(_, unicode, hex) => {
|
|
117
|
+
if (unicode) {
|
|
118
|
+
const codePoint = parseInt(unicode, 16);
|
|
119
|
+
return String.fromCharCode(codePoint);
|
|
120
|
+
} else {
|
|
121
|
+
const codePoint = parseInt(hex, 16);
|
|
122
|
+
return String.fromCharCode(codePoint);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
113
128
|
const OCTOTHORPE_PH = "%__lingui_octothorpe__%";
|
|
114
129
|
const getDefaultFormats = (locale, passedLocales, formats = {}) => {
|
|
115
130
|
const locales = passedLocales || locale;
|
|
@@ -186,8 +201,8 @@ function interpolate(translation, locale, locales) {
|
|
|
186
201
|
}, "");
|
|
187
202
|
};
|
|
188
203
|
const result = formatMessage(translation);
|
|
189
|
-
if (isString(result) &&
|
|
190
|
-
return
|
|
204
|
+
if (isString(result) && ESCAPE_SEQUENCE_REGEX.test(result)) {
|
|
205
|
+
return decodeEscapeSequences(result);
|
|
191
206
|
}
|
|
192
207
|
if (isString(result))
|
|
193
208
|
return result;
|
|
@@ -395,8 +410,8 @@ Please compile your catalog first.
|
|
|
395
410
|
`);
|
|
396
411
|
}
|
|
397
412
|
}
|
|
398
|
-
if (isString(translation) &&
|
|
399
|
-
return
|
|
413
|
+
if (isString(translation) && ESCAPE_SEQUENCE_REGEX.test(translation))
|
|
414
|
+
return decodeEscapeSequences(translation);
|
|
400
415
|
if (isString(translation))
|
|
401
416
|
return translation;
|
|
402
417
|
return interpolate(
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { unraw } from 'unraw';
|
|
2
1
|
import { compileMessage } from '@lingui/message-utils/compileMessage';
|
|
3
2
|
|
|
4
3
|
const isString = (s) => typeof s === "string";
|
|
@@ -107,7 +106,23 @@ const formats = {
|
|
|
107
106
|
time: time
|
|
108
107
|
};
|
|
109
108
|
|
|
110
|
-
const
|
|
109
|
+
const ESCAPE_SEQUENCE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/;
|
|
110
|
+
const decodeEscapeSequences = (str) => {
|
|
111
|
+
return str.replace(
|
|
112
|
+
// Same pattern but with capturing groups for extracting values during replacement
|
|
113
|
+
/\\u([a-fA-F0-9]{4})|\\x([a-fA-F0-9]{2})/g,
|
|
114
|
+
(_, unicode, hex) => {
|
|
115
|
+
if (unicode) {
|
|
116
|
+
const codePoint = parseInt(unicode, 16);
|
|
117
|
+
return String.fromCharCode(codePoint);
|
|
118
|
+
} else {
|
|
119
|
+
const codePoint = parseInt(hex, 16);
|
|
120
|
+
return String.fromCharCode(codePoint);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
111
126
|
const OCTOTHORPE_PH = "%__lingui_octothorpe__%";
|
|
112
127
|
const getDefaultFormats = (locale, passedLocales, formats = {}) => {
|
|
113
128
|
const locales = passedLocales || locale;
|
|
@@ -184,8 +199,8 @@ function interpolate(translation, locale, locales) {
|
|
|
184
199
|
}, "");
|
|
185
200
|
};
|
|
186
201
|
const result = formatMessage(translation);
|
|
187
|
-
if (isString(result) &&
|
|
188
|
-
return
|
|
202
|
+
if (isString(result) && ESCAPE_SEQUENCE_REGEX.test(result)) {
|
|
203
|
+
return decodeEscapeSequences(result);
|
|
189
204
|
}
|
|
190
205
|
if (isString(result))
|
|
191
206
|
return result;
|
|
@@ -393,8 +408,8 @@ Please compile your catalog first.
|
|
|
393
408
|
`);
|
|
394
409
|
}
|
|
395
410
|
}
|
|
396
|
-
if (isString(translation) &&
|
|
397
|
-
return
|
|
411
|
+
if (isString(translation) && ESCAPE_SEQUENCE_REGEX.test(translation))
|
|
412
|
+
return decodeEscapeSequences(translation);
|
|
398
413
|
if (isString(translation))
|
|
399
414
|
return translation;
|
|
400
415
|
return interpolate(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/core",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "I18n tools for javascript",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
|
-
"url": "https://github.com/lingui/js-lingui.git"
|
|
29
|
+
"url": "git+https://github.com/lingui/js-lingui.git",
|
|
30
|
+
"directory": "packages/core"
|
|
30
31
|
},
|
|
31
32
|
"bugs": {
|
|
32
33
|
"url": "https://github.com/lingui/js-lingui/issues"
|
|
@@ -60,15 +61,14 @@
|
|
|
60
61
|
],
|
|
61
62
|
"dependencies": {
|
|
62
63
|
"@babel/runtime": "^7.20.13",
|
|
63
|
-
"@lingui/message-utils": "5.3.
|
|
64
|
-
"unraw": "^3.0.0"
|
|
64
|
+
"@lingui/message-utils": "5.3.3"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@lingui/jest-mocks": "*",
|
|
68
68
|
"unbuild": "2.0.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@lingui/babel-plugin-lingui-macro": "5.3.
|
|
71
|
+
"@lingui/babel-plugin-lingui-macro": "5.3.3",
|
|
72
72
|
"babel-plugin-macros": "2 || 3"
|
|
73
73
|
},
|
|
74
74
|
"peerDependenciesMeta": {
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"optional": true
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "f8dc4af3d9110f53613bb1b2fb303d6751e7a7b1"
|
|
83
83
|
}
|