@agentscope-ai/i18n 0.1.2 → 0.1.3-rc.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/lib/cli.js +27 -3
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -7,10 +7,34 @@ const fs = require('fs-extra');
7
7
 
8
8
  // 读取配置文件
9
9
  const getConfig = (options) => {
10
- const configPath = options.config || path.resolve(process.cwd(), 'i18n.config.js');
11
- if (!fs.existsSync(configPath)) {
12
- throw new Error(`配置文件 ${configPath} 不存在`);
10
+ let configPath = options.config;
11
+
12
+ // 如果没有指定配置文件路径,按优先级查找
13
+ if (!configPath) {
14
+ const configFiles = [
15
+ 'i18n.config.js',
16
+ 'i18n.config.cjs',
17
+ 'i18n.config.mjs',
18
+ ];
19
+
20
+ for (const file of configFiles) {
21
+ const fullPath = path.resolve(process.cwd(), file);
22
+ if (fs.existsSync(fullPath)) {
23
+ configPath = fullPath;
24
+ break;
25
+ }
26
+ }
27
+
28
+ if (!configPath) {
29
+ throw new Error(`配置文件不存在,请在项目根目录创建 i18n.config.js 或 i18n.config.cjs`);
30
+ }
31
+ } else {
32
+ // 如果指定了配置文件路径,检查是否存在
33
+ if (!fs.existsSync(configPath)) {
34
+ throw new Error(`配置文件 ${configPath} 不存在`);
35
+ }
13
36
  }
37
+
14
38
  const config = require(configPath);
15
39
  return config;
16
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentscope-ai/i18n",
3
- "version": "0.1.2",
3
+ "version": "0.1.3-rc.0",
4
4
  "description": "A tool for translating Chinese content in frontend code repositories",
5
5
  "keywords": [
6
6
  "i18n",