@geekron/strapi 0.2.11 → 0.2.12

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.
@@ -40,8 +40,8 @@ var addPrefix = (translations, prefix) => {
40
40
  return acc;
41
41
  }, {});
42
42
  };
43
- var isNestedFile = (modulePath, baseDepth = 3) => {
44
- return modulePath.split("/").length > baseDepth;
43
+ var isInPrefixDir = (modulePath) => {
44
+ return modulePath.includes("/prefix/") || modulePath.includes("\\prefix\\");
45
45
  };
46
46
  var extractFileName = (modulePath) => {
47
47
  const match = modulePath.match(/\/([^/]+)\.json$/);
@@ -58,7 +58,7 @@ var processLocaleModules = (modules, locale, basePath = ".") => {
58
58
  return acc;
59
59
  }
60
60
  const translation = modules[modulePath];
61
- if (isNestedFile(modulePath)) {
61
+ if (isInPrefixDir(modulePath)) {
62
62
  return {
63
63
  ...acc,
64
64
  ...addPrefix(translation, fileName)
@@ -5,8 +5,8 @@ var addPrefix = (translations, prefix) => {
5
5
  return acc;
6
6
  }, {});
7
7
  };
8
- var isNestedFile = (modulePath, baseDepth = 3) => {
9
- return modulePath.split("/").length > baseDepth;
8
+ var isInPrefixDir = (modulePath) => {
9
+ return modulePath.includes("/prefix/") || modulePath.includes("\\prefix\\");
10
10
  };
11
11
  var extractFileName = (modulePath) => {
12
12
  const match = modulePath.match(/\/([^/]+)\.json$/);
@@ -23,7 +23,7 @@ var processLocaleModules = (modules, locale, basePath = ".") => {
23
23
  return acc;
24
24
  }
25
25
  const translation = modules[modulePath];
26
- if (isNestedFile(modulePath)) {
26
+ if (isInPrefixDir(modulePath)) {
27
27
  return {
28
28
  ...acc,
29
29
  ...addPrefix(translation, fileName)
@@ -12,13 +12,13 @@ const addPrefix = (translations: Record<string, any>, prefix: string): Record<st
12
12
  };
13
13
 
14
14
  /**
15
- * 判断文件是否在子目录中
15
+ * 判断文件是否在 prefix 目录中(需要添加前缀)
16
16
  * @param modulePath - 模块路径
17
- * @param baseDepth - 基础路径深度(默认为 3,即 ./locale/*.json)
18
- * @returns 是否为子目录文件
17
+ * @returns 是否在 prefix 目录中
19
18
  */
20
- const isNestedFile = (modulePath: string, baseDepth = 3): boolean => {
21
- return modulePath.split('/').length > baseDepth;
19
+ const isInPrefixDir = (modulePath: string): boolean => {
20
+ // 检查路径中是否包含 /prefix/ 子串
21
+ return modulePath.includes('/prefix/') || modulePath.includes('\\prefix\\');
22
22
  };
23
23
 
24
24
  /**
@@ -58,8 +58,8 @@ const processLocaleModules = (
58
58
 
59
59
  const translation = modules[modulePath] as Record<string, any>;
60
60
 
61
- // 判断是否为子目录文件,子目录文件添加文件名作为前缀
62
- if (isNestedFile(modulePath)) {
61
+ // 判断是否在 prefix 目录中,prefix 目录中的文件添加文件名作为前缀
62
+ if (isInPrefixDir(modulePath)) {
63
63
  return {
64
64
  ...acc,
65
65
  ...addPrefix(translation, fileName)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekron/strapi",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "极客领航网站管理插件",
5
5
  "type": "commonjs",
6
6
  "author": "Geekron",