@npm-questionpro/wick-ui-i18n 0.1.0 → 0.5.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/README.md CHANGED
@@ -1,5 +1,3 @@
1
- Here is the stripped-down, one-liner style README with the logic map included.
2
-
3
1
  # Wick UI Auto I18n
4
2
 
5
3
  **Build-time extractor that wraps static strings in `<WuTranslate>` and generates a JSON dictionary.**
@@ -9,7 +7,7 @@ Here is the stripped-down, one-liner style README with the logic map included.
9
7
  ### Quick Start
10
8
 
11
9
  ```javascript
12
- import wickuiI18nPlugin from "./plugins/wickui-i18n";
10
+ import wickuiI18nPlugin from "@npm-questionpro/wick-ui-i18n";
13
11
  export default {
14
12
  plugins: [wickuiI18nPlugin({ debug: true })],
15
13
  };
@@ -34,16 +32,6 @@ export default {
34
32
 
35
33
  ---
36
34
 
37
- ### ⚙️ Config Options
38
-
39
- | Option | Type | Default | Description |
40
- | ------------------ | ---------- | --------------- | -------------------------------------------- | ----------------- |
41
- | `components` | `string[]` | `[]` | Component names to scan (empty = all `Wu*`). |
42
- | `ignoreComponents` | `string[]` | `["WuIcon"...]` | Component names to explicitly skip. |
43
- | `include` | `RegExp[]` | `[/\.(jsx | tsx)$/]` | Files to process. |
44
-
45
- ---
46
-
47
35
  ### 🔄 Logic Map (Pseudo-code)
48
36
 
49
37
  ```text
package/index.js CHANGED
@@ -113,7 +113,7 @@ export default function wickuiI18nPlugin(options = {}) {
113
113
  ms.overwrite(
114
114
  start,
115
115
  end,
116
- `<WuTranslate __i18nKey=${JSON.stringify(key)}>${original}</WuTranslate>`,
116
+ `<WuTranslate __i18nKey=${JSON.stringify(key)}></WuTranslate>`,
117
117
  );
118
118
  needsImport = true;
119
119
  };
@@ -160,7 +160,7 @@ export default function wickuiI18nPlugin(options = {}) {
160
160
  generateBundle() {
161
161
  this.emitFile({
162
162
  type: "asset",
163
- fileName: "wick_extracted_strings.json",
163
+ fileName: "wick-ui-i18n.json",
164
164
  source: JSON.stringify(
165
165
  Object.fromEntries(processor.dictionary),
166
166
  null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npm-questionpro/wick-ui-i18n",
3
- "version": "0.1.0",
3
+ "version": "0.5.0",
4
4
  "license": "ISC",
5
5
  "description": "Auto-translation AST wrapper for Wick UI",
6
6
  "type": "module",
@@ -12,20 +12,20 @@
12
12
  "default": "./index.js"
13
13
  }
14
14
  },
15
- "scripts": {
16
- "test": "vitest run"
17
- },
18
15
  "peerDependencies": {
19
- "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
16
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
20
17
  },
21
18
  "devDependencies": {
22
19
  "@types/babel__traverse": "^7.28.0",
23
20
  "vite": "^7.3.1",
24
- "vitest": "^4.0.18"
21
+ "vitest": "^3.2.4"
25
22
  },
26
23
  "dependencies": {
27
24
  "@babel/parser": "^7.29.0",
28
25
  "@babel/traverse": "^7.29.0",
29
26
  "magic-string": "^0.30.21"
27
+ },
28
+ "scripts": {
29
+ "test": "vitest run"
30
30
  }
31
- }
31
+ }
@@ -13,9 +13,7 @@ describe("Wick UI i18n Vite Plugin", () => {
13
13
  const code = `<WuButton>Submit</WuButton>`;
14
14
  const result = transform(code);
15
15
  expect(result).toContain(`import { WuTranslate }`);
16
- expect(result).toContain(
17
- `<WuTranslate __i18nKey="Submit">Submit</WuTranslate>`,
18
- );
16
+ expect(result).toContain(`<WuTranslate __i18nKey="Submit"></WuTranslate>`);
19
17
  });
20
18
 
21
19
  it("2. Ignores components in the ignoreComponents list", () => {
@@ -27,18 +25,14 @@ describe("Wick UI i18n Vite Plugin", () => {
27
25
  it("3. Handles smart nested ignored components (Ignored inside Target)", () => {
28
26
  const code = `<WuButton>Click <WuIcon>star</WuIcon></WuButton>`;
29
27
  const result = transform(code);
30
- expect(result).toContain(
31
- `<WuTranslate __i18nKey="Click">Click</WuTranslate>`,
32
- );
28
+ expect(result).toContain(`<WuTranslate __i18nKey="Click"></WuTranslate>`);
33
29
  expect(result).toContain(`<WuIcon>star</WuIcon>`);
34
30
  });
35
31
 
36
32
  it("4. Handles smart nested target components (Target inside regular HTML)", () => {
37
33
  const code = `<WuProvider><div><WuButton>Save</WuButton></div></WuProvider>`;
38
34
  const result = transform(code);
39
- expect(result).toContain(
40
- `<WuTranslate __i18nKey="Save">Save</WuTranslate>`,
41
- );
35
+ expect(result).toContain(`<WuTranslate __i18nKey="Save"></WuTranslate>`);
42
36
  });
43
37
 
44
38
  it("5. Respects data-skip and data-i18n-skip flags", () => {
@@ -52,7 +46,7 @@ describe("Wick UI i18n Vite Plugin", () => {
52
46
  const code = `<WuButton data-i18n-key="btn_login">Log In</WuButton>`;
53
47
  const result = transform(code);
54
48
  expect(result).toContain(
55
- `<WuTranslate __i18nKey="btn_login">Log In</WuTranslate>`,
49
+ `<WuTranslate __i18nKey="btn_login"></WuTranslate>`,
56
50
  );
57
51
  });
58
52
 
@@ -60,7 +54,7 @@ describe("Wick UI i18n Vite Plugin", () => {
60
54
  const code = `<WuButton>{"Hello World"}</WuButton>`;
61
55
  const result = transform(code);
62
56
  expect(result).toContain(
63
- `<WuTranslate __i18nKey="Hello World">{"Hello World"}</WuTranslate>`,
57
+ `<WuTranslate __i18nKey="Hello World"></WuTranslate>`,
64
58
  );
65
59
  });
66
60
 
@@ -77,7 +71,7 @@ describe("Wick UI i18n Vite Plugin", () => {
77
71
  const triggerCode = `import { WuPlaceholder } from 'lib';\n` + code;
78
72
  const result = transform(triggerCode);
79
73
  expect(result).toContain(
80
- `<WuTranslate __i18nKey="Wrapped Text">Wrapped Text</WuTranslate>`,
74
+ `<WuTranslate __i18nKey="Wrapped Text"></WuTranslate>`,
81
75
  );
82
76
  });
83
77
  });