Skip to content

Commit

Permalink
fixed an issue in the multilingual user text parser
Browse files Browse the repository at this point in the history
  • Loading branch information
hneemann committed Jan 24, 2021
1 parent 8990a72 commit cbba48e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/main/java/de/neemann/digital/draw/shapes/TextShape.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,20 @@
public class TextShape implements Shape {
private final String text;
private final int fontSize;
private Orientation orientation;
private final Orientation orientation;

/**
* Create a new instance
* Creates a new instance
*
* @param attr attributes
* @param inputs the inputs
* @param outputs the outputs
*/
public TextShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
String text = attr.get(Keys.DESCRIPTION);
if (text.length() == 0) {
String gen = attr.get(Keys.GENERIC);
if (gen.isEmpty())
text = Lang.get("elem_Text");
else
text = gen.replace(" ", "\u00A0");
}
this.text = Lang.evalMultilingualContent(text);
String text = Lang.evalMultilingualContent(attr.get(Keys.DESCRIPTION));
if (text.isEmpty())
text = Lang.get("elem_Text");
this.text = text;

fontSize = attr.get(Keys.FONT_SIZE);
orientation = attr.get(Keys.TEXT_ORIENTATION);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/neemann/digital/lang/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ static String evalMultilingualContent(String text, Language currentLanguage) {
String l = text.substring(pos + 2, pos + 4);
if (l.equalsIgnoreCase(currentLanguage.getName()))
return text.substring(pos + 4, p2).trim();
if (l.equalsIgnoreCase("en") && def.isEmpty())
def = text.substring(pos + 4, p2).trim();

pos = text.indexOf("{{", p2);
} else
Expand Down

0 comments on commit cbba48e

Please sign in to comment.