From 8951a60546b3699c0816eb11e7a01f224bef901c Mon Sep 17 00:00:00 2001 From: Augusto Braun Date: Fri, 12 Jul 2024 17:03:26 -0300 Subject: [PATCH 1/2] criado o arquivo de traducao e a insercao no codigo. enviado para a traducao. --- src/editor/index.ts | 101 ++++++++++++++++++++++++++++++----- src/editor/translations.json | 26 +++++++++ 2 files changed, 114 insertions(+), 13 deletions(-) create mode 100644 src/editor/translations.json diff --git a/src/editor/index.ts b/src/editor/index.ts index 4cfe000..44ab552 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -4,6 +4,9 @@ import { IaraEditorStyleManager } from "./style"; import { IaraEditorNavigationFieldManager } from "./navigationFields"; import { Ribbon } from "../syncfusion/toolbar/ribbon"; +//braun +import * as Translations from "./translations.json"; +// import * as Translation_es from "./es.json"; export interface IaraEditorConfig { darkMode: boolean; @@ -39,6 +42,12 @@ export abstract class EditorAdapter { }; protected _inferenceFormatter: IaraEditorInferenceFormatter; + //braun + // protected _currentLanguage: object; + protected _currentLanguage: {[k: string]: any} = {}; + // protected _language_pt_br: object; + // protected _language_es: object; + private _listeners = [ { key: "iaraSpeechRecognitionResult", @@ -78,6 +87,33 @@ export abstract class EditorAdapter { protected _recognition: IaraSpeechRecognition, protected _config: IaraEditorConfig = EditorAdapter.DefaultConfig ) { + + //braun + //escolher o idioma aqui + // const userProfile: UserProfile = { + // name: "John Doe", + // }; + // const propertyName: keyof UserProfile = "age"; + // const propertyValue = userProfile[propertyName]; + // const translations = require('./translations.json'); + // const currentLanguage = this._config.language; + + // const value = eval(`Translations.${currentLanguage}`); + // const value = Translations; + // console.log(value); + // this._language_pt_br = pt_BR; + // this._language_es = Translation_es; + switch (this._config.language) + { + case 'es': + this._currentLanguage = Translations['es']; + default: + this._currentLanguage = Translations["pt-BR"]; + } + + console.log('CURRENT', this._currentLanguage.copy_report); + + this._inferenceFormatter = new IaraEditorInferenceFormatter(); this._initCommands(); this._initListeners(); @@ -119,8 +155,25 @@ export abstract class EditorAdapter { } private _initCommands(): void { + + //braun + //escolher o idioma aqui + // const userProfile: UserProfile = { + // name: "John Doe", + // }; + // const propertyName: keyof UserProfile = "age"; + // const propertyValue = userProfile[propertyName]; + // const translations = require('./translations.json'); + + + // const value = eval(`Translations.${currentLanguage}`); + + console.log('CURRENT', this._currentLanguage.copy_report); + this._recognition.commands.add( - "iara copiar laudo", + //braun + // "iara copiar laudo", + this._currentLanguage.copy_report, async (detail, command) => { if (detail.transcript === command) { this._getNavigationFieldDeleted(); @@ -131,11 +184,15 @@ export abstract class EditorAdapter { } this._recognition.stop(); await this.copyReport(); - this.onIaraCommand?.("iara copiar laudo"); + //braun + // this.onIaraCommand?.("iara copiar laudo"); + this.onIaraCommand?.(this._currentLanguage.copy_report); } ); this._recognition.commands.add( - "iara finalizar laudo", + //braun + // "iara finalizar laudo", + this._currentLanguage.finish_report, async (detail, command) => { if (detail.transcript === command) { this._getNavigationFieldDeleted(); @@ -146,31 +203,47 @@ export abstract class EditorAdapter { } this._recognition.stop(); await this.finishReport(); - this.onIaraCommand?.("iara finalizar laudo"); + //braun + // this.onIaraCommand?.("iara finalizar laudo"); + this.onIaraCommand?.(this._currentLanguage.finish_report); } ); - this._recognition.commands.add("iara negrito", () => { + //braun + // this._recognition.commands.add("iara negrito", () => { + this._recognition.commands.add(this._currentLanguage.toggle_bold, () => { this._styleManager.toggleBold(); }); - this._recognition.commands.add("iara itálico", () => { + //braun + // this._recognition.commands.add("iara itálico", () => { + this._recognition.commands.add(this._currentLanguage.toggle_italic, () => { this._styleManager.toggleItalic(); }); - this._recognition.commands.add("iara sublinhado", () => { + //braun + // this._recognition.commands.add("iara sublinhado", () => { + this._recognition.commands.add(this._currentLanguage.toggle_underline, () => { this._styleManager.toggleUnderline(); }); - this._recognition.commands.add("iara maiúsculo", () => { + //braun + // this._recognition.commands.add("iara maiúsculo", () => { + this._recognition.commands.add(this._currentLanguage.toggle_uppercase, () => { this._styleManager.toggleUppercase(); }); - this._recognition.commands.add("iara imprimir", () => { + //braun + // this._recognition.commands.add("iara imprimir", () => { + this._recognition.commands.add(this._currentLanguage.print, () => { this.print(); }); - this._recognition.commands.add("iara próximo campo", (detail, command) => { + //braun + // this._recognition.commands.add("iara próximo campo", (detail, command) => { + this._recognition.commands.add(this._currentLanguage.next_field, (detail, command) => { if (detail.transcript === command) { this._getNavigationFieldDeleted(); } this._navigationFieldManager.nextField(); }); - this._recognition.commands.add("iara campo anterior", (detail, command) => { + //braun + // this._recognition.commands.add("iara campo anterior", (detail, command) => { + this._recognition.commands.add(this._currentLanguage.previous_field, (detail, command) => { if (detail.transcript === command) { this._getNavigationFieldDeleted(); } @@ -183,7 +256,9 @@ export abstract class EditorAdapter { this._navigationFieldManager.nextField(); }); this._recognition.commands.add( - `buscar (\\p{Letter}+)`, + //braun + // `buscar (\\p{Letter}+)`, + `${this._currentLanguage.search} (\\p{Letter}+)`, (detail, command, param, groups) => { if (detail.transcript === command) { this._getNavigationFieldDeleted(); @@ -191,7 +266,7 @@ export abstract class EditorAdapter { try { this._navigationFieldManager.goToField(groups ? groups[1] : ""); } catch (e) { - this.onIaraCommand?.("buscar"); + this.onIaraCommand?.(this._currentLanguage.search); } finally { console.info(detail, command, param); } diff --git a/src/editor/translations.json b/src/editor/translations.json new file mode 100644 index 0000000..d5a8648 --- /dev/null +++ b/src/editor/translations.json @@ -0,0 +1,26 @@ +{ + "pt-BR": { + "copy_report": "iara copiar laudo", + "finish_report": "iara finalizar laudo", + "toggle_bold": "iara negrito", + "toggle_italic": "iara itálico", + "toggle_underline": "iara sublinhado", + "toggle_uppercase": "iara maiúsculo", + "print": "iara imprimir", + "next_field": "iara próximo campo", + "previous_field": "iara campo anterior", + "search": "buscar" + }, + "es": { + "copy_report": "iara copiar laudo", + "finish_report": "iara finalizar laudo", + "toggle_bold": "iara negrito", + "toggle_italic": "iara itálico", + "toggle_underline": "iara sublinhado", + "toggle_uppercase": "iara maiúsculo", + "print": "iara imprimir", + "next_field": "iara próximo campo", + "previous_field": "iara campo anterior", + "search": "buscar" + } +} From dbd6d38ce2edafaae713d1f0688cbbcc21ef280c Mon Sep 17 00:00:00 2001 From: Augusto Braun Date: Mon, 15 Jul 2024 17:15:52 -0300 Subject: [PATCH 2/2] finalizando a traducao no adapter --- src/editor/index.ts | 67 ++---------------------------------- src/editor/translations.json | 12 +++---- 2 files changed, 8 insertions(+), 71 deletions(-) diff --git a/src/editor/index.ts b/src/editor/index.ts index 44ab552..6df6e7f 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -1,12 +1,9 @@ import { IaraSpeechRecognition, IaraSpeechRecognitionDetail } from "../speech"; import { IaraEditorInferenceFormatter } from "./formatter"; import { IaraEditorStyleManager } from "./style"; - import { IaraEditorNavigationFieldManager } from "./navigationFields"; import { Ribbon } from "../syncfusion/toolbar/ribbon"; -//braun import * as Translations from "./translations.json"; -// import * as Translation_es from "./es.json"; export interface IaraEditorConfig { darkMode: boolean; @@ -41,12 +38,7 @@ export abstract class EditorAdapter { highlightInference: true, }; protected _inferenceFormatter: IaraEditorInferenceFormatter; - - //braun - // protected _currentLanguage: object; protected _currentLanguage: {[k: string]: any} = {}; - // protected _language_pt_br: object; - // protected _language_es: object; private _listeners = [ { @@ -87,22 +79,7 @@ export abstract class EditorAdapter { protected _recognition: IaraSpeechRecognition, protected _config: IaraEditorConfig = EditorAdapter.DefaultConfig ) { - - //braun - //escolher o idioma aqui - // const userProfile: UserProfile = { - // name: "John Doe", - // }; - // const propertyName: keyof UserProfile = "age"; - // const propertyValue = userProfile[propertyName]; - // const translations = require('./translations.json'); - // const currentLanguage = this._config.language; - - // const value = eval(`Translations.${currentLanguage}`); - // const value = Translations; - // console.log(value); - // this._language_pt_br = pt_BR; - // this._language_es = Translation_es; + // this._config.language = 'es'; switch (this._config.language) { case 'es': @@ -111,9 +88,6 @@ export abstract class EditorAdapter { this._currentLanguage = Translations["pt-BR"]; } - console.log('CURRENT', this._currentLanguage.copy_report); - - this._inferenceFormatter = new IaraEditorInferenceFormatter(); this._initCommands(); this._initListeners(); @@ -155,24 +129,7 @@ export abstract class EditorAdapter { } private _initCommands(): void { - - //braun - //escolher o idioma aqui - // const userProfile: UserProfile = { - // name: "John Doe", - // }; - // const propertyName: keyof UserProfile = "age"; - // const propertyValue = userProfile[propertyName]; - // const translations = require('./translations.json'); - - - // const value = eval(`Translations.${currentLanguage}`); - - console.log('CURRENT', this._currentLanguage.copy_report); - this._recognition.commands.add( - //braun - // "iara copiar laudo", this._currentLanguage.copy_report, async (detail, command) => { if (detail.transcript === command) { @@ -184,14 +141,10 @@ export abstract class EditorAdapter { } this._recognition.stop(); await this.copyReport(); - //braun - // this.onIaraCommand?.("iara copiar laudo"); this.onIaraCommand?.(this._currentLanguage.copy_report); } ); this._recognition.commands.add( - //braun - // "iara finalizar laudo", this._currentLanguage.finish_report, async (detail, command) => { if (detail.transcript === command) { @@ -203,46 +156,32 @@ export abstract class EditorAdapter { } this._recognition.stop(); await this.finishReport(); - //braun - // this.onIaraCommand?.("iara finalizar laudo"); this.onIaraCommand?.(this._currentLanguage.finish_report); } ); - //braun - // this._recognition.commands.add("iara negrito", () => { this._recognition.commands.add(this._currentLanguage.toggle_bold, () => { this._styleManager.toggleBold(); }); - //braun - // this._recognition.commands.add("iara itálico", () => { this._recognition.commands.add(this._currentLanguage.toggle_italic, () => { this._styleManager.toggleItalic(); }); - //braun - // this._recognition.commands.add("iara sublinhado", () => { this._recognition.commands.add(this._currentLanguage.toggle_underline, () => { this._styleManager.toggleUnderline(); }); - //braun - // this._recognition.commands.add("iara maiúsculo", () => { this._recognition.commands.add(this._currentLanguage.toggle_uppercase, () => { this._styleManager.toggleUppercase(); }); //braun - // this._recognition.commands.add("iara imprimir", () => { this._recognition.commands.add(this._currentLanguage.print, () => { + // this._recognition.commands.add("iara capotar", () => { this.print(); }); - //braun - // this._recognition.commands.add("iara próximo campo", (detail, command) => { this._recognition.commands.add(this._currentLanguage.next_field, (detail, command) => { if (detail.transcript === command) { this._getNavigationFieldDeleted(); } this._navigationFieldManager.nextField(); }); - //braun - // this._recognition.commands.add("iara campo anterior", (detail, command) => { this._recognition.commands.add(this._currentLanguage.previous_field, (detail, command) => { if (detail.transcript === command) { this._getNavigationFieldDeleted(); @@ -256,8 +195,6 @@ export abstract class EditorAdapter { this._navigationFieldManager.nextField(); }); this._recognition.commands.add( - //braun - // `buscar (\\p{Letter}+)`, `${this._currentLanguage.search} (\\p{Letter}+)`, (detail, command, param, groups) => { if (detail.transcript === command) { diff --git a/src/editor/translations.json b/src/editor/translations.json index d5a8648..bc2c081 100644 --- a/src/editor/translations.json +++ b/src/editor/translations.json @@ -12,12 +12,12 @@ "search": "buscar" }, "es": { - "copy_report": "iara copiar laudo", - "finish_report": "iara finalizar laudo", - "toggle_bold": "iara negrito", - "toggle_italic": "iara itálico", - "toggle_underline": "iara sublinhado", - "toggle_uppercase": "iara maiúsculo", + "copy_report": "iara copiar informe", + "finish_report": "iara finalizar informe", + "toggle_bold": "iara negrilla", + "toggle_italic": "iara cursiva", + "toggle_underline": "iara subrayado", + "toggle_uppercase": "iara mayúscula", "print": "iara imprimir", "next_field": "iara próximo campo", "previous_field": "iara campo anterior",