@adminforth/i18n 1.2.1-next.1 → 1.2.2
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 +6 -1
- package/dist/index.js +5 -3
- package/index.ts +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
# AdminForth i18n Plugin
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /> <img src="https://woodpecker.devforth.io/api/badges/3848/status.svg" alt="Build Status" /> <a href="https://www.npmjs.com/package/@adminforth/i18n"> <img src="https://img.shields.io/npm/dt/@adminforth/i18n" alt="npm downloads" /></a> <a href="https://www.npmjs.com/package/@adminforth/i18n"><img src="https://img.shields.io/npm/v/@adminforth/i18n" alt="npm version" /></a> <a href="https://www.npmjs.com/package/@adminforth/i18n">
|
|
4
|
+
|
|
5
|
+
Allows to store all translation strings in an adminforth application in a single resource.
|
|
6
|
+
|
|
7
|
+
## For ussage, see [AdminForth i18n Documentation](https://adminforth.dev/docs/tutorial/Plugins/i18n/)
|
package/dist/index.js
CHANGED
|
@@ -360,7 +360,6 @@ export default class I18nPlugin extends AdminForthPlugin {
|
|
|
360
360
|
icon: 'flowbite:language-outline',
|
|
361
361
|
// if optional `confirm` is provided, user will be asked to confirm action
|
|
362
362
|
confirm: 'Are you sure you want to translate selected items?',
|
|
363
|
-
state: 'selected',
|
|
364
363
|
allowed: (_a) => __awaiter(this, [_a], void 0, function* ({ resource, adminUser, selectedIds, allowedActions }) {
|
|
365
364
|
console.log('allowedActions', JSON.stringify(allowedActions));
|
|
366
365
|
return allowedActions.edit;
|
|
@@ -445,7 +444,8 @@ ${JSON.stringify(strings.reduce((acc, s) => {
|
|
|
445
444
|
\`\`\`
|
|
446
445
|
`;
|
|
447
446
|
// call OpenAI
|
|
448
|
-
const resp = yield this.options.completeAdapter.complete(prompt, [],
|
|
447
|
+
const resp = yield this.options.completeAdapter.complete(prompt, [], prompt.length * 2);
|
|
448
|
+
console.log(`🪲🔪LLM resp >> ${prompt.length}, <<${resp.content.length} :\n\n`, JSON.stringify(resp));
|
|
449
449
|
if (resp.error) {
|
|
450
450
|
throw new AiTranslateError(resp.error);
|
|
451
451
|
}
|
|
@@ -680,7 +680,9 @@ ${JSON.stringify(strings.reduce((acc, s) => {
|
|
|
680
680
|
}
|
|
681
681
|
if (params) {
|
|
682
682
|
for (const [key, value] of Object.entries(params)) {
|
|
683
|
-
result
|
|
683
|
+
if (result) {
|
|
684
|
+
result = result.replace(`{${key}}`, value);
|
|
685
|
+
}
|
|
684
686
|
}
|
|
685
687
|
}
|
|
686
688
|
return result;
|
package/index.ts
CHANGED
|
@@ -409,7 +409,6 @@ export default class I18nPlugin extends AdminForthPlugin {
|
|
|
409
409
|
icon: 'flowbite:language-outline',
|
|
410
410
|
// if optional `confirm` is provided, user will be asked to confirm action
|
|
411
411
|
confirm: 'Are you sure you want to translate selected items?',
|
|
412
|
-
state: 'selected',
|
|
413
412
|
allowed: async ({ resource, adminUser, selectedIds, allowedActions }) => {
|
|
414
413
|
console.log('allowedActions', JSON.stringify(allowedActions));
|
|
415
414
|
return allowedActions.edit;
|
|
@@ -507,9 +506,11 @@ JSON.stringify(strings.reduce((acc: object, s: { en_string: string }): object =>
|
|
|
507
506
|
const resp = await this.options.completeAdapter.complete(
|
|
508
507
|
prompt,
|
|
509
508
|
[],
|
|
510
|
-
|
|
509
|
+
prompt.length * 2,
|
|
511
510
|
);
|
|
512
511
|
|
|
512
|
+
console.log(`🪲🔪LLM resp >> ${prompt.length}, <<${resp.content.length} :\n\n`, JSON.stringify(resp));
|
|
513
|
+
|
|
513
514
|
|
|
514
515
|
if (resp.error) {
|
|
515
516
|
throw new AiTranslateError(resp.error);
|
|
@@ -803,7 +804,9 @@ JSON.stringify(strings.reduce((acc: object, s: { en_string: string }): object =>
|
|
|
803
804
|
|
|
804
805
|
if (params) {
|
|
805
806
|
for (const [key, value] of Object.entries(params)) {
|
|
806
|
-
result
|
|
807
|
+
if (result) {
|
|
808
|
+
result = result.replace(`{${key}}`, value);
|
|
809
|
+
}
|
|
807
810
|
}
|
|
808
811
|
}
|
|
809
812
|
return result;
|