diff --git a/pom.xml b/pom.xml index 0eb2c00..72a55cb 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 de.thm.mni.mote.mode MoDE - 0.6.7-SNAPSHOT + 0.6.8-SNAPSHOT jar diff --git a/src/main/java/de/thm/mni/mote/mode/modelica/MoClass.java b/src/main/java/de/thm/mni/mote/mode/modelica/MoClass.java index 8907913..07aa3ac 100644 --- a/src/main/java/de/thm/mni/mote/mode/modelica/MoClass.java +++ b/src/main/java/de/thm/mni/mote/mode/modelica/MoClass.java @@ -259,7 +259,7 @@ static MoClass parse(@NonNull OMCompiler omc, MoLater that) throws ParserExcepti break; } - if (tmp == null) throw new ParserException(tr("Error", "error.modelica.cant_parse", ci.getType())); + if (tmp == null) throw new ParserException(tr("Error", "error", "modelica.cant_parse", ci.getType())); tmp.parseExtra(omc); return tmp; diff --git a/src/main/java/de/thm/mni/mote/mode/modelica/MoContainer.java b/src/main/java/de/thm/mni/mote/mode/modelica/MoContainer.java index 3a89096..06fd239 100644 --- a/src/main/java/de/thm/mni/mote/mode/modelica/MoContainer.java +++ b/src/main/java/de/thm/mni/mote/mode/modelica/MoContainer.java @@ -115,7 +115,7 @@ public MoClass getElement() { try { this.element = MoClass.parse(omc, (MoLater) this.element); } catch (ParserException e) { - MessageBus.getInstance().send(new ErrorMessage(MoContainer.class, omc.getGroup(), new ParserException(tr("Error", "error.modelica.error_in", getSimpleName()), e))); + MessageBus.getInstance().send(new ErrorMessage(MoContainer.class, omc.getGroup(), new ParserException(tr("Error", "error", "modelica.error_in", getSimpleName()), e))); } } return this.element; diff --git a/src/main/java/de/thm/mni/mote/mode/omcactor/OMCompiler.java b/src/main/java/de/thm/mni/mote/mode/omcactor/OMCompiler.java index b569ca4..fab97b3 100644 --- a/src/main/java/de/thm/mni/mote/mode/omcactor/OMCompiler.java +++ b/src/main/java/de/thm/mni/mote/mode/omcactor/OMCompiler.java @@ -103,7 +103,7 @@ void addSystemLibraries(List libs) { void clearProject() throws ParserException { Result r = client.call("clear"); - if (!Boolean.parseBoolean(r.result)) throw new ParserException(tr("Error", "error.omcactor.cant_unload_project")); + if (!Boolean.parseBoolean(r.result)) throw new ParserException(tr("Error", "error", "omcactor.cant_unload_project")); this.getSystemLibraries().clear(); this.getProjectLibraries().clear(); project = null; @@ -111,9 +111,9 @@ void clearProject() throws ParserException { void setProject(Path f) throws ParserException { - if (project != null) throw new ParserException(tr("Error", "error.omcactor.project_already_set")); + if (project != null) throw new ParserException(tr("Error", "error", "omcactor.project_already_set")); Pair lib = loadProject(f); - if (lib == null) throw new ParserException(tr("Error", "error.omcactor.cant_load_project", f.getFileName())); + if (lib == null) throw new ParserException(tr("Error", "error", "omcactor.cant_load_project", f.getFileName())); this.project = lib; } @@ -125,7 +125,7 @@ void reloadProject() throws ParserException { if (r.error.isPresent()) { throw new ParserException(r.error.get()); } - throw new ParserException(tr("error", "error.omcactor.unknown_error")); + throw new ParserException(tr("Error", "error", "omcactor.unknown_error")); } } @@ -137,7 +137,7 @@ private Pair loadProject(Path f) throws ParserException { if (r.error.isPresent()) { throw new ParserException(r.error.get()); } - throw new ParserException(tr("error", "error.omcactor.unknown_error")); + throw new ParserException(tr("Error", "error", "omcactor.unknown_error")); } r = client.call("getLoadedLibraries"); diff --git a/src/main/java/de/thm/mni/mote/mode/uiactor/editor/elementmanager/elements/ManagedMoConnectorIconGroup.java b/src/main/java/de/thm/mni/mote/mode/uiactor/editor/elementmanager/elements/ManagedMoConnectorIconGroup.java index f7c4717..14ecea3 100644 --- a/src/main/java/de/thm/mni/mote/mode/uiactor/editor/elementmanager/elements/ManagedMoConnectorIconGroup.java +++ b/src/main/java/de/thm/mni/mote/mode/uiactor/editor/elementmanager/elements/ManagedMoConnectorIconGroup.java @@ -56,7 +56,7 @@ public ManagedMoConnectorIconGroup(MoVariableIconGroup moParent, MoVariable vari while (c.next()) { c.getAddedSubList().forEach(str -> { if (!entries.containsKey(str)) { - Label tmp = new Label(Translator.tr("Main", str)); + Label tmp = new Label(Translator.tr("MoDE", "main", str)); entries.put(str, tmp); ((Pane) errorPopOver.getContentNode()).getChildren().add(tmp); } diff --git a/src/main/java/de/thm/mni/mote/mode/uiactor/editor/elementmanager/elements/ManagedMoDiagramGroup.java b/src/main/java/de/thm/mni/mote/mode/uiactor/editor/elementmanager/elements/ManagedMoDiagramGroup.java index ccf49bc..531e9f5 100644 --- a/src/main/java/de/thm/mni/mote/mode/uiactor/editor/elementmanager/elements/ManagedMoDiagramGroup.java +++ b/src/main/java/de/thm/mni/mote/mode/uiactor/editor/elementmanager/elements/ManagedMoDiagramGroup.java @@ -61,7 +61,7 @@ private List getConnectableToMessages(MoVariable from, MoVariable to) { private List getConnectableToMessages(MoVariable from, MoVariable to, boolean compare) { if (compare) { - if (!from.getName().equals(to.getName())) return Collections.singletonList("editor.connectors.no_matching_name"); + if (!from.getName().equals(to.getName())) return Collections.singletonList("editor.connectors.no_matching_name|" + from.getName()); if (from.getKind().equals(MoVariable.Specification.FLOW) && !from.getKind().equals(to.getKind())) return Collections.singletonList("editor.connectors.no_matching_modifier"); if (from.getKind().equals(MoVariable.Specification.INPUT) && !to.getKind().equals(MoVariable.Specification.OUTPUT)) return Collections.singletonList("editor.connectors.no_matching_modifier"); if (from.getKind().equals(MoVariable.Specification.OUTPUT) && !to.getKind().equals(MoVariable.Specification.INPUT)) return Collections.singletonList("editor.connectors.no_matching_modifier"); diff --git a/src/main/java/de/thm/mni/mote/mode/util/Translator.java b/src/main/java/de/thm/mni/mote/mode/util/Translator.java index 5693775..ac37c2b 100644 --- a/src/main/java/de/thm/mni/mote/mode/util/Translator.java +++ b/src/main/java/de/thm/mni/mote/mode/util/Translator.java @@ -1,7 +1,5 @@ package de.thm.mni.mote.mode.util; -import lombok.NonNull; - import java.text.MessageFormat; import java.util.*; @@ -19,47 +17,36 @@ public static ResourceBundle getBundle(String bundle) { } public static String tr(String bundle, String key) { - return tr(getBundle(bundle), key); + return tr(getBundle(bundle), "", key); } public static String tr(String bundle, String group, String key) { if (bundle == null) bundle = "MoDE"; - return tr(getBundle(bundle), group.toLowerCase() + "." + key); - } - - public static String tr(@NonNull ResourceBundle bundle, String key) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } + String[] keyWithParams = key.split("\\|"); + key = keyWithParams[0]; + Object[] params = new String[0]; + if (keyWithParams.length > 1) + params = Arrays.copyOfRange(keyWithParams, 1, keyWithParams.length); + return tr(getBundle(bundle), group, key, params); + } - - public static String tr(String bundle, String key, Object... params) { - return tr(getBundle(bundle), key, params); + public static String tr(String bundle, String group, String key, Object... params) { + return tr(getBundle(bundle), group, key, params); } public static String tr(ResourceBundle bundle, String key, Object... params) { - try { - return MessageFormat.format(bundle.getString(key), params); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - - public static String tr(String bundle, String key, Integer splitAt, Object... params) { - return tr(getBundle(bundle), key, splitAt, params); + return tr(bundle, "", key, params); } - public static String tr(ResourceBundle bundle, String key, Integer splitAt, Object... params) { + public static String tr(ResourceBundle bundle, String group, String key, Object... params) { + if (!group.isEmpty()) key = group.toLowerCase() + "." + key; try { - Object[] p1 = Arrays.copyOfRange(params, 0, splitAt); - Object[] p2 = Arrays.copyOfRange(params, splitAt, params.length); - String k1 = key.split("|")[0]; - String k2 = key.split("|")[1]; - return MessageFormat.format(bundle.getString(k1), p1) + "|" + MessageFormat.format(bundle.getString(k2), p2); + if (params.length == 0) + return bundle.getString(key); + else + return MessageFormat.format(bundle.getString(key), params); } catch (MissingResourceException e) { return '!' + key + '!'; } diff --git a/src/main/resources/de/thm/mni/mote/mode/i18n/MoDE.properties b/src/main/resources/de/thm/mni/mote/mode/i18n/MoDE.properties index 11979a3..9cf6512 100644 --- a/src/main/resources/de/thm/mni/mote/mode/i18n/MoDE.properties +++ b/src/main/resources/de/thm/mni/mote/mode/i18n/MoDE.properties @@ -58,3 +58,9 @@ settings.logger.select_level=Loglevel: file.all_supported=All Supported Files file.mode_project=MoDE Project File file.modelica=Modelica File +#main +main.editor.connectors.already_connected=Already Connected! +main.editor.connectors.no_matching_name=No Variable with name {0} found! +main.editor.connectors.no_matching_type=Type of variables {0} und {1} not matching! +main.editor.connectors.no_matching_variable_count=Count of variables not matching! +main.editor.connectors.no_matching_modifier=Variable modifier not matching! diff --git a/src/main/resources/de/thm/mni/mote/mode/i18n/MoDE_de.properties b/src/main/resources/de/thm/mni/mote/mode/i18n/MoDE_de.properties index 30fc645..0108e7d 100644 --- a/src/main/resources/de/thm/mni/mote/mode/i18n/MoDE_de.properties +++ b/src/main/resources/de/thm/mni/mote/mode/i18n/MoDE_de.properties @@ -34,3 +34,9 @@ settings.global.select_modelica_compiler.popover=Klicke hier um den OMC auszuwä settings.notify.select_level=Benachrichtigungslevel: settings.notify.select_seconds=Benachrichtigungsdauer: settings.logger.select_level=Loglevel: +#main +main.editor.connectors.already_connected=Schon verbunden! +main.editor.connectors.no_matching_name=Keine Variable mit dem Namen {0} vorhanden! +main.editor.connectors.no_matching_type=Typen der Variablen {0} und {1} passen nicht! +main.editor.connectors.no_matching_variable_count=Anzahl der Variablen passen nicht! +main.editor.connectors.no_matching_modifier=Variablemodifizierer passen nicht!