webpack-easyi18n 0.3.10 → 0.4.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/package.json +4 -4
- package/src/index.js +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-easyi18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Go from gettext catalog (.po files) to embeded localization in your Webpack bundles",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=4.3.0 <5.0.0 || >=5.10"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
14
|
"example:clean": "rimraf example\\dist example\\locale\\webpack-easyi18n-temp",
|
|
15
15
|
"example:build": "npm run example:clean && webpack -c example\\webpack.config.js",
|
|
16
|
-
"example:
|
|
16
|
+
"example:generatetranslations": "dotnet tool restore && dotnet tool run generatepot --app-settings-paths=\"./example/appsettings.json\""
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"i18next-conv": "^4.0.3"
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"homepage": "https://github.com/SimplyDating/webpack-easyi18n#readme",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"html-webpack-plugin": "^5.3.1",
|
|
37
|
-
"rimraf": "^
|
|
38
|
-
"webpack": "^5.
|
|
37
|
+
"rimraf": "^6.0.1",
|
|
38
|
+
"webpack": "^5.99.9",
|
|
39
39
|
"webpack-cli": "^4.6.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,13 @@ class EasyI18nPlugin {
|
|
|
15
15
|
includeUrls: null,
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
static escapeNuggets = (string) => {
|
|
19
|
+
return string
|
|
20
|
+
.replace(/\\/g, `\\\\`) // escape backslashes
|
|
21
|
+
.replace(/'/g, `\\'`) // escape single quotes
|
|
22
|
+
.replace(/"/g, `\\"`); // escape double quotes
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
constructor(locale, options = {}) {
|
|
19
26
|
this.locale = locale;
|
|
20
27
|
this.options = {
|
|
@@ -36,7 +43,7 @@ class EasyI18nPlugin {
|
|
|
36
43
|
compilation.hooks.processAssets.tapPromise(
|
|
37
44
|
{
|
|
38
45
|
name: 'EasyI18nPlugin',
|
|
39
|
-
|
|
46
|
+
stage: compilation.PROCESS_ASSETS_STAGE_DERIVED,
|
|
40
47
|
},
|
|
41
48
|
async () => {
|
|
42
49
|
const localeKey = this.locale[0];
|
|
@@ -127,7 +134,7 @@ class EasyI18nPlugin {
|
|
|
127
134
|
});
|
|
128
135
|
}
|
|
129
136
|
|
|
130
|
-
return replacement;
|
|
137
|
+
return EasyI18nPlugin.escapeNuggets(replacement);
|
|
131
138
|
});
|
|
132
139
|
|
|
133
140
|
compilation.updateAsset(filename, new SourceMapSource(
|