@capillarytech/cap-ui-utils 1.4.14 → 1.4.16
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/package.json +1 -1
- package/utils/translationUtils.js +117 -0
package/package.json
CHANGED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export const entityMap = {
|
|
2
|
+
reportName: "report_name",
|
|
3
|
+
chartName: "chart_name",
|
|
4
|
+
kpiCustomerName: "kpi_customer_name",
|
|
5
|
+
kpiName: "kpi_name",
|
|
6
|
+
kpiCategoryName: "kpi_category_name",
|
|
7
|
+
categoryName: "category_name",
|
|
8
|
+
kpiDescription: "kpi_description",
|
|
9
|
+
factTable: "fact_table",
|
|
10
|
+
dimensionName: "dimension_name",
|
|
11
|
+
standardFilterName: "standardfilter_name",
|
|
12
|
+
kpiVariableName: "kpi_variable_name",
|
|
13
|
+
kpiVariableDescription: "kpi_variable_description",
|
|
14
|
+
templateName: "template_name",
|
|
15
|
+
templateDescription: "template_description",
|
|
16
|
+
measureName: "measure_name",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function getEntityNameAsKey(type, name) {
|
|
20
|
+
const replaceChars = {
|
|
21
|
+
"%": "pc",
|
|
22
|
+
"-": "hyphen",
|
|
23
|
+
"(": "",
|
|
24
|
+
")": "",
|
|
25
|
+
"/": "",
|
|
26
|
+
".": "_",
|
|
27
|
+
};
|
|
28
|
+
const normalizedName =
|
|
29
|
+
name &&
|
|
30
|
+
name
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/\s/g, "_")
|
|
33
|
+
.toLowerCase()
|
|
34
|
+
.replace(/%|-|\(|\)|\//g, (match) => replaceChars[match]);
|
|
35
|
+
switch (type) {
|
|
36
|
+
case "kpi_name":
|
|
37
|
+
return {
|
|
38
|
+
id: `app.globals.kpis.name.kpi_${normalizedName}_name`,
|
|
39
|
+
defaultMessage: name,
|
|
40
|
+
};
|
|
41
|
+
case "category_name":
|
|
42
|
+
return {
|
|
43
|
+
id: `app.globals.category.name.category_${normalizedName}_name`,
|
|
44
|
+
defaultMessage: name,
|
|
45
|
+
};
|
|
46
|
+
case "report_name":
|
|
47
|
+
return {
|
|
48
|
+
id: `app.globals.report.name.report_${normalizedName}_name`,
|
|
49
|
+
defaultMessage: name,
|
|
50
|
+
};
|
|
51
|
+
case "chart_name":
|
|
52
|
+
return {
|
|
53
|
+
id: `app.globals.chart.name.chart_${normalizedName}_name`,
|
|
54
|
+
defaultMessage: name,
|
|
55
|
+
};
|
|
56
|
+
case "kpi_description":
|
|
57
|
+
return {
|
|
58
|
+
id: `app.globals.kpis.description.kpi_${normalizedName}_description`,
|
|
59
|
+
defaultMessage: name,
|
|
60
|
+
};
|
|
61
|
+
case "fact_table":
|
|
62
|
+
return {
|
|
63
|
+
id: `app.globals.dimensions.facttable.dim_${normalizedName}_facttable`,
|
|
64
|
+
defaultMessage: name,
|
|
65
|
+
};
|
|
66
|
+
case "dimension_name":
|
|
67
|
+
return {
|
|
68
|
+
id: `app.globals.dimensions.name.dim_${normalizedName}_name`,
|
|
69
|
+
defaultMessage: name,
|
|
70
|
+
};
|
|
71
|
+
case "standardfilter_name":
|
|
72
|
+
return {
|
|
73
|
+
id: `app.globals.stdfilter_${normalizedName}_name`,
|
|
74
|
+
defaultMessage: name,
|
|
75
|
+
};
|
|
76
|
+
case "kpi_variable_name":
|
|
77
|
+
return {
|
|
78
|
+
id: `app.globals.kpis.variable.kpi_var_${normalizedName}_name`,
|
|
79
|
+
defaultMessage: name,
|
|
80
|
+
};
|
|
81
|
+
case "kpi_variable_description":
|
|
82
|
+
return {
|
|
83
|
+
id: `app.globals.kpis.variable.kpi_var_${normalizedName}_description`,
|
|
84
|
+
defaultMessage: name,
|
|
85
|
+
};
|
|
86
|
+
case "template_name":
|
|
87
|
+
return {
|
|
88
|
+
id: `app.globals.template.name.template_${normalizedName}_name`,
|
|
89
|
+
defaultMessage: name,
|
|
90
|
+
};
|
|
91
|
+
case "template_description":
|
|
92
|
+
return {
|
|
93
|
+
id: `app.globals.template.description.template_${normalizedName}_name`,
|
|
94
|
+
defaultMessage: name,
|
|
95
|
+
};
|
|
96
|
+
case "measure_name":
|
|
97
|
+
return {
|
|
98
|
+
id: `app.globals.measure.name.measure_${normalizedName}_name`,
|
|
99
|
+
defaultMessage: name,
|
|
100
|
+
};
|
|
101
|
+
case "kpi_category_name":
|
|
102
|
+
return {
|
|
103
|
+
id: `app.globals.kpis.category.kpi_category_${normalizedName}_name`,
|
|
104
|
+
defaultMessage: name,
|
|
105
|
+
};
|
|
106
|
+
case "kpi_customer_name":
|
|
107
|
+
return {
|
|
108
|
+
id: `app.globals.kpis.description.kpi_customer_${normalizedName}_name`,
|
|
109
|
+
defaultMessage: name,
|
|
110
|
+
};
|
|
111
|
+
default:
|
|
112
|
+
return {
|
|
113
|
+
id: `app.globals.report.name.report_${normalizedName}_name`,
|
|
114
|
+
defaultMessage: name,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|