@etsoo/appscript 1.6.27 → 1.6.29

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.
@@ -1,5 +1,4 @@
1
1
  import { ArrayUtils } from "@etsoo/shared";
2
- import { CultureGridItem } from "../../src";
3
2
  import { BusinessUtils } from "../../src/business/BusinessUtils";
4
3
 
5
4
  // Import the ArrayUtils
@@ -12,35 +11,3 @@ test("Tests for BusinessUtils.formatAvatarTitle", () => {
12
11
  expect(BusinessUtils.formatAvatarTitle("Etsoo", 3, "E")).toBe("E");
13
12
  expect(BusinessUtils.formatAvatarTitle("Etsoo", 5)).toBe("ETSOO");
14
13
  });
15
-
16
- test("Tests for BusinessUtils.formatCultues", () => {
17
- // Arrange
18
- const cultures = [
19
- {
20
- id: "zh-Hans",
21
- label: "中文(简体), Chinese (Simplified)"
22
- },
23
- {
24
- id: "en",
25
- label: "英语, English"
26
- },
27
- {
28
- id: "de",
29
- label: "德语, German"
30
- },
31
- {
32
- id: "zh-Hant",
33
- label: "中文(繁体), Chinese (Traditional)"
34
- }
35
- ];
36
- const data: { cultures: CultureGridItem[] } = {
37
- cultures: [{ id: "zh-Hant", title: "繁体" }]
38
- };
39
-
40
- // Act
41
- BusinessUtils.formatCultues(cultures, data);
42
-
43
- // Assert
44
- expect(data.cultures[0].id).toBe("en");
45
- expect(data.cultures.slice(-1)[0].id).toBe("zh-Hant");
46
- });
@@ -354,6 +354,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
354
354
  * @param onReady On ready callback
355
355
  */
356
356
  changeCulture(culture: DataTypes.CultureDefinition): Promise<DataTypes.StringRecord>;
357
+ /**
358
+ * Load custom resources, override to implement custom resources
359
+ * @param resources Resources
360
+ * @param culture Culture name
361
+ */
362
+ protected loadCustomResources(resources: DataTypes.StringRecord, culture: string): Promise<void> | void;
357
363
  /**
358
364
  * Update current region label
359
365
  */
@@ -829,9 +829,17 @@ class CoreApp {
829
829
  // Set static resources back
830
830
  culture.resources = resources;
831
831
  }
832
+ // Load system custom resources
833
+ await this.loadCustomResources(resources, name);
832
834
  this.updateRegionLabel();
833
835
  return resources;
834
836
  }
837
+ /**
838
+ * Load custom resources, override to implement custom resources
839
+ * @param resources Resources
840
+ * @param culture Culture name
841
+ */
842
+ loadCustomResources(resources, culture) { }
835
843
  /**
836
844
  * Update current region label
837
845
  */
@@ -1,5 +1,5 @@
1
- import { ListType, ListType1 } from "@etsoo/shared";
2
- import { CultureGridItem } from "./CultureItem";
1
+ import { DataTypes, ListType } from "@etsoo/shared";
2
+ import { CustomCultureData } from "../def/CustomCulture";
3
3
  /**
4
4
  * Business utils
5
5
  */
@@ -12,14 +12,6 @@ export declare namespace BusinessUtils {
12
12
  * @returns Result
13
13
  */
14
14
  function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
15
- /**
16
- * Format cultures for data
17
- * @param cultures Supported cultures
18
- * @param data Data to format
19
- */
20
- function formatCultues(cultures: ListType1[], data: {
21
- cultures?: CultureGridItem[];
22
- }): void;
23
15
  /**
24
16
  * Get 12-month items
25
17
  * @param monthLabels Month labels
@@ -27,4 +19,11 @@ export declare namespace BusinessUtils {
27
19
  * @returns 12 months
28
20
  */
29
21
  function getMonths(monthLabels: string[], startMonth?: number): ListType[];
22
+ /**
23
+ * Merge custom resources to target collection
24
+ * @param target Target collection merges to
25
+ * @param resources New resources to merge
26
+ */
27
+ function mergeCustomResources(target: DataTypes.StringRecord, resources: CustomCultureData[]): void;
28
+ function restoreResources(target?: DataTypes.StringRecord): void;
30
29
  }
@@ -6,6 +6,7 @@ exports.BusinessUtils = void 0;
6
6
  */
7
7
  var BusinessUtils;
8
8
  (function (BusinessUtils) {
9
+ let resourcesCache = {};
9
10
  /**
10
11
  * Format avatar title
11
12
  * @param title Title
@@ -38,27 +39,6 @@ var BusinessUtils;
38
39
  return defaultTitle;
39
40
  }
40
41
  BusinessUtils.formatAvatarTitle = formatAvatarTitle;
41
- /**
42
- * Format cultures for data
43
- * @param cultures Supported cultures
44
- * @param data Data to format
45
- */
46
- function formatCultues(cultures, data) {
47
- // Add the lost cultures
48
- const allCultures = data.cultures ?? [];
49
- cultures.forEach((culture) => {
50
- if (!allCultures.some((a) => a.id === culture.id)) {
51
- allCultures.push({ id: culture.id, title: "" });
52
- }
53
- });
54
- // Remove the default culture
55
- allCultures.remove((a) => a.id === cultures[0].id);
56
- // Sort
57
- allCultures.sortByProperty("id", cultures.map((c) => c.id));
58
- // Set back
59
- data.cultures = allCultures;
60
- }
61
- BusinessUtils.formatCultues = formatCultues;
62
42
  /**
63
43
  * Get 12-month items
64
44
  * @param monthLabels Month labels
@@ -76,4 +56,41 @@ var BusinessUtils;
76
56
  return months;
77
57
  }
78
58
  BusinessUtils.getMonths = getMonths;
59
+ /**
60
+ * Merge custom resources to target collection
61
+ * @param target Target collection merges to
62
+ * @param resources New resources to merge
63
+ */
64
+ function mergeCustomResources(target, resources) {
65
+ for (const item of resources) {
66
+ if (item.organizationId) {
67
+ // Backup
68
+ const backup = target[item.id];
69
+ if (backup != null &&
70
+ (typeof backup !== "object" || !("organizationId" in backup))) {
71
+ resourcesCache[item.id] = backup;
72
+ }
73
+ }
74
+ if (item.description || item.jsonData) {
75
+ const { id, ...rest } = item;
76
+ target[item.id] = rest;
77
+ }
78
+ else {
79
+ target[item.id] = item.title;
80
+ }
81
+ }
82
+ }
83
+ BusinessUtils.mergeCustomResources = mergeCustomResources;
84
+ function restoreResources(target) {
85
+ // Clear cache if no target
86
+ if (target == null) {
87
+ resourcesCache = {};
88
+ return;
89
+ }
90
+ // Restore resources
91
+ for (const key in resourcesCache) {
92
+ target[key] = resourcesCache[key];
93
+ }
94
+ }
95
+ BusinessUtils.restoreResources = restoreResources;
79
96
  })(BusinessUtils || (exports.BusinessUtils = BusinessUtils = {}));
@@ -1,46 +1,42 @@
1
1
  /**
2
- * Culture item for multilingual labels
2
+ * Culture item
3
+ * 文化项目
4
+ * @see com.etsoo.Utils.Serialization.Country.CultureItem
3
5
  */
4
6
  export type CultureItem = {
5
7
  /**
6
- * Target id
8
+ * Id, like zh-Hans-CN
9
+ * 编号,如zh-Hans-CN
7
10
  */
8
- id: number;
9
- /**
10
- * Culture, like zh-Hans
11
- */
12
- culture: string;
11
+ id: string;
13
12
  /**
14
- * Title / label
13
+ * Two characters id, like zh
14
+ * 两个字符编号
15
15
  */
16
- title: string;
16
+ id2: string;
17
17
  /**
18
- * Description
18
+ * Three characters id, like zho
19
+ * 三个字符编号
19
20
  */
20
- description?: string;
21
+ id3: string;
21
22
  /**
22
- * JSON data related
23
+ * Parent culture, like zh-Hans
24
+ * 父文化
23
25
  */
24
- jsonData?: string;
25
- };
26
- /**
27
- * Culture grid item for editing
28
- */
29
- export type CultureGridItem = {
30
- /**
31
- * Culture
32
- */
33
- id: string;
26
+ parent: string;
34
27
  /**
35
- * Title / label
28
+ * Name
29
+ * 名称
36
30
  */
37
- title: string;
31
+ name: string;
38
32
  /**
39
- * Description
33
+ * Native name, like 中文(简体,中国)
34
+ * 原生名
40
35
  */
41
- description?: string;
36
+ nativeName: string;
42
37
  /**
43
- * JSON data related
38
+ * English name, like Chinese (Simplified, China)
39
+ * 英文名
44
40
  */
45
- jsonData?: string;
41
+ englishName: string;
46
42
  };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Custom culture data
3
+ */
4
+ export type CustomCultureData = {
5
+ /**
6
+ * Target id
7
+ */
8
+ id: string;
9
+ /**
10
+ * Organization id
11
+ */
12
+ organizationId?: number;
13
+ /**
14
+ * Title / label
15
+ */
16
+ title: string;
17
+ /**
18
+ * Description
19
+ */
20
+ description?: string;
21
+ /**
22
+ * JSON data related
23
+ * Use Utils.parseString of @etsoo/shared to parse the string to JSON object
24
+ */
25
+ jsonData?: string;
26
+ };
27
+ /**
28
+ * Custom culture
29
+ */
30
+ export type CustomCulture = CustomCultureData & {
31
+ /**
32
+ * Culture, like zh-Hans
33
+ */
34
+ culture: string;
35
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -59,6 +59,7 @@ export * from "./business/RepeatOption";
59
59
  export * from "./business/ShoppingCart";
60
60
  export * from "./custom/CustomField";
61
61
  export * from "./custom/CustomFieldData";
62
+ export * from "./def/CustomCulture";
62
63
  export * from "./def/ListItem";
63
64
  export * from "./i18n/Culture";
64
65
  export { ApiAuthorizationScheme, ApiDataError, ApiMethod, ApiResponseType, createClient, createClientAsync } from "@etsoo/restclient";
package/lib/cjs/index.js CHANGED
@@ -83,6 +83,7 @@ __exportStar(require("./business/ShoppingCart"), exports);
83
83
  __exportStar(require("./custom/CustomField"), exports);
84
84
  __exportStar(require("./custom/CustomFieldData"), exports);
85
85
  // def
86
+ __exportStar(require("./def/CustomCulture"), exports);
86
87
  __exportStar(require("./def/ListItem"), exports);
87
88
  // i18n
88
89
  __exportStar(require("./i18n/Culture"), exports);
@@ -354,6 +354,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
354
354
  * @param onReady On ready callback
355
355
  */
356
356
  changeCulture(culture: DataTypes.CultureDefinition): Promise<DataTypes.StringRecord>;
357
+ /**
358
+ * Load custom resources, override to implement custom resources
359
+ * @param resources Resources
360
+ * @param culture Culture name
361
+ */
362
+ protected loadCustomResources(resources: DataTypes.StringRecord, culture: string): Promise<void> | void;
357
363
  /**
358
364
  * Update current region label
359
365
  */
@@ -826,9 +826,17 @@ export class CoreApp {
826
826
  // Set static resources back
827
827
  culture.resources = resources;
828
828
  }
829
+ // Load system custom resources
830
+ await this.loadCustomResources(resources, name);
829
831
  this.updateRegionLabel();
830
832
  return resources;
831
833
  }
834
+ /**
835
+ * Load custom resources, override to implement custom resources
836
+ * @param resources Resources
837
+ * @param culture Culture name
838
+ */
839
+ loadCustomResources(resources, culture) { }
832
840
  /**
833
841
  * Update current region label
834
842
  */
@@ -1,5 +1,5 @@
1
- import { ListType, ListType1 } from "@etsoo/shared";
2
- import { CultureGridItem } from "./CultureItem";
1
+ import { DataTypes, ListType } from "@etsoo/shared";
2
+ import { CustomCultureData } from "../def/CustomCulture";
3
3
  /**
4
4
  * Business utils
5
5
  */
@@ -12,14 +12,6 @@ export declare namespace BusinessUtils {
12
12
  * @returns Result
13
13
  */
14
14
  function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
15
- /**
16
- * Format cultures for data
17
- * @param cultures Supported cultures
18
- * @param data Data to format
19
- */
20
- function formatCultues(cultures: ListType1[], data: {
21
- cultures?: CultureGridItem[];
22
- }): void;
23
15
  /**
24
16
  * Get 12-month items
25
17
  * @param monthLabels Month labels
@@ -27,4 +19,11 @@ export declare namespace BusinessUtils {
27
19
  * @returns 12 months
28
20
  */
29
21
  function getMonths(monthLabels: string[], startMonth?: number): ListType[];
22
+ /**
23
+ * Merge custom resources to target collection
24
+ * @param target Target collection merges to
25
+ * @param resources New resources to merge
26
+ */
27
+ function mergeCustomResources(target: DataTypes.StringRecord, resources: CustomCultureData[]): void;
28
+ function restoreResources(target?: DataTypes.StringRecord): void;
30
29
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export var BusinessUtils;
5
5
  (function (BusinessUtils) {
6
+ let resourcesCache = {};
6
7
  /**
7
8
  * Format avatar title
8
9
  * @param title Title
@@ -35,27 +36,6 @@ export var BusinessUtils;
35
36
  return defaultTitle;
36
37
  }
37
38
  BusinessUtils.formatAvatarTitle = formatAvatarTitle;
38
- /**
39
- * Format cultures for data
40
- * @param cultures Supported cultures
41
- * @param data Data to format
42
- */
43
- function formatCultues(cultures, data) {
44
- // Add the lost cultures
45
- const allCultures = data.cultures ?? [];
46
- cultures.forEach((culture) => {
47
- if (!allCultures.some((a) => a.id === culture.id)) {
48
- allCultures.push({ id: culture.id, title: "" });
49
- }
50
- });
51
- // Remove the default culture
52
- allCultures.remove((a) => a.id === cultures[0].id);
53
- // Sort
54
- allCultures.sortByProperty("id", cultures.map((c) => c.id));
55
- // Set back
56
- data.cultures = allCultures;
57
- }
58
- BusinessUtils.formatCultues = formatCultues;
59
39
  /**
60
40
  * Get 12-month items
61
41
  * @param monthLabels Month labels
@@ -73,4 +53,41 @@ export var BusinessUtils;
73
53
  return months;
74
54
  }
75
55
  BusinessUtils.getMonths = getMonths;
56
+ /**
57
+ * Merge custom resources to target collection
58
+ * @param target Target collection merges to
59
+ * @param resources New resources to merge
60
+ */
61
+ function mergeCustomResources(target, resources) {
62
+ for (const item of resources) {
63
+ if (item.organizationId) {
64
+ // Backup
65
+ const backup = target[item.id];
66
+ if (backup != null &&
67
+ (typeof backup !== "object" || !("organizationId" in backup))) {
68
+ resourcesCache[item.id] = backup;
69
+ }
70
+ }
71
+ if (item.description || item.jsonData) {
72
+ const { id, ...rest } = item;
73
+ target[item.id] = rest;
74
+ }
75
+ else {
76
+ target[item.id] = item.title;
77
+ }
78
+ }
79
+ }
80
+ BusinessUtils.mergeCustomResources = mergeCustomResources;
81
+ function restoreResources(target) {
82
+ // Clear cache if no target
83
+ if (target == null) {
84
+ resourcesCache = {};
85
+ return;
86
+ }
87
+ // Restore resources
88
+ for (const key in resourcesCache) {
89
+ target[key] = resourcesCache[key];
90
+ }
91
+ }
92
+ BusinessUtils.restoreResources = restoreResources;
76
93
  })(BusinessUtils || (BusinessUtils = {}));
@@ -1,46 +1,42 @@
1
1
  /**
2
- * Culture item for multilingual labels
2
+ * Culture item
3
+ * 文化项目
4
+ * @see com.etsoo.Utils.Serialization.Country.CultureItem
3
5
  */
4
6
  export type CultureItem = {
5
7
  /**
6
- * Target id
8
+ * Id, like zh-Hans-CN
9
+ * 编号,如zh-Hans-CN
7
10
  */
8
- id: number;
9
- /**
10
- * Culture, like zh-Hans
11
- */
12
- culture: string;
11
+ id: string;
13
12
  /**
14
- * Title / label
13
+ * Two characters id, like zh
14
+ * 两个字符编号
15
15
  */
16
- title: string;
16
+ id2: string;
17
17
  /**
18
- * Description
18
+ * Three characters id, like zho
19
+ * 三个字符编号
19
20
  */
20
- description?: string;
21
+ id3: string;
21
22
  /**
22
- * JSON data related
23
+ * Parent culture, like zh-Hans
24
+ * 父文化
23
25
  */
24
- jsonData?: string;
25
- };
26
- /**
27
- * Culture grid item for editing
28
- */
29
- export type CultureGridItem = {
30
- /**
31
- * Culture
32
- */
33
- id: string;
26
+ parent: string;
34
27
  /**
35
- * Title / label
28
+ * Name
29
+ * 名称
36
30
  */
37
- title: string;
31
+ name: string;
38
32
  /**
39
- * Description
33
+ * Native name, like 中文(简体,中国)
34
+ * 原生名
40
35
  */
41
- description?: string;
36
+ nativeName: string;
42
37
  /**
43
- * JSON data related
38
+ * English name, like Chinese (Simplified, China)
39
+ * 英文名
44
40
  */
45
- jsonData?: string;
41
+ englishName: string;
46
42
  };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Custom culture data
3
+ */
4
+ export type CustomCultureData = {
5
+ /**
6
+ * Target id
7
+ */
8
+ id: string;
9
+ /**
10
+ * Organization id
11
+ */
12
+ organizationId?: number;
13
+ /**
14
+ * Title / label
15
+ */
16
+ title: string;
17
+ /**
18
+ * Description
19
+ */
20
+ description?: string;
21
+ /**
22
+ * JSON data related
23
+ * Use Utils.parseString of @etsoo/shared to parse the string to JSON object
24
+ */
25
+ jsonData?: string;
26
+ };
27
+ /**
28
+ * Custom culture
29
+ */
30
+ export type CustomCulture = CustomCultureData & {
31
+ /**
32
+ * Culture, like zh-Hans
33
+ */
34
+ culture: string;
35
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -59,6 +59,7 @@ export * from "./business/RepeatOption";
59
59
  export * from "./business/ShoppingCart";
60
60
  export * from "./custom/CustomField";
61
61
  export * from "./custom/CustomFieldData";
62
+ export * from "./def/CustomCulture";
62
63
  export * from "./def/ListItem";
63
64
  export * from "./i18n/Culture";
64
65
  export { ApiAuthorizationScheme, ApiDataError, ApiMethod, ApiResponseType, createClient, createClientAsync } from "@etsoo/restclient";
package/lib/mjs/index.js CHANGED
@@ -66,6 +66,7 @@ export * from "./business/ShoppingCart";
66
66
  export * from "./custom/CustomField";
67
67
  export * from "./custom/CustomFieldData";
68
68
  // def
69
+ export * from "./def/CustomCulture";
69
70
  export * from "./def/ListItem";
70
71
  // i18n
71
72
  export * from "./i18n/Culture";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.6.27",
3
+ "version": "1.6.29",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -1229,11 +1229,25 @@ export abstract class CoreApp<
1229
1229
  // Set static resources back
1230
1230
  culture.resources = resources;
1231
1231
  }
1232
+
1233
+ // Load system custom resources
1234
+ await this.loadCustomResources(resources, name);
1235
+
1232
1236
  this.updateRegionLabel();
1233
1237
 
1234
1238
  return resources;
1235
1239
  }
1236
1240
 
1241
+ /**
1242
+ * Load custom resources, override to implement custom resources
1243
+ * @param resources Resources
1244
+ * @param culture Culture name
1245
+ */
1246
+ protected loadCustomResources(
1247
+ resources: DataTypes.StringRecord,
1248
+ culture: string
1249
+ ): Promise<void> | void {}
1250
+
1237
1251
  /**
1238
1252
  * Update current region label
1239
1253
  */
@@ -1,10 +1,12 @@
1
- import { ListType, ListType1 } from "@etsoo/shared";
2
- import { CultureGridItem } from "./CultureItem";
1
+ import { DataTypes, ListType } from "@etsoo/shared";
2
+ import { CustomCultureData } from "../def/CustomCulture";
3
3
 
4
4
  /**
5
5
  * Business utils
6
6
  */
7
7
  export namespace BusinessUtils {
8
+ let resourcesCache: DataTypes.StringRecord = {};
9
+
8
10
  /**
9
11
  * Format avatar title
10
12
  * @param title Title
@@ -44,35 +46,6 @@ export namespace BusinessUtils {
44
46
  return defaultTitle;
45
47
  }
46
48
 
47
- /**
48
- * Format cultures for data
49
- * @param cultures Supported cultures
50
- * @param data Data to format
51
- */
52
- export function formatCultues(
53
- cultures: ListType1[],
54
- data: { cultures?: CultureGridItem[] }
55
- ) {
56
- // Add the lost cultures
57
- const allCultures = data.cultures ?? [];
58
- cultures.forEach((culture) => {
59
- if (!allCultures.some((a) => a.id === culture.id)) {
60
- allCultures.push({ id: culture.id, title: "" });
61
- }
62
- });
63
-
64
- // Remove the default culture
65
- allCultures.remove((a) => a.id === cultures[0].id);
66
- // Sort
67
- allCultures.sortByProperty(
68
- "id",
69
- cultures.map((c) => c.id)
70
- );
71
-
72
- // Set back
73
- data.cultures = allCultures;
74
- }
75
-
76
49
  /**
77
50
  * Get 12-month items
78
51
  * @param monthLabels Month labels
@@ -92,4 +65,47 @@ export namespace BusinessUtils {
92
65
 
93
66
  return months;
94
67
  }
68
+
69
+ /**
70
+ * Merge custom resources to target collection
71
+ * @param target Target collection merges to
72
+ * @param resources New resources to merge
73
+ */
74
+ export function mergeCustomResources(
75
+ target: DataTypes.StringRecord,
76
+ resources: CustomCultureData[]
77
+ ) {
78
+ for (const item of resources) {
79
+ if (item.organizationId) {
80
+ // Backup
81
+ const backup = target[item.id];
82
+ if (
83
+ backup != null &&
84
+ (typeof backup !== "object" || !("organizationId" in backup))
85
+ ) {
86
+ resourcesCache[item.id] = backup;
87
+ }
88
+ }
89
+
90
+ if (item.description || item.jsonData) {
91
+ const { id, ...rest } = item;
92
+ target[item.id] = rest;
93
+ } else {
94
+ target[item.id] = item.title;
95
+ }
96
+ }
97
+ }
98
+
99
+ export function restoreResources(target?: DataTypes.StringRecord) {
100
+ // Clear cache if no target
101
+ if (target == null) {
102
+ resourcesCache = {};
103
+ return;
104
+ }
105
+
106
+ // Restore resources
107
+ for (const key in resourcesCache) {
108
+ target[key] = resourcesCache[key];
109
+ }
110
+ }
95
111
  }
@@ -1,54 +1,48 @@
1
1
  /**
2
- * Culture item for multilingual labels
2
+ * Culture item
3
+ * 文化项目
4
+ * @see com.etsoo.Utils.Serialization.Country.CultureItem
3
5
  */
4
6
  export type CultureItem = {
5
7
  /**
6
- * Target id
8
+ * Id, like zh-Hans-CN
9
+ * 编号,如zh-Hans-CN
7
10
  */
8
- id: number;
9
-
10
- /**
11
- * Culture, like zh-Hans
12
- */
13
- culture: string;
14
-
15
- /**
16
- * Title / label
17
- */
18
- title: string;
11
+ id: string;
19
12
 
20
13
  /**
21
- * Description
14
+ * Two characters id, like zh
15
+ * 两个字符编号
22
16
  */
23
- description?: string;
17
+ id2: string;
24
18
 
25
19
  /**
26
- * JSON data related
20
+ * Three characters id, like zho
21
+ * 三个字符编号
27
22
  */
28
- jsonData?: string;
29
- };
23
+ id3: string;
30
24
 
31
- /**
32
- * Culture grid item for editing
33
- */
34
- export type CultureGridItem = {
35
25
  /**
36
- * Culture
26
+ * Parent culture, like zh-Hans
27
+ * 父文化
37
28
  */
38
- id: string;
29
+ parent: string;
39
30
 
40
31
  /**
41
- * Title / label
32
+ * Name
33
+ * 名称
42
34
  */
43
- title: string;
35
+ name: string;
44
36
 
45
37
  /**
46
- * Description
38
+ * Native name, like 中文(简体,中国)
39
+ * 原生名
47
40
  */
48
- description?: string;
41
+ nativeName: string;
49
42
 
50
43
  /**
51
- * JSON data related
44
+ * English name, like Chinese (Simplified, China)
45
+ * 英文名
52
46
  */
53
- jsonData?: string;
47
+ englishName: string;
54
48
  };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Custom culture data
3
+ */
4
+ export type CustomCultureData = {
5
+ /**
6
+ * Target id
7
+ */
8
+ id: string;
9
+
10
+ /**
11
+ * Organization id
12
+ */
13
+ organizationId?: number;
14
+
15
+ /**
16
+ * Title / label
17
+ */
18
+ title: string;
19
+
20
+ /**
21
+ * Description
22
+ */
23
+ description?: string;
24
+
25
+ /**
26
+ * JSON data related
27
+ * Use Utils.parseString of @etsoo/shared to parse the string to JSON object
28
+ */
29
+ jsonData?: string;
30
+ };
31
+
32
+ /**
33
+ * Custom culture
34
+ */
35
+ export type CustomCulture = CustomCultureData & {
36
+ /**
37
+ * Culture, like zh-Hans
38
+ */
39
+ culture: string;
40
+ };
package/src/index.ts CHANGED
@@ -74,6 +74,7 @@ export * from "./custom/CustomField";
74
74
  export * from "./custom/CustomFieldData";
75
75
 
76
76
  // def
77
+ export * from "./def/CustomCulture";
77
78
  export * from "./def/ListItem";
78
79
 
79
80
  // i18n