Skip to content

Commit bd45280

Browse files
committed
chore: convert all text to lexicons
1 parent 1b48a84 commit bd45280

File tree

18 files changed

+2656
-60
lines changed

18 files changed

+2656
-60
lines changed

TODO.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- [ ] Convert all text to lexicons
2+
- [ ] Implement Vision AI endpoints for TVs
3+
- [ ] Convert docs to Writerside

assets/components/modai/js/mgr/autosummary.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Ext.onReady(function() {
182182

183183
const wandEl = createWandEl();
184184
wandEl.addEventListener('click', () => {
185-
Ext.Msg.wait('Generating ...', 'Please wait');
185+
Ext.Msg.wait(_('modai.cmp.generate_ing'), _('modai.cmp.please_wait'));
186186

187187
MODx.Ajax.request({
188188
url: MODx.config.connector_url,
@@ -200,14 +200,14 @@ Ext.onReady(function() {
200200
Ext.Msg.hide();
201201
}).catch((err) => {
202202
Ext.Msg.hide();
203-
Ext.Msg.alert("Failed", `Failed to generated. Please try again. ${err.message}`);
203+
Ext.Msg.alert("Failed", _('modai.cmp.failed_try_again', {"msg": err.message}));
204204
});
205205
}
206206
},
207207
failure: {
208208
fn: function() {
209209
Ext.Msg.hide();
210-
Ext.Msg.alert("Failed", "Failed to generated. Please try again.");
210+
Ext.Msg.alert("Failed", _('modai.cmp.failed_try_again'));
211211
} ,
212212
scope: this
213213
}
@@ -260,7 +260,7 @@ Ext.onReady(function() {
260260

261261
const wandEl = createWandEl();
262262
wandEl.addEventListener('click', () => {
263-
Ext.Msg.wait('Generating ...', 'Please wait');
263+
Ext.Msg.wait(_('modai.cmp.generate_ing'), _('modai.cmp.please_wait'));
264264

265265
MODx.Ajax.request({
266266
url: MODx.config.connector_url,
@@ -278,14 +278,14 @@ Ext.onReady(function() {
278278
Ext.Msg.hide();
279279
}).catch((err) => {
280280
Ext.Msg.hide();
281-
Ext.Msg.alert("Failed", `Failed to generated. Please try again. ${err.message}`);
281+
Ext.Msg.alert("Failed", _('modai.cmp.failed_try_again', {"msg": err.message}));
282282
});
283283
}
284284
},
285285
failure: {
286286
fn: function() {
287287
Ext.Msg.hide();
288-
Ext.Msg.alert("Failed", "Failed to generated. Please try again.");
288+
Ext.Msg.alert("Failed", _('modai.cmp.failed_try_again'));
289289
} ,
290290
scope: this
291291
}
@@ -329,7 +329,7 @@ Ext.onReady(function() {
329329

330330
const base64Data = canvas.toDataURL('image/png');
331331

332-
Ext.Msg.wait('Generating ...', 'Please wait');
332+
Ext.Msg.wait(_('modai.cmp.generate_ing'), _('modai.cmp.please_wait'));
333333

334334
MODx.Ajax.request({
335335
url: MODx.config.connector_url,
@@ -349,14 +349,14 @@ Ext.onReady(function() {
349349
Ext.Msg.hide();
350350
}).catch((err) => {
351351
Ext.Msg.hide();
352-
Ext.Msg.alert("Failed", `Failed to generated. Please try again. ${err.message}`);
352+
Ext.Msg.alert("Failed", _('modai.cmp.failed_try_again', {"msg": err.message}));
353353
});
354354
}
355355
},
356356
failure: {
357357
fn: function() {
358358
Ext.Msg.hide();
359-
Ext.Msg.alert("Failed", "Failed to generated. Please try again.");
359+
Ext.Msg.alert("Failed", _('modai.cmp.failed_try_again'));
360360
} ,
361361
scope: this
362362
}

assets/components/modai/js/mgr/serviceExecutor.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ modAI.serviceExecutor = async (details) => {
3030
const content = data?.choices?.[0]?.message?.content;
3131

3232
if (!content) {
33-
throw new Error("Failed to process your request.");
33+
throw new Error(_('modai.cmp.failed_request'));
3434
}
3535

3636
return {
@@ -41,7 +41,7 @@ modAI.serviceExecutor = async (details) => {
4141
const url = data?.data?.[0]?.url;
4242

4343
if (!url) {
44-
throw new Error("Failed to process your request.");
44+
throw new Error(_('modai.cmp.failed_request'));
4545
}
4646

4747
return {
@@ -54,7 +54,7 @@ modAI.serviceExecutor = async (details) => {
5454
const content = data?.content?.[0]?.text;
5555

5656
if (!content) {
57-
throw new Error("Failed to process your request.");
57+
throw new Error(_('modai.cmp.failed_request'));
5858
}
5959

6060
return {
@@ -67,7 +67,7 @@ modAI.serviceExecutor = async (details) => {
6767
const content = data?.candidates?.[0]?.content?.parts?.[0]?.text;
6868

6969
if (!content) {
70-
throw new Error("Failed to process your request.");
70+
throw new Error(_('modai.cmp.failed_request'));
7171
}
7272

7373
return {
@@ -78,7 +78,7 @@ modAI.serviceExecutor = async (details) => {
7878
const base64 = data?.predictions?.[0]?.bytesBase64Encoded;
7979

8080
if (!base64) {
81-
throw new Error("Failed to process your request.");
81+
throw new Error(_('modai.cmp.failed_request'));
8282
}
8383

8484
return {
@@ -89,11 +89,11 @@ modAI.serviceExecutor = async (details) => {
8989
};
9090

9191
if (!details.service || !details.parser) {
92-
throw new Error("Service is required");
92+
throw new Error(_('modai.cmp.service_required'));
9393
}
9494

9595
if (!services[details.service]?.[details.parser]) {
96-
throw new Error("Unsupported Service/Parser");
96+
throw new Error(_('modai.cmp.service_unsupported'));
9797
}
9898

9999
const data = await callService(details);

assets/components/modai/js/mgr/widgets/image_prompt.window.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ modAI.window.ImagePrompt = function(config) {
44
const pagination = this.init();
55

66
Ext.applyIf(config,{
7-
title: 'Image',
7+
title: _('modai.cmp.image'),
88
closeAction: 'close',
99
width: 600,
1010
autoHeight: true,
@@ -109,7 +109,7 @@ Ext.extend(modAI.window.ImagePrompt,MODx.Window, {
109109
});
110110

111111
this.prompt = new Ext.form.TextArea({
112-
fieldLabel: 'Prompt',
112+
fieldLabel: _('modai.cmp.prompt'),
113113
name: 'prompt',
114114
anchor: '100%',
115115
required: true,
@@ -177,12 +177,12 @@ Ext.extend(modAI.window.ImagePrompt,MODx.Window, {
177177
handler: () => {
178178
const prompt = this.prompt.getValue();
179179
if (!prompt) {
180-
this.prompt.markInvalid("Prompt is required");
180+
this.prompt.markInvalid(_('modai.cmp.prompt_required'));
181181
return;
182182
}
183183
this.prompt.clearInvalid();
184184

185-
Ext.Msg.wait('Generating ...', 'Please wait');
185+
Ext.Msg.wait(_('modai.cmp.generate_ing'), _('modai.cmp.please_wait'));
186186
MODx.Ajax.request({
187187
url: MODx.config.connector_url,
188188
timeout: 0,
@@ -199,14 +199,14 @@ Ext.extend(modAI.window.ImagePrompt,MODx.Window, {
199199
Ext.Msg.hide();
200200
}).catch((err) => {
201201
Ext.Msg.hide();
202-
Ext.Msg.alert("Failed", `Failed to generated. Please try again. ${err.message}`);
202+
Ext.Msg.alert(_('modai.cmp.failed'), _('modai.cmp.failed_try_again', {"msg": err.message}));
203203
});
204204
}
205205
},
206206
failure: {
207207
fn: function() {
208208
Ext.Msg.hide();
209-
Ext.Msg.alert("Failed", "Failed to generated. Please try again.");
209+
Ext.Msg.alert(_('modai.cmp.failed'), _('modai.cmp.failed_try_again'));
210210
} ,
211211
scope: this
212212
}

assets/components/modai/js/mgr/widgets/text_prompt.window.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ modAI.window.TextPrompt = function(config) {
66
const pagination = this.init(config);
77

88
Ext.applyIf(config,{
9-
title: 'Text',
9+
title: _('modai.cmp.text'),
1010
closeAction: 'close',
1111
width: 600,
1212
autoHeight: true,
@@ -91,7 +91,7 @@ Ext.extend(modAI.window.TextPrompt,MODx.Window, {
9191
});
9292

9393
this.prompt = new Ext.form.TextArea({
94-
fieldLabel: 'Prompt',
94+
fieldLabel: _('modai.cmp.prompt'),
9595
name: 'prompt',
9696
anchor: '100%',
9797
required: true,
@@ -118,14 +118,14 @@ Ext.extend(modAI.window.TextPrompt,MODx.Window, {
118118
this.close();
119119
})
120120
.catch(() => {
121-
Ext.Msg.alert("Failed", "Failed to copy the generated text. Please try again.");
121+
Ext.Msg.alert(_('modai.cmp.failed'), _('modai.cmp.failed_copy'));
122122
});
123123
} else {
124124
try {
125125
document.execCommand("copy");
126126
this.close();
127127
} catch (err) {
128-
Ext.Msg.alert("Failed", "Failed to copy the generated text. Please try again.");
128+
Ext.Msg.alert(_('modai.cmp.failed'), _('modai.cmp.failed_copy'));
129129
}
130130
}
131131
},
@@ -165,12 +165,12 @@ Ext.extend(modAI.window.TextPrompt,MODx.Window, {
165165
handler: () => {
166166
const prompt = this.prompt.getValue();
167167
if (!prompt) {
168-
this.prompt.markInvalid("Prompt is required");
168+
this.prompt.markInvalid(_('modai.cmp.prompt_required'));
169169
return;
170170
}
171171
this.prompt.clearInvalid();
172172

173-
Ext.Msg.wait('Generating ...', 'Please wait');
173+
Ext.Msg.wait(_('modai.cmp.generate_ing'), _('modai.cmp.please_wait'));
174174

175175
MODx.Ajax.request({
176176
url: MODx.config.connector_url,
@@ -188,14 +188,14 @@ Ext.extend(modAI.window.TextPrompt,MODx.Window, {
188188
Ext.Msg.hide();
189189
}).catch((err) => {
190190
Ext.Msg.hide();
191-
Ext.Msg.alert("Failed", `Failed to generated. Please try again. ${err.message}`);
191+
Ext.Msg.alert(_('modai.cmp.failed'), _('modai.cmp.failed_try_again', {"msg": err.message}));
192192
});
193193
}
194194
},
195195
failure: {
196196
fn: function() {
197197
Ext.Msg.hide();
198-
Ext.Msg.alert("Failed", "Failed to generated. Please try again.");
198+
Ext.Msg.alert(_('modai.cmp.failed'), _('modai.cmp.failed_try_again'));
199199
} ,
200200
scope: this
201201
}

core/components/modai/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"psr-4": {
44
"modAI\\": "src/"
55
}
6+
},
7+
"require-dev": {
8+
"modx/revolution": "^3.1"
69
}
710
}

0 commit comments

Comments
 (0)