slicejs-web-framework 2.2.13 → 2.3.1
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/README.md +155 -156
- package/Slice/Components/Structural/ContextManager/ContextManager.js +361 -0
- package/Slice/Components/Structural/Controller/Controller.js +131 -96
- package/Slice/Components/Structural/EventManager/EventManager.js +329 -0
- package/Slice/Components/Structural/Router/Router.js +112 -103
- package/Slice/Slice.js +83 -35
- package/package.json +1 -1
- package/src/Components/AppComponents/HomePage/HomePage.js +195 -195
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.js +3 -4
- package/src/Components/components.js +1 -2
- package/src/sliceConfig.json +59 -53
- package/src/Components/Service/Translator/Translator.js +0 -45
- package/src/Components/Service/Translator/messages.json +0 -58
|
@@ -1,196 +1,196 @@
|
|
|
1
|
-
export default class HomePage extends HTMLElement {
|
|
2
|
-
constructor(props) {
|
|
3
|
-
super();
|
|
4
|
-
slice.attachTemplate(this);
|
|
5
|
-
|
|
6
|
-
this.$examplesContainer = this.querySelector('.examples-container');
|
|
7
|
-
|
|
8
|
-
slice.controller.setComponentProps(this, props);
|
|
9
|
-
this.debuggerProps = [];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async init() {
|
|
13
|
-
// Crear la barra de navegación
|
|
14
|
-
const navbar = await slice.build('Navbar', {
|
|
15
|
-
position: 'fixed',
|
|
16
|
-
logo: {
|
|
17
|
-
src: '/images/Slice.js-logo.png',
|
|
18
|
-
path: '/',
|
|
19
|
-
},
|
|
20
|
-
items: [
|
|
21
|
-
{ text: 'Home', path: '/' },
|
|
22
|
-
{ text: 'Playground', path: '/Playground' },
|
|
23
|
-
|
|
24
|
-
],
|
|
25
|
-
buttons: [
|
|
26
|
-
{
|
|
27
|
-
value: 'Change Theme',
|
|
28
|
-
onClickCallback: async () => {
|
|
29
|
-
const currentTheme = slice.stylesManager.themeManager.currentTheme;
|
|
30
|
-
if (currentTheme === 'Slice') {
|
|
31
|
-
await slice.setTheme('Light');
|
|
32
|
-
} else if (currentTheme === 'Light') {
|
|
33
|
-
await slice.setTheme('Dark');
|
|
34
|
-
} else {
|
|
35
|
-
await slice.setTheme('Slice');
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Crear botones para la sección de llamada a la acción
|
|
43
|
-
const docsButton = await slice.build('Button', {
|
|
44
|
-
value: 'Documentation',
|
|
45
|
-
onClickCallback: () => //redirect to https://slice-js-docs.vercel.app/Documentation
|
|
46
|
-
window.open('https://slice-js-docs.vercel.app/Documentation', '_blank'),
|
|
47
|
-
customColor: {
|
|
48
|
-
button: 'var(--primary-color)',
|
|
49
|
-
label: 'var(--primary-color-contrast)'
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const componentsButton = await slice.build('Button', {
|
|
54
|
-
value: 'Components Library',
|
|
55
|
-
onClickCallback: () => window.open('https://slice-js-docs.vercel.app/Documentation/Visual', '_blank'),
|
|
56
|
-
customColor: {
|
|
57
|
-
button: 'var(--secondary-color)',
|
|
58
|
-
label: 'var(--secondary-color-contrast)'
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Añadir botones a la sección CTA
|
|
63
|
-
this.querySelector('.cta-buttons').appendChild(docsButton);
|
|
64
|
-
this.querySelector('.cta-buttons').appendChild(componentsButton);
|
|
65
|
-
|
|
66
|
-
// Crear features section con un enfoque diferente (sin usar Cards)
|
|
67
|
-
await this.createFeatures();
|
|
68
|
-
|
|
69
|
-
// Crear ejemplos de componentes
|
|
70
|
-
await this.createComponentExamples();
|
|
71
|
-
|
|
72
|
-
// Configurar la sección de código de inicio
|
|
73
|
-
await this.setupGettingStartedSection();
|
|
74
|
-
|
|
75
|
-
// Añadir la barra de navegación al inicio del componente
|
|
76
|
-
this.insertBefore(navbar, this.firstChild);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async createFeatures() {
|
|
80
|
-
// Definir características
|
|
81
|
-
const features = [
|
|
82
|
-
{
|
|
83
|
-
title: 'Component-Based',
|
|
84
|
-
description: 'Build your app using modular, reusable components following web standards.'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
title: 'Zero Dependencies',
|
|
88
|
-
description: 'Built with vanilla JavaScript. No external libraries required.'
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
title: 'Easy Routing',
|
|
92
|
-
description: 'Simple and powerful routing system for single page applications.'
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title: 'Theme System',
|
|
96
|
-
description: 'Built-in theme support with easy customization through CSS variables.'
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
title: 'Developer Tools',
|
|
100
|
-
description: 'Integrated debugging and logging for faster development.'
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
title: 'Performance Focused',
|
|
104
|
-
description: 'Lightweight and optimized for fast loading and execution.'
|
|
105
|
-
}
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
const featureGrid = this.querySelector('.feature-grid');
|
|
109
|
-
|
|
110
|
-
// Crear y añadir cada feature como un elemento HTML simple
|
|
111
|
-
for (const feature of features) {
|
|
112
|
-
const featureElement = document.createElement('div');
|
|
113
|
-
featureElement.classList.add('feature-item');
|
|
114
|
-
|
|
115
|
-
const featureTitle = document.createElement('h3');
|
|
116
|
-
featureTitle.textContent = feature.title;
|
|
117
|
-
featureTitle.classList.add('feature-title');
|
|
118
|
-
|
|
119
|
-
const featureDescription = document.createElement('p');
|
|
120
|
-
featureDescription.textContent = feature.description;
|
|
121
|
-
featureDescription.classList.add('feature-description');
|
|
122
|
-
|
|
123
|
-
featureElement.appendChild(featureTitle);
|
|
124
|
-
featureElement.appendChild(featureDescription);
|
|
125
|
-
|
|
126
|
-
featureGrid.appendChild(featureElement);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async createComponentExamples() {
|
|
131
|
-
// Crear ejemplos para demostrar componentes
|
|
132
|
-
const inputExample = await slice.build('Input', {
|
|
133
|
-
placeholder: 'Try typing here...',
|
|
134
|
-
type: 'text'
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const switchExample = await slice.build('Switch', {
|
|
138
|
-
label: 'Toggle me',
|
|
139
|
-
checked: true
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const checkboxExample = await slice.build('Checkbox', {
|
|
143
|
-
label: 'Check me',
|
|
144
|
-
labelPlacement: 'right'
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const detailsExample = await slice.build('Details', {
|
|
148
|
-
title: 'Click to expand',
|
|
149
|
-
text: 'This is a collapsible details component that can contain any content.'
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
// Crear sección para cada ejemplo
|
|
153
|
-
const exampleSections = [
|
|
154
|
-
{ title: 'Input Component', component: inputExample },
|
|
155
|
-
{ title: 'Switch Component', component: switchExample },
|
|
156
|
-
{ title: 'Checkbox Component', component: checkboxExample },
|
|
157
|
-
{ title: 'Details Component', component: detailsExample }
|
|
158
|
-
];
|
|
159
|
-
|
|
160
|
-
// Añadir cada ejemplo a la sección de ejemplos
|
|
161
|
-
for (const section of exampleSections) {
|
|
162
|
-
const container = document.createElement('div');
|
|
163
|
-
container.classList.add('example-item');
|
|
164
|
-
|
|
165
|
-
const title = document.createElement('h3');
|
|
166
|
-
title.textContent = section.title;
|
|
167
|
-
|
|
168
|
-
container.appendChild(title);
|
|
169
|
-
container.appendChild(section.component);
|
|
170
|
-
|
|
171
|
-
this.$examplesContainer.appendChild(container);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async setupGettingStartedSection() {
|
|
176
|
-
// Opcionalmente podríamos mejorar esta sección usando el CodeVisualizer component
|
|
177
|
-
// en lugar del código HTML estático en el template
|
|
178
|
-
const codeVisualizer = await slice.build('CodeVisualizer', {
|
|
179
|
-
value: `// Initialize a new Slice.js project
|
|
180
|
-
npm run slice:init
|
|
181
|
-
|
|
182
|
-
// Create a new component
|
|
183
|
-
npm run slice:create
|
|
184
|
-
|
|
185
|
-
// Start your application
|
|
186
|
-
npm run slice:start`,
|
|
187
|
-
language: 'bash'
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const codeSample = this.querySelector('.code-sample');
|
|
191
|
-
codeSample.innerHTML = ''; // Clear the static code sample
|
|
192
|
-
codeSample.appendChild(codeVisualizer);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
1
|
+
export default class HomePage extends HTMLElement {
|
|
2
|
+
constructor(props) {
|
|
3
|
+
super();
|
|
4
|
+
slice.attachTemplate(this);
|
|
5
|
+
|
|
6
|
+
this.$examplesContainer = this.querySelector('.examples-container');
|
|
7
|
+
|
|
8
|
+
slice.controller.setComponentProps(this, props);
|
|
9
|
+
this.debuggerProps = [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async init() {
|
|
13
|
+
// Crear la barra de navegación
|
|
14
|
+
const navbar = await slice.build('Navbar', {
|
|
15
|
+
position: 'fixed',
|
|
16
|
+
logo: {
|
|
17
|
+
src: '/images/Slice.js-logo.png',
|
|
18
|
+
path: '/',
|
|
19
|
+
},
|
|
20
|
+
items: [
|
|
21
|
+
{ text: 'Home', path: '/' },
|
|
22
|
+
{ text: 'Playground', path: '/Playground' },
|
|
23
|
+
|
|
24
|
+
],
|
|
25
|
+
buttons: [
|
|
26
|
+
{
|
|
27
|
+
value: 'Change Theme',
|
|
28
|
+
onClickCallback: async () => {
|
|
29
|
+
const currentTheme = slice.stylesManager.themeManager.currentTheme;
|
|
30
|
+
if (currentTheme === 'Slice') {
|
|
31
|
+
await slice.setTheme('Light');
|
|
32
|
+
} else if (currentTheme === 'Light') {
|
|
33
|
+
await slice.setTheme('Dark');
|
|
34
|
+
} else {
|
|
35
|
+
await slice.setTheme('Slice');
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Crear botones para la sección de llamada a la acción
|
|
43
|
+
const docsButton = await slice.build('Button', {
|
|
44
|
+
value: 'Documentation',
|
|
45
|
+
onClickCallback: () => //redirect to https://slice-js-docs.vercel.app/Documentation
|
|
46
|
+
window.open('https://slice-js-docs.vercel.app/Documentation', '_blank'),
|
|
47
|
+
customColor: {
|
|
48
|
+
button: 'var(--primary-color)',
|
|
49
|
+
label: 'var(--primary-color-contrast)'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const componentsButton = await slice.build('Button', {
|
|
54
|
+
value: 'Components Library',
|
|
55
|
+
onClickCallback: () => window.open('https://slice-js-docs.vercel.app/Documentation/Visual', '_blank'),
|
|
56
|
+
customColor: {
|
|
57
|
+
button: 'var(--secondary-color)',
|
|
58
|
+
label: 'var(--secondary-color-contrast)'
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Añadir botones a la sección CTA
|
|
63
|
+
this.querySelector('.cta-buttons').appendChild(docsButton);
|
|
64
|
+
this.querySelector('.cta-buttons').appendChild(componentsButton);
|
|
65
|
+
|
|
66
|
+
// Crear features section con un enfoque diferente (sin usar Cards)
|
|
67
|
+
await this.createFeatures();
|
|
68
|
+
|
|
69
|
+
// Crear ejemplos de componentes
|
|
70
|
+
await this.createComponentExamples();
|
|
71
|
+
|
|
72
|
+
// Configurar la sección de código de inicio
|
|
73
|
+
await this.setupGettingStartedSection();
|
|
74
|
+
|
|
75
|
+
// Añadir la barra de navegación al inicio del componente
|
|
76
|
+
this.insertBefore(navbar, this.firstChild);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async createFeatures() {
|
|
80
|
+
// Definir características
|
|
81
|
+
const features = [
|
|
82
|
+
{
|
|
83
|
+
title: 'Component-Based',
|
|
84
|
+
description: 'Build your app using modular, reusable components following web standards.'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
title: 'Zero Dependencies',
|
|
88
|
+
description: 'Built with vanilla JavaScript. No external libraries required.'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: 'Easy Routing',
|
|
92
|
+
description: 'Simple and powerful routing system for single page applications.'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: 'Theme System',
|
|
96
|
+
description: 'Built-in theme support with easy customization through CSS variables.'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
title: 'Developer Tools',
|
|
100
|
+
description: 'Integrated debugging and logging for faster development.'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
title: 'Performance Focused',
|
|
104
|
+
description: 'Lightweight and optimized for fast loading and execution.'
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
const featureGrid = this.querySelector('.feature-grid');
|
|
109
|
+
|
|
110
|
+
// Crear y añadir cada feature como un elemento HTML simple
|
|
111
|
+
for (const feature of features) {
|
|
112
|
+
const featureElement = document.createElement('div');
|
|
113
|
+
featureElement.classList.add('feature-item');
|
|
114
|
+
|
|
115
|
+
const featureTitle = document.createElement('h3');
|
|
116
|
+
featureTitle.textContent = feature.title;
|
|
117
|
+
featureTitle.classList.add('feature-title');
|
|
118
|
+
|
|
119
|
+
const featureDescription = document.createElement('p');
|
|
120
|
+
featureDescription.textContent = feature.description;
|
|
121
|
+
featureDescription.classList.add('feature-description');
|
|
122
|
+
|
|
123
|
+
featureElement.appendChild(featureTitle);
|
|
124
|
+
featureElement.appendChild(featureDescription);
|
|
125
|
+
|
|
126
|
+
featureGrid.appendChild(featureElement);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async createComponentExamples() {
|
|
131
|
+
// Crear ejemplos para demostrar componentes
|
|
132
|
+
const inputExample = await slice.build('Input', {
|
|
133
|
+
placeholder: 'Try typing here...',
|
|
134
|
+
type: 'text'
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const switchExample = await slice.build('Switch', {
|
|
138
|
+
label: 'Toggle me',
|
|
139
|
+
checked: true
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const checkboxExample = await slice.build('Checkbox', {
|
|
143
|
+
label: 'Check me',
|
|
144
|
+
labelPlacement: 'right'
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const detailsExample = await slice.build('Details', {
|
|
148
|
+
title: 'Click to expand',
|
|
149
|
+
text: 'This is a collapsible details component that can contain any content.'
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Crear sección para cada ejemplo
|
|
153
|
+
const exampleSections = [
|
|
154
|
+
{ title: 'Input Component', component: inputExample },
|
|
155
|
+
{ title: 'Switch Component', component: switchExample },
|
|
156
|
+
{ title: 'Checkbox Component', component: checkboxExample },
|
|
157
|
+
{ title: 'Details Component', component: detailsExample }
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
// Añadir cada ejemplo a la sección de ejemplos
|
|
161
|
+
for (const section of exampleSections) {
|
|
162
|
+
const container = document.createElement('div');
|
|
163
|
+
container.classList.add('example-item');
|
|
164
|
+
|
|
165
|
+
const title = document.createElement('h3');
|
|
166
|
+
title.textContent = section.title;
|
|
167
|
+
|
|
168
|
+
container.appendChild(title);
|
|
169
|
+
container.appendChild(section.component);
|
|
170
|
+
|
|
171
|
+
this.$examplesContainer.appendChild(container);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async setupGettingStartedSection() {
|
|
176
|
+
// Opcionalmente podríamos mejorar esta sección usando el CodeVisualizer component
|
|
177
|
+
// en lugar del código HTML estático en el template
|
|
178
|
+
const codeVisualizer = await slice.build('CodeVisualizer', {
|
|
179
|
+
value: `// Initialize a new Slice.js project
|
|
180
|
+
npm run slice:init
|
|
181
|
+
|
|
182
|
+
// Create a new component
|
|
183
|
+
npm run slice:create
|
|
184
|
+
|
|
185
|
+
// Start your application
|
|
186
|
+
npm run slice:start`,
|
|
187
|
+
language: 'bash'
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const codeSample = this.querySelector('.code-sample');
|
|
191
|
+
codeSample.innerHTML = ''; // Clear the static code sample
|
|
192
|
+
codeSample.appendChild(codeVisualizer);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
196
|
customElements.define('slice-home-page', HomePage);
|
|
@@ -90,8 +90,7 @@ export default class CodeVisualizer extends HTMLElement {
|
|
|
90
90
|
.replace(/&/g, '&')
|
|
91
91
|
.replace(/</g, '<')
|
|
92
92
|
.replace(/>/g, '>')
|
|
93
|
-
.replace(/"/g, '"')
|
|
94
|
-
.replace(/'/g, ''');
|
|
93
|
+
.replace(/"/g, '"');
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
highlightJavaScript(code) {
|
|
@@ -188,7 +187,7 @@ export default class CodeVisualizer extends HTMLElement {
|
|
|
188
187
|
});
|
|
189
188
|
|
|
190
189
|
// 3. Atributos HTML
|
|
191
|
-
extractTokens(/\s([a-zA-Z0-9-]+)=("
|
|
190
|
+
extractTokens(/\s([a-zA-Z0-9-]+)=("|')/g, (match, attr, quote) => {
|
|
192
191
|
const tokenId = generateTokenId(tokens.length);
|
|
193
192
|
tokens.push({
|
|
194
193
|
id: tokenId,
|
|
@@ -260,4 +259,4 @@ export default class CodeVisualizer extends HTMLElement {
|
|
|
260
259
|
|
|
261
260
|
customElements.define('slice-codevisualizer', CodeVisualizer);
|
|
262
261
|
|
|
263
|
-
|
|
262
|
+
|
package/src/sliceConfig.json
CHANGED
|
@@ -1,54 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
2
|
+
"server": {
|
|
3
|
+
"port": 3001,
|
|
4
|
+
"host": "localhost"
|
|
5
|
+
},
|
|
6
|
+
"debugger": {
|
|
7
|
+
"enabled": false,
|
|
8
|
+
"click": "right"
|
|
9
|
+
},
|
|
10
|
+
"events": {
|
|
11
|
+
"enabled": true
|
|
12
|
+
},
|
|
13
|
+
"context": {
|
|
14
|
+
"enabled": true
|
|
15
|
+
},
|
|
16
|
+
"stylesManager": {
|
|
17
|
+
"requestedStyles": ["sliceStyles"]
|
|
18
|
+
},
|
|
19
|
+
"themeManager": {
|
|
20
|
+
"enabled": true,
|
|
21
|
+
"defaultTheme": "Slice",
|
|
22
|
+
"saveThemeLocally": false,
|
|
23
|
+
"useBrowserTheme": false
|
|
24
|
+
},
|
|
25
|
+
"logger": {
|
|
26
|
+
"enabled": true,
|
|
27
|
+
"showLogs": {
|
|
28
|
+
"console": {
|
|
29
|
+
"error": true,
|
|
30
|
+
"warning": true,
|
|
31
|
+
"info": false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"paths": {
|
|
36
|
+
"components": {
|
|
37
|
+
"AppComponents": {
|
|
38
|
+
"path": "/Components/AppComponents",
|
|
39
|
+
"type": "Visual"
|
|
40
|
+
},
|
|
41
|
+
"Visual": {
|
|
42
|
+
"path": "/Components/Visual",
|
|
43
|
+
"type": "Visual"
|
|
44
|
+
},
|
|
45
|
+
"Service": {
|
|
46
|
+
"path": "/Components/Service",
|
|
47
|
+
"type": "Service"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"themes": "/Themes",
|
|
51
|
+
"styles": "/Styles",
|
|
52
|
+
"routesFile": "/routes.js"
|
|
53
|
+
},
|
|
54
|
+
"router": {
|
|
55
|
+
"defaultRoute": "/"
|
|
56
|
+
},
|
|
57
|
+
"loading": {
|
|
58
|
+
"enabled": true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import messages from './messages.json' with { type: 'json' };
|
|
2
|
-
|
|
3
|
-
export default class Translator {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.messages = messages;
|
|
6
|
-
this.currentLanguage = 'en';
|
|
7
|
-
|
|
8
|
-
if (slice.translator) {
|
|
9
|
-
throw new Error('Translator already initialized');
|
|
10
|
-
} else {
|
|
11
|
-
slice.translator = this;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
changeLanguage(newLanguage) {
|
|
16
|
-
this.currentLanguage = newLanguage;
|
|
17
|
-
return this.setPropertiesForComponents();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setPropertiesForComponents() {
|
|
21
|
-
try {
|
|
22
|
-
const currentLanguageMessages = this.messages[this.currentLanguage];
|
|
23
|
-
|
|
24
|
-
for (const componentName in currentLanguageMessages) {
|
|
25
|
-
const component = slice.controller.activeComponents.get(componentName);
|
|
26
|
-
const translations = currentLanguageMessages[componentName];
|
|
27
|
-
if (component) {
|
|
28
|
-
for (const prop in translations) {
|
|
29
|
-
component[prop] = translations[prop];
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
console.error(`Component ${componentName} not found`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return true;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.log(error);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setMessages(messagesObject) {
|
|
43
|
-
this.messages = messagesObject;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"en": {
|
|
3
|
-
"myInput": {
|
|
4
|
-
"placeholder": "Type here"
|
|
5
|
-
},
|
|
6
|
-
"cardYoutube": {
|
|
7
|
-
"title": "Youtube in English",
|
|
8
|
-
"text": "Youtube is a video sharing platform. You can watch videos, upload your own videos and comment on videos."
|
|
9
|
-
},
|
|
10
|
-
"cardGoogle": {
|
|
11
|
-
"title": "Google in English",
|
|
12
|
-
"text": "Google is a search engine. You can search for information, images, videos and much more."
|
|
13
|
-
},
|
|
14
|
-
"cardFacebook": {
|
|
15
|
-
"title": "Facebook in English",
|
|
16
|
-
"text": "Facebook is a social network. You can share photos, videos, statuses and chat with your friends."
|
|
17
|
-
},
|
|
18
|
-
"cardTwitter": {
|
|
19
|
-
"title": "Twitter in English",
|
|
20
|
-
"text": "Twitter is a social network. You can share tweets, follow other people and stay informed."
|
|
21
|
-
},
|
|
22
|
-
"buttonLanguage": {
|
|
23
|
-
"value": "Change language"
|
|
24
|
-
},
|
|
25
|
-
"prueba":{
|
|
26
|
-
"title":"Card in English",
|
|
27
|
-
"text":"Text in english"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"es": {
|
|
31
|
-
"myInput": {
|
|
32
|
-
"placeholder": "Escribe aquí"
|
|
33
|
-
},
|
|
34
|
-
"cardYoutube": {
|
|
35
|
-
"title": "Youtube en Español",
|
|
36
|
-
"text": "Youtube es una plataforma de intercambio de videos. Puedes ver videos, subir tus propios videos y comentar en videos."
|
|
37
|
-
},
|
|
38
|
-
"cardGoogle": {
|
|
39
|
-
"title": "Google en Español",
|
|
40
|
-
"text": "Google es un motor de búsqueda. Puedes buscar información, imágenes, videos y mucho más."
|
|
41
|
-
},
|
|
42
|
-
"cardFacebook": {
|
|
43
|
-
"title": "Facebook en Español",
|
|
44
|
-
"text": "Facebook es una red social. Puedes compartir fotos, videos, estados y chatear con tus amigos."
|
|
45
|
-
},
|
|
46
|
-
"cardTwitter": {
|
|
47
|
-
"title": "Twitter en Español",
|
|
48
|
-
"text": "Twitter es una red social. Puedes compartir tweets, seguir a otras personas y mantenerte informado."
|
|
49
|
-
},
|
|
50
|
-
"buttonLanguage": {
|
|
51
|
-
"value": "Cambiar idioma"
|
|
52
|
-
},
|
|
53
|
-
"prueba":{
|
|
54
|
-
"title":"Card en espanol",
|
|
55
|
-
"text":"Text en espanol"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|