webpack-easyi18n 0.3.9 → 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.
Files changed (2) hide show
  1. package/package.json +7 -7
  2. 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.9",
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,14 +13,14 @@
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:generatetransaltions": "dotnet tool restore && dotnet tool run generatepot --app-settings-paths=\"./example/appsettings.json\""
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"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "git+https://github.com/ajbeaven/webpack-easyi18n.git"
23
+ "url": "git+https://github.com/SimplyDating/webpack-easyi18n.git"
24
24
  },
25
25
  "keywords": [
26
26
  "webpack",
@@ -29,13 +29,13 @@
29
29
  "author": "Andrew Beaven",
30
30
  "license": "MIT",
31
31
  "bugs": {
32
- "url": "https://github.com/ajbeaven/webpack-easyi18n/issues"
32
+ "url": "https://github.com/SimplyDating/webpack-easyi18n/issues"
33
33
  },
34
- "homepage": "https://github.com/ajbeaven/webpack-easyi18n#readme",
34
+ "homepage": "https://github.com/SimplyDating/webpack-easyi18n#readme",
35
35
  "devDependencies": {
36
36
  "html-webpack-plugin": "^5.3.1",
37
- "rimraf": "^3.0.2",
38
- "webpack": "^5.32.0",
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
- state: compilation.PROCESS_ASSETS_STAGE_DERIVED,
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(