-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit e14baa3.
- Loading branch information
Showing
137 changed files
with
5,429 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test/** linguist-vendored | ||
|
||
build_dita2translate_template.xml linguist-language=Ant-Build-System | ||
src/main/resources/fox/jason/translate/antlib.xml linguist-language=Ant-Build-System |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: CI | ||
'on': | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
sonarcloud: | ||
name: SonarCloud Scan | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
- name: Use Java 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'zulu' | ||
- name: SonarCloud Scan | ||
uses: jason-fox/sonarcloud-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_CLOUD_LOGIN: ${{ secrets.SONAR_CLOUD_LOGIN }} | ||
|
||
unit-test: | ||
name: Unit Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
- name: Run DITA-OT Unit Test | ||
uses: jason-fox/dita-unit-test-action@master | ||
with: | ||
dita-ot-version: '4.0' | ||
plugin: 'fox.jason.translate.xliff' | ||
env: | ||
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }} | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: test-results | ||
path: test-results.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
**/out/** | ||
**/temp/** | ||
**/tmp/** | ||
build_dita2translate.xml | ||
|
||
**/test/add-translations1/translate.xlf | ||
**/test/approved-translations1/test.properties | ||
**/test/add-translations2/translate.xlf | ||
**/test/approved-translations2/test.properties | ||
|
||
.scannerwork/ | ||
|
||
target/ | ||
classes/ | ||
lib/ant-*.jar | ||
lib/ant-launcher-*.jar | ||
|
||
*~ | ||
.fuse_hidden* | ||
.directory | ||
.Trash-* | ||
.nfs* | ||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
Icon | ||
._* | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>fox.jason</groupId> | ||
<artifactId>translate</artifactId> | ||
<version>1.2</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.ant</groupId> | ||
<artifactId>ant</artifactId> | ||
<version>[1.10.9,)</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.googlecode.json-simple</groupId> | ||
<artifactId>json-simple</artifactId> | ||
<version>1.1.1</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<properties> | ||
<sonar.projectKey>fox.jason.translate.xliff</sonar.projectKey> | ||
<sonar.organization>dita-ot-plugins</sonar.organization> | ||
<sonar.sources>cfg,src,Customization,xsl</sonar.sources> | ||
<sonar.java.binaries | ||
>target/classes/fox/jason/translate/tasks</sonar.java.binaries> | ||
<sonar.java.libraries>lib/*.jar</sonar.java.libraries> | ||
<sonar.test.exclusions>test</sonar.test.exclusions> | ||
<sonar.cpd.exclusions>src/fox/jason/translate/tasks/**</sonar.cpd.exclusions> | ||
<sonar.host.url>https://sonarcloud.io</sonar.host.url> | ||
<sonar.cobertura.reportPath>coverage.xml</sonar.cobertura.reportPath> | ||
<sonar.exclusions | ||
>coverage.html,test-results.html,pom.xml,coverage.xml</sonar.exclusions> | ||
</properties> | ||
|
||
<build> | ||
<sourceDirectory>src</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<filesets> | ||
<fileset> | ||
<directory>lib</directory> | ||
</fileset> | ||
</filesets> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- Copy the runtime dependencies to the lib folder. --> | ||
<plugin> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>3.6.0</version> | ||
<executions> | ||
<execution> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>copy-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${basedir}/lib</outputDirectory> | ||
<includeScope>runtime</includeScope> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.11.0</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
<compilerArgument>${compilerArgument}</compilerArgument> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<configuration> | ||
<outputDirectory>${basedir}/lib</outputDirectory> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.sonarsource.scanner.maven</groupId> | ||
<artifactId>sonar-maven-plugin</artifactId> | ||
<version>3.9.1.2184</version> | ||
<executions> | ||
<execution> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>sonar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* This file is part of the DITA-OT Translate Plug-in project. | ||
* See the accompanying LICENSE file for applicable licenses. | ||
*/ | ||
|
||
package fox.jason.translate.tasks; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.Task; | ||
import org.json.simple.JSONObject; | ||
import org.json.simple.JSONArray; | ||
import org.json.simple.parser.JSONParser; | ||
import org.json.simple.parser.ParseException; | ||
|
||
// Microsoft Translation. Copies text translated by Azure cloud services to a file | ||
// | ||
|
||
public class BingParseTask extends Task { | ||
|
||
private String text; | ||
private String outproperty; | ||
private JSONParser parser; | ||
|
||
/** | ||
* Creates a new <code>BingParseTask</code> instance. | ||
*/ | ||
public BingParseTask() { | ||
super(); | ||
this.text = null; | ||
this.outproperty = null; | ||
this.parser = new JSONParser(); | ||
} | ||
|
||
/** | ||
* Method setText. | ||
* | ||
* @param text String | ||
*/ | ||
public void setText(String text) { | ||
this.text = text; | ||
} | ||
|
||
/** | ||
* Method setOutproperty. | ||
* | ||
* @param outproperty String | ||
*/ | ||
public void setOutproperty(String outproperty) { | ||
this.outproperty = outproperty; | ||
} | ||
|
||
/** | ||
* Method execute. | ||
* | ||
* @throws BuildException if something goes wrong | ||
*/ | ||
@Override | ||
public void execute() { | ||
// @param text - The response from Microsoft Translate | ||
// @param outproperty - The property to output to | ||
if (this.text == null) { | ||
throw new BuildException("You must supply a response from Microsoft Translate"); | ||
} | ||
if (this.outproperty == null) { | ||
throw new BuildException("You must supply a property to output to"); | ||
} | ||
|
||
try { | ||
JSONArray json = (JSONArray) this.parser | ||
.parse(this.text); | ||
JSONArray translations = (JSONArray) ((JSONObject) json.get(0)).get("translations"); | ||
String trans = (String) ((JSONObject) translations.get(0)).get("text"); | ||
trans = trans.replaceAll("\\\\\"", "\""); | ||
trans = trans.replaceAll("class=\"notranslate\"", "translate=\"no\""); | ||
getProject().setProperty(this.outproperty, trans); | ||
} catch (ParseException e) { | ||
throw new BuildException("Unable to translate JSON", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* This file is part of the DITA-OT Translate Plug-in project. | ||
* See the accompanying LICENSE file for applicable licenses. | ||
*/ | ||
|
||
package fox.jason.translate.tasks; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.Task; | ||
import org.json.simple.JSONObject; | ||
import org.json.simple.JSONArray; | ||
import org.json.simple.parser.JSONParser; | ||
import org.json.simple.parser.ParseException; | ||
|
||
// Watson Translation. Parses the response and extracts the translated text | ||
// | ||
|
||
public class DeeplParseTask extends Task { | ||
|
||
private String text; | ||
private String outproperty; | ||
private JSONParser parser; | ||
|
||
/** | ||
* Creates a new <code>DeeplParseTask</code> instance. | ||
*/ | ||
public DeeplParseTask() { | ||
super(); | ||
this.text = null; | ||
this.outproperty = null; | ||
this.parser = new JSONParser(); | ||
} | ||
|
||
/** | ||
* Method setText. | ||
* | ||
* @param text String | ||
*/ | ||
public void setText(String text) { | ||
this.text = text; | ||
} | ||
|
||
/** | ||
* Method setOutproperty. | ||
* | ||
* @param outproperty String | ||
*/ | ||
public void setOutproperty(String outproperty) { | ||
this.outproperty = outproperty; | ||
} | ||
|
||
/** | ||
* Method execute. | ||
* | ||
* @throws BuildException if something goes wrong | ||
*/ | ||
@Override | ||
public void execute() { | ||
// @param text - The response from Deepl | ||
// @param outproperty - The property to output to | ||
if (this.text == null) { | ||
throw new BuildException("You must supply a response from Deepl"); | ||
} | ||
if (this.outproperty == null) { | ||
throw new BuildException("You must supply a property to output to"); | ||
} | ||
|
||
try { | ||
JSONObject json = (JSONObject) this.parser | ||
.parse(this.text); | ||
JSONArray translations = (JSONArray) json.get("translations"); | ||
String trans = (String) ((JSONObject) translations.get(0)).get("text"); | ||
trans = trans.replaceAll("\\\\\"", "\""); | ||
getProject().setProperty(this.outproperty, trans); | ||
} catch (ParseException e) { | ||
throw new BuildException("Unable to translate JSON", e); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.