@geekron/strapi 0.3.3 → 0.3.5

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.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 自动生成的翻译模块文件
3
+ * 由 shell/generate-translations.ts 在构建时生成
4
+ * 请勿手动修改此文件
5
+ * 生成时间: 2026-01-12T09:31:15.370Z
6
+ */
7
+ /**
8
+ * 默认翻译模块对象
9
+ * 键为模块路径,值为翻译内容
10
+ */
11
+ export declare const defaultTranslationModules: Record<string, Record<string, any>>;
12
+ /** 默认翻译基础路径 */
13
+ export declare const defaultBasePath = "./translations";
14
+ //# sourceMappingURL=generated-translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-translations.d.ts","sourceRoot":"","sources":["../../i18n/generated-translations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAywCzE,CAAA;AAED,eAAe;AACf,eAAO,MAAM,eAAe,mBAAmB,CAAA"}
@@ -1,2 +1,55 @@
1
- export { translations } from "./translations";
1
+ /**
2
+ * 翻译加载器配置接口
3
+ */
4
+ interface TranslationsConfig {
5
+ /** 扩展翻译目录配置数组(自定义目录的值会覆盖默认目录的值) */
6
+ extensions?: Array<{
7
+ /** 扩展目录的模块对象(使用 import.meta.glob 导入) */
8
+ modules: Record<string, any>;
9
+ /** 扩展目录的基础路径(用于路径匹配) */
10
+ basePath?: string;
11
+ }>;
12
+ /** 指定要加载的语言列表,如果不指定则自动发现 */
13
+ locales?: string[];
14
+ }
15
+ /**
16
+ * 创建多语言翻译对象
17
+ * @param config - 翻译加载器配置(可选)
18
+ * @returns 以语言为 key 的翻译对象
19
+ *
20
+ * @description
21
+ * 该方法实现了多目录翻译文件的深度合并机制:
22
+ * 1. 自动加载默认目录 (translations/) 下的 JSON 文件
23
+ * 2. 支持扩展自定义目录,可以添加多个自定义来源
24
+ * 3. 合并顺序:默认目录 → 自定义目录 1 → 自定义目录 2 → ...
25
+ * 4. 覆盖机制:后面的目录会 **深度覆盖**前面目录的值
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // 基础用法:只加载默认目录
30
+ * const t = translations();
31
+ *
32
+ * // 高级用法:加载默认目录 + 自定义扩展目录(自定义目录会深度覆盖默认目录)
33
+ * const t = translations({
34
+ * extensions: [
35
+ * {
36
+ * modules: import.meta.glob('../custom/ * \/ ** \/ *.json', { eager: true, import: 'default' }),
37
+ * basePath: '../custom'
38
+ * }
39
+ * ]
40
+ * });
41
+ *
42
+ * // 指定语言列表
43
+ * const t = translations({
44
+ * locales: ['en', 'zh-Hans', 'zh-Hant']
45
+ * });
46
+ *
47
+ * // 深度覆盖示例:
48
+ * // 默认目录的 en.json: { common: { hello: "Hello", world: "World" }, home: { title: "Home" } }
49
+ * // 自定义目录的 en.json: { common: { hello: "Hi" }, about: { title: "About" } }
50
+ * // 最终结果: { common: { hello: "Hi", world: "World" }, home: { title: "Home" }, about: { title: "About" } }
51
+ * ```
52
+ */
53
+ export declare const translations: (config?: TranslationsConfig) => Record<string, Record<string, any>>;
54
+ export {};
2
55
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../i18n/index.ts"],"names":[],"mappings":"AAmJA;;GAEG;AACH,UAAU,kBAAkB;IAC3B,mCAAmC;IACnC,UAAU,CAAC,EAAE,KAAK,CAAC;QAClB,wCAAwC;QACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC7B,wBAAwB;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,4BAA4B;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,kBAAkB,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA8B5F,CAAC"}