Skip to content

Commit

Permalink
Updated for release 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rmraya committed Mar 19, 2024
1 parent 4ef1f70 commit c04addb
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 39 deletions.
23 changes: 21 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,30 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="jars/sqlite-jdbc-3.43.0.0.jar">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="jars/bcp47j.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="jars/slf4j-api-2.0.9.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="jars/slf4j-nop-2.0.9.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="jars/sqlite-jdbc-3.45.1.0.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="out"/>
</classpath>
18 changes: 10 additions & 8 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
<property name="source" value="21"/>
<property name="build.compiler" value="javac10+"/>
<path id="Swordfish.classpath">
<pathelement location="jars/dtd.jar"/>
<pathelement location="jars/json.jar"/>
<pathelement location="jars/jsoup.jar"/>
<pathelement location="jars/mapdb.jar"/>
<pathelement location="jars/openxliff.jar"/>
<pathelement location="jars/xmljava.jar"/>
<pathelement location="jars/h2-1.4.200.jar"/>
<pathelement location="jars/sqlite-jdbc-3.43.0.0.jar"/>
<pathelement location="jars/bcp47j.jar" />
<pathelement location="jars/dtd.jar" />
<pathelement location="jars/json.jar" />
<pathelement location="jars/jsoup.jar" />
<pathelement location="jars/mapdb.jar" />
<pathelement location="jars/openxliff.jar" />
<pathelement location="jars/xmljava.jar" />
<pathelement location="jars/slf4j-api-2.0.9.jar" />
<pathelement location="jars/slf4j-nop-2.0.9.jar" />
<pathelement location="jars/sqlite-jdbc-3.45.1.0.jar" />
</path>
<condition property="isWindows">
<os family="windows"/>
Expand Down
Binary file added jars/bcp47j.jar
Binary file not shown.
Binary file modified jars/openxliff.jar
Binary file not shown.
Binary file added jars/slf4j-api-2.0.9.jar
Binary file not shown.
Binary file added jars/slf4j-nop-2.0.9.jar
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swordfish",
"productName": "Swordfish",
"version": "5.0.2",
"version": "5.1.0",
"description": "Swordfish Translation Editor",
"main": "js/Swordfish.js",
"scripts": {
Expand All @@ -20,8 +20,8 @@
"url": "https://github.com/rmraya/Swordfish.git"
},
"devDependencies": {
"electron": "^29.1.0",
"typescript": "^5.3.3"
"electron": "^29.1.4",
"typescript": "^5.4.2"
},
"dependencies": {
"mtengines": "^1.3.3",
Expand Down
4 changes: 2 additions & 2 deletions src/com/maxprograms/swordfish/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ private Constants() {
}

public static final String APPNAME = "Swordfish";
public static final String VERSION = "5.0.2";
public static final String BUILD = "20240303_1649";
public static final String VERSION = "5.1.0";
public static final String BUILD = "20240318_1046";

public static final String REASON = "reason";
public static final String STATUS = "status";
Expand Down
7 changes: 3 additions & 4 deletions src/com/maxprograms/swordfish/am/Term.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ public Term(JSONObject json) {

@Override
public boolean equals(Object o) {
if (!(o instanceof Term)) {
return false;
if (o instanceof Term t) {
return t.getSource().equals(source) && t.getTarget().equals(target);
}
Term t = (Term) o;
return t.getSource().equals(source) && t.getTarget().equals(target);
return false;
}

@Override
Expand Down
7 changes: 3 additions & 4 deletions src/com/maxprograms/swordfish/models/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,10 @@ public int compareTo(Project o) {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Project)) {
return false;
if (obj instanceof Project p) {
return id.equals(p.getId());
}
Project p = (Project) obj;
return id.equals(p.getId());
return false;
}

@Override
Expand Down
7 changes: 3 additions & 4 deletions src/com/maxprograms/swordfish/models/SourceFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ public int compareTo(SourceFile o) {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof SourceFile)) {
return false;
if (obj instanceof SourceFile s) {
return file.equals(s.getFile()) && type.equals(s.getType()) && encoding.equals(s.getEncoding());
}
SourceFile s = (SourceFile) obj;
return file.equals(s.getFile()) && type.equals(s.getType()) && encoding.equals(s.getEncoding());
return false;
}

@Override
Expand Down
52 changes: 48 additions & 4 deletions src/com/maxprograms/swordfish/tbx/Tbx2Tmx.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import com.maxprograms.swordfish.Constants;
import com.maxprograms.swordfish.TmsServer;
import com.maxprograms.xml.Catalog;
Expand All @@ -30,30 +33,30 @@
import com.maxprograms.xml.XMLNode;
import com.maxprograms.xml.XMLOutputter;

import org.xml.sax.SAXException;

public class Tbx2Tmx {

private Document tmx;
private Element tmxRoot;
private Element header;
private Element body;
private Element currentTU;
private Element currentTUV;
private String currentLang;
private Element currentSeg;
private boolean inTUV;
private List<Element> tuvNotes;

private Tbx2Tmx() {
tmx = new Document(null, "tmx", "-//LISA OSCAR:1998//DTD for Translation Memory eXchange//EN", "tmx14.dtd");
tmxRoot = tmx.getRootElement();
tmxRoot.setAttribute("version", "1.4");
Element header = new Element("header");
header = new Element("header");
header.setAttribute("creationtool", Constants.APPNAME);
header.setAttribute("creationtoolversion", Constants.VERSION);
header.setAttribute("srclang", "*all*");
header.setAttribute("adminlang", "en");
header.setAttribute("datatype", "xml");
header.setAttribute("o-tmf", "unknown");
header.setAttribute("o-tmf", "TBX");
header.setAttribute("segtype", "block");
tmxRoot.addContent(header);
body = new Element("body");
Expand Down Expand Up @@ -81,17 +84,38 @@ private void export(String file) throws IOException {
}

private void recurse(Element e) throws IOException {
if ("tbx".equals(e.getName()) && e.hasAttribute("xml:lang")) {
header.setAttribute("srclang", e.getAttributeValue("xml:lang"));
}
if ("sourceDesc".equals(e.getName()) || "publicationStmt".equals(e.getName())) {
String[] notes = getHeaderNotes(e);
for (String note : notes) {
Element noteElement = new Element("note");
noteElement.setText(note);
header.addContent(noteElement);
}
}
if ("termEntry".equals(e.getName()) || "conceptEntry".equals(e.getName())) {
currentTU = new Element("tu");
if (e.hasAttribute("id")) {
currentTU.setAttribute("tuid", e.getAttributeValue("id"));
}
body.addContent(currentTU);
inTUV = false;
}
if ("langSet".equals(e.getName()) || "langSec".equals(e.getName())) {
currentLang = e.getAttributeValue("xml:lang");
tuvNotes = new Vector<>();
}
if ("tig".equals(e.getName()) || "termGrp".equals(e.getName()) || "termSec".equals(e.getName())) {
currentTUV = new Element("tuv");
currentTUV.setAttribute("xml:lang", currentLang);
currentTU.addContent(currentTUV);
if (!this.tuvNotes.isEmpty()) {
for (Element note : tuvNotes) {
currentTUV.addContent(note);
}
}
inTUV = true;
}
if ("term".equals(e.getName())) {
Expand All @@ -110,6 +134,15 @@ private void recurse(Element e) throws IOException {
}
return;
}
if ("descrip".equals(e.getName())) {
Element note = new Element("note");
note.setText(e.getText());
if (inTUV) {
tuvNotes.add(note);
} else {
currentTU.addContent(note);
}
}
if ("termNote".equals(e.getName())) {
String type = e.getAttributeValue("type");
if (!type.isBlank()) {
Expand Down Expand Up @@ -151,4 +184,15 @@ private void recurse(Element e) throws IOException {
inTUV = false;
}
}

private String[] getHeaderNotes(Element e) {
List<String> notes = new Vector<>();
List<Element> children = e.getChildren();
for (Element element : children) {
if ("p".equals(element.getName())) {
notes.add(element.getText());
}
}
return notes.toArray(new String[notes.size()]);
}
}
9 changes: 4 additions & 5 deletions src/com/maxprograms/swordfish/tm/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,11 @@ private long getCreationDate() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Match)) {
return false;
if (obj instanceof Match m) {
return source.equals(m.getSource()) && target.equals(m.getTarget()) && similarity == m.getSimilarity()
&& origin.equals(m.getOrigin()) && properties.equals(m.getProperties());
}
Match m = (Match) obj;
return source.equals(m.getSource()) && target.equals(m.getTarget()) && similarity == m.getSimilarity()
&& origin.equals(m.getOrigin()) && properties.equals(m.getProperties());
return false;
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/com/maxprograms/swordfish/xliff/XliffStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,9 @@ private String addHtmlTags(Element seg, JSONObject originalData) throws IOExcept
String key = e.getName() + e.getAttributeValue("id");
if (!tagsMap.containsKey(key)) {
String dataRef = e.getAttributeValue("dataRef");
if (dataRef.isEmpty()) {
dataRef = e.getAttributeValue("id");
}
XliffUtils.checkSVG(tag);
StringBuilder sb = new StringBuilder();
sb.append("<img data-ref='");
Expand Down
6 changes: 3 additions & 3 deletions src/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007-2022 Maxprograms.
* Copyright (c) 2007 - 2024 Maxprograms.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 1.0 which accompanies this distribution,
Expand All @@ -24,9 +24,9 @@
requires java.xml;
requires java.sql;
requires java.net.http;
requires jdk.security.auth;
requires jdk.crypto.cryptoki;
requires transitive javabcp47;
requires transitive openxliff;
requires transitive xmljava;
requires transitive jdk.httpserver;
requires transitive json;
requires java.logging;
Expand Down

0 comments on commit c04addb

Please sign in to comment.