From b3587acfee7135f4b89d4a4b0c1e7e141bf3710c Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 21 Dec 2022 21:22:17 -0800 Subject: [PATCH] Add internationalization. --- packages/editor/lang/de.json | 62 +++++++++++-------- packages/editor/lang/en.json | 12 ++++ packages/editor/lang/es.json | 12 ++++ packages/editor/lang/fr.json | 12 ++++ packages/editor/src/compiled-lang/de.json | 24 +++++++ packages/editor/src/compiled-lang/en.json | 24 +++++++ packages/editor/src/compiled-lang/es.json | 24 +++++++ packages/editor/src/compiled-lang/fr.json | 24 +++++++ .../editor-toolbar/configBuilder.tsx | 20 +++--- packages/mindplot/src/components/Designer.ts | 8 +-- packages/mindplot/src/components/Topic.ts | 10 ++- 11 files changed, 189 insertions(+), 43 deletions(-) diff --git a/packages/editor/lang/de.json b/packages/editor/lang/de.json index 2f6c4658..2343b1c5 100644 --- a/packages/editor/lang/de.json +++ b/packages/editor/lang/de.json @@ -93,7 +93,7 @@ "defaultMessage": "Zoom zu passen" }, "editor-panel.tooltip-add-icon": { - "defaultMessage":"Symbol hinzufügen" + "defaultMessage": "Symbol hinzufügen" }, "editor-panel.tooltip-add-link": { "defaultMessage": "Link hinzufügen" @@ -150,75 +150,87 @@ "defaultMessage": "Themenstil" }, "shortcut-help-pane.action": { - "defaultMessage": "Aktion" + "defaultMessage": "Aktion" }, "shortcut-help-pane.add-child": { - "defaultMessage": "Kinderthema hinzufügen" + "defaultMessage": "Kinderthema hinzufügen" }, "shortcut-help-pane.add-link": { - "defaultMessage": "Link hinzufügen" + "defaultMessage": "Link hinzufügen" }, "shortcut-help-pane.add-note": { - "defaultMessage": "Notiz hinzufügen" + "defaultMessage": "Notiz hinzufügen" }, "shortcut-help-pane.add-sibling": { - "defaultMessage": "Geschwisterthema hinzufügen" + "defaultMessage": "Geschwisterthema hinzufügen" }, "shortcut-help-pane.cancel-text-changes": { - "defaultMessage": "Textänderungen abbrechen" + "defaultMessage": "Textänderungen abbrechen" }, "shortcut-help-pane.change-font-bold": { - "defaultMessage": "Text in fett gedruckt" + "defaultMessage": "Text in fett gedruckt" }, "shortcut-help-pane.change-font-italic": { - "defaultMessage": "Text in Kursivschrift ändern" + "defaultMessage": "Text in Kursivschrift ändern" }, "shortcut-help-pane.collapse-children": { - "defaultMessage": "Kinder zusammenbrechen" + "defaultMessage": "Kinder zusammenbrechen" }, "shortcut-help-pane.copy-and-text": { - "defaultMessage": "Themen kopieren und einfügen" + "defaultMessage": "Themen kopieren und einfügen" }, "shortcut-help-pane.delete-topic": { - "defaultMessage":"Thema löschen" + "defaultMessage": "Thema löschen" }, "shortcut-help-pane.deselect-all-topics": { - "defaultMessage": "Alle Themen auswählen" + "defaultMessage": "Alle Themen auswählen" }, "shortcut-help-pane.edit-multiline": { - "defaultMessage": "Multi-Line-Thementext hinzufügen" + "defaultMessage": "Multi-Line-Thementext hinzufügen" }, "shortcut-help-pane.edit-topic": { - "defaultMessage": "Thementext bearbeiten" + "defaultMessage": "Thementext bearbeiten" }, "shortcut-help-pane.edit-topic-key": { - "defaultMessage": "Fang einfach an zu tippen" + "defaultMessage": "Fang einfach an zu tippen" }, "shortcut-help-pane.navigation": { - "defaultMessage": "navigation" + "defaultMessage": "navigation" }, "shortcut-help-pane.navigation-keys": { - "defaultMessage": "Pfeiltasten" + "defaultMessage": "Pfeiltasten" }, "shortcut-help-pane.redo": { - "defaultMessage": "redoEdition" + "defaultMessage": "redoEdition" }, "shortcut-help-pane.save-changes": { - "defaultMessage": "Änderungen speichern" + "defaultMessage": "Änderungen speichern" }, "shortcut-help-pane.select-all-topics": { - "defaultMessage": "Wählen Sie alle Themen aus" + "defaultMessage": "Wählen Sie alle Themen aus" }, "shortcut-help-pane.select-topics": { - "defaultMessage": "Wählen Sie mehrere Themen aus" + "defaultMessage": "Wählen Sie mehrere Themen aus" }, "shortcut-help-pane.select-topics-keys": { - "defaultMessage": "Mausklick" + "defaultMessage": "Mausklick" }, "shortcut-help-pane.undo": { - "defaultMessage": "Rückgängerausgabe" + "defaultMessage": "Rückgängerausgabe" }, "icon-picker.show-images": { - "defaultMessage": "Bilder anzeigen" + "defaultMessage": "Bilder anzeigen" + }, + "editor-panel.tooltip-connection-style": { + "defaultMessage": "Verbindungsstil" + }, + "editor-panel.tooltip-connection-style-curved": { + "defaultMessage": "Kurve" + }, + "editor-panel.tooltip-connection-style-polyline": { + "defaultMessage": "Polylinie" + }, + "editor-panel.tooltip-connection-style-polyline-curved": { + "defaultMessage": "Gekrümmte Polylinie" } } \ No newline at end of file diff --git a/packages/editor/lang/en.json b/packages/editor/lang/en.json index dabfdf82..304c992d 100644 --- a/packages/editor/lang/en.json +++ b/packages/editor/lang/en.json @@ -62,6 +62,18 @@ "editor-panel.tooltip-add-topic": { "defaultMessage": "Add Topic" }, + "editor-panel.tooltip-connection-style": { + "defaultMessage": "Connection Style" + }, + "editor-panel.tooltip-connection-style-curved": { + "defaultMessage": "Curved" + }, + "editor-panel.tooltip-connection-style-polyline": { + "defaultMessage": "Polyline" + }, + "editor-panel.tooltip-connection-style-polyline-curved": { + "defaultMessage": "Curved Polyline" + }, "editor-panel.tooltip-delete-topic": { "defaultMessage": "Delete Topic" }, diff --git a/packages/editor/lang/es.json b/packages/editor/lang/es.json index c8a51130..1bd4083b 100644 --- a/packages/editor/lang/es.json +++ b/packages/editor/lang/es.json @@ -214,5 +214,17 @@ }, "icon-picker.show-images": { "defaultMessage": "Mostrar imagenes" + }, + "editor-panel.tooltip-connection-style": { + "defaultMessage": "Estilo de Connexión" + }, + "editor-panel.tooltip-connection-style-curved": { + "defaultMessage": "Curva" + }, + "editor-panel.tooltip-connection-style-polyline": { + "defaultMessage": "Polilinea" + }, + "editor-panel.tooltip-connection-style-polyline-curved": { + "defaultMessage": "Polilinea Curva" } } \ No newline at end of file diff --git a/packages/editor/lang/fr.json b/packages/editor/lang/fr.json index a825a154..db4f1f60 100644 --- a/packages/editor/lang/fr.json +++ b/packages/editor/lang/fr.json @@ -214,5 +214,17 @@ }, "icon-picker.show-images": { "defaultMessage": "Afficher les images" + }, + "editor-panel.tooltip-connection-style": { + "defaultMessage": "Style de connexion" + }, + "editor-panel.tooltip-connection-style-curved": { + "defaultMessage": "Courbe" + }, + "editor-panel.tooltip-connection-style-polyline": { + "defaultMessage": "Polyligne" + }, + "editor-panel.tooltip-connection-style-polyline-curved": { + "defaultMessage": "Polyligne courbe" } } \ No newline at end of file diff --git a/packages/editor/src/compiled-lang/de.json b/packages/editor/src/compiled-lang/de.json index b6e4c908..a8716650 100644 --- a/packages/editor/src/compiled-lang/de.json +++ b/packages/editor/src/compiled-lang/de.json @@ -131,6 +131,30 @@ "value": "Thema hinzufügen" } ], + "editor-panel.tooltip-connection-style": [ + { + "type": 0, + "value": "Verbindungsstil" + } + ], + "editor-panel.tooltip-connection-style-curved": [ + { + "type": 0, + "value": "Kurve" + } + ], + "editor-panel.tooltip-connection-style-polyline": [ + { + "type": 0, + "value": "Polylinie" + } + ], + "editor-panel.tooltip-connection-style-polyline-curved": [ + { + "type": 0, + "value": "Gekrümmte Polylinie" + } + ], "editor-panel.tooltip-delete-topic": [ { "type": 0, diff --git a/packages/editor/src/compiled-lang/en.json b/packages/editor/src/compiled-lang/en.json index b5578df4..5b471e42 100644 --- a/packages/editor/src/compiled-lang/en.json +++ b/packages/editor/src/compiled-lang/en.json @@ -125,6 +125,30 @@ "value": "Add Topic" } ], + "editor-panel.tooltip-connection-style": [ + { + "type": 0, + "value": "Connection Style" + } + ], + "editor-panel.tooltip-connection-style-curved": [ + { + "type": 0, + "value": "Curved" + } + ], + "editor-panel.tooltip-connection-style-polyline": [ + { + "type": 0, + "value": "Polyline" + } + ], + "editor-panel.tooltip-connection-style-polyline-curved": [ + { + "type": 0, + "value": "Curved Polyline" + } + ], "editor-panel.tooltip-delete-topic": [ { "type": 0, diff --git a/packages/editor/src/compiled-lang/es.json b/packages/editor/src/compiled-lang/es.json index bf33cf0d..119949a0 100644 --- a/packages/editor/src/compiled-lang/es.json +++ b/packages/editor/src/compiled-lang/es.json @@ -125,6 +125,30 @@ "value": "Agregar tópico" } ], + "editor-panel.tooltip-connection-style": [ + { + "type": 0, + "value": "Estilo de Connexión" + } + ], + "editor-panel.tooltip-connection-style-curved": [ + { + "type": 0, + "value": "Curva" + } + ], + "editor-panel.tooltip-connection-style-polyline": [ + { + "type": 0, + "value": "Polilinea" + } + ], + "editor-panel.tooltip-connection-style-polyline-curved": [ + { + "type": 0, + "value": "Polilinea Curva" + } + ], "editor-panel.tooltip-delete-topic": [ { "type": 0, diff --git a/packages/editor/src/compiled-lang/fr.json b/packages/editor/src/compiled-lang/fr.json index 00f6663a..7ca9c527 100644 --- a/packages/editor/src/compiled-lang/fr.json +++ b/packages/editor/src/compiled-lang/fr.json @@ -125,6 +125,30 @@ "value": "Agregar Topico" } ], + "editor-panel.tooltip-connection-style": [ + { + "type": 0, + "value": "Style de connexion" + } + ], + "editor-panel.tooltip-connection-style-curved": [ + { + "type": 0, + "value": "Courbe" + } + ], + "editor-panel.tooltip-connection-style-polyline": [ + { + "type": 0, + "value": "Polyligne" + } + ], + "editor-panel.tooltip-connection-style-polyline-curved": [ + { + "type": 0, + "value": "Polyligne courbe" + } + ], "editor-panel.tooltip-delete-topic": [ { "type": 0, diff --git a/packages/editor/src/components/editor-toolbar/configBuilder.tsx b/packages/editor/src/components/editor-toolbar/configBuilder.tsx index bde1c81d..2112afec 100644 --- a/packages/editor/src/components/editor-toolbar/configBuilder.tsx +++ b/packages/editor/src/components/editor-toolbar/configBuilder.tsx @@ -158,6 +158,15 @@ export function buildEditorPanelConfig(model: Editor, intl: IntlShape): ActionCo defaultMessage: 'Connection Style', }), options: [ + { + icon: , + tooltip: intl.formatMessage({ + id: 'editor-panel.tooltip-connection-style-curved', + defaultMessage: 'Curved', + }), + onClick: () => valueBulder.getConnectionStyleModel().setValue(LineType.SIMPLE_CURVED), + selected: () => valueBulder.getConnectionStyleModel().getValue() === LineType.SIMPLE_CURVED, + }, { icon: , tooltip: intl.formatMessage({ @@ -172,21 +181,12 @@ export function buildEditorPanelConfig(model: Editor, intl: IntlShape): ActionCo icon: , tooltip: intl.formatMessage({ id: 'editor-panel.tooltip-connection-style-polyline-curved', - defaultMessage: 'Polyline Curved', + defaultMessage: 'Curved Polyline', }), onClick: () => valueBulder.getConnectionStyleModel().setValue(LineType.POLYLINE_CURVED), selected: () => valueBulder.getConnectionStyleModel().getValue() === LineType.POLYLINE_CURVED, }, - { - icon: , - tooltip: intl.formatMessage({ - id: 'editor-panel.tooltip-connection-style-curved', - defaultMessage: 'Curved', - }), - onClick: () => valueBulder.getConnectionStyleModel().setValue(LineType.SIMPLE_CURVED), - selected: () => valueBulder.getConnectionStyleModel().getValue() === LineType.SIMPLE_CURVED, - }, ], disabled: () => model.getDesignerModel().filterSelectedTopics().length === 0, }; diff --git a/packages/mindplot/src/components/Designer.ts b/packages/mindplot/src/components/Designer.ts index b1d32a97..50d554fe 100644 --- a/packages/mindplot/src/components/Designer.ts +++ b/packages/mindplot/src/components/Designer.ts @@ -660,7 +660,7 @@ class Designer extends Events { this._workspace.append(result); children.forEach((child) => { - if ($defined(child)) { + if (child) { this.nodeModelToTopic(child); } }); @@ -690,10 +690,6 @@ class Designer extends Events { return result; } - /** - * @param {mindplot.model.RelationshipModel} model - * @return {mindplot.Relationship} the relationship added to the mindmap - */ addRelationship(model: RelationshipModel): Relationship { const mindmap = this.getMindmap(); mindmap.addRelationship(model); @@ -881,7 +877,7 @@ class Designer extends Events { changeConnectionStyle(type: LineType): void { const validateFunc = (topic: Topic) => !topic.isCentralTopic(); - const validateError = 'Central Topic can not be changed to line figure.'; + const validateError = 'Central topic connection style can not be changed for central topic.'; const topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError); if (topicsIds.length > 0) { this._actionDispatcher.changeConnectionStyleToTopic(topicsIds, type); diff --git a/packages/mindplot/src/components/Topic.ts b/packages/mindplot/src/components/Topic.ts index 00fb616b..fbc9e428 100644 --- a/packages/mindplot/src/components/Topic.ts +++ b/packages/mindplot/src/components/Topic.ts @@ -548,10 +548,17 @@ abstract class Topic extends NodeGraph { } setConnectionStyle(type: LineType): void { - this.getModel().setConnectionStyle(type); + const model = this.getModel(); + model.setConnectionStyle(type); // Needs to change change all the lines types. Outgoing are part of the children. this.getChildren().map((topic: Topic) => topic.redraw()); + + // If chidren nodes does not children, set the connection style too. We don't want to have cascade changes on all the branches. + model + .getChildren() + .filter((c) => c.getChildren().length === 0) + .forEach((c) => c.setConnectionStyle(type)); } private _setBackgroundColor(color: string, updateModel: boolean) { @@ -1157,7 +1164,6 @@ abstract class Topic extends NodeGraph { private createConnectionLine(targetTopic: Topic): ConnectionLine { const type: LineType = targetTopic.getConnectionStyle(); - console.log(`redraw ...: ${type}`); return new ConnectionLine(this, targetTopic, type); }