Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 797914f
Showing
18 changed files
with
1,988 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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry kind="src" path="src/main/test"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> | ||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
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,2 @@ | ||
.settings/ | ||
target/ |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>google-api-translate-java</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.maven.ide.eclipse.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.maven.ide.eclipse.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
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,27 @@ | ||
Provides a simple, unofficial, Java client API for using Google Translate. | ||
|
||
Features: | ||
========= | ||
|
||
Small library size - less than 50Kb. | ||
|
||
Uses English as an intermediate language to attempt translations between language pairings that are unsupported directly by Google Translate. | ||
|
||
The jar is runnable and has a very lightweight GUI to demonstrate translation functionality. | ||
|
||
Quickstart: | ||
=========== | ||
|
||
import com.google.api.translate.Language; | ||
import com.google.api.translate.Translate; | ||
|
||
public class Main { | ||
public static void main(String[] args) throws Exception { | ||
// Set the HTTP referrer to your website address. | ||
Translate.setHttpReferrer(/* Enter the URL of your site here */); | ||
|
||
String translatedText = Translate.execute("Bonjour le monde", Language.FRENCH, Language.ENGLISH); | ||
|
||
System.out.println(translatedText); | ||
} | ||
} |
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,100 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
This configuration file was written by the eclipse-cs plugin configuration editor | ||
--> | ||
<!-- | ||
Checkstyle-Configuration: Quative Settings | ||
Description: | ||
--> | ||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> | ||
<module name="Checker"> | ||
<property name="severity" value="warning"/> | ||
<module name="TreeWalker"> | ||
<module name="FileContentsHolder"/> | ||
<module name="JavadocMethod"/> | ||
<module name="JavadocType"/> | ||
<module name="JavadocVariable"/> | ||
<module name="JavadocStyle"/> | ||
<module name="ConstantName"/> | ||
<module name="LocalFinalVariableName"/> | ||
<module name="LocalVariableName"/> | ||
<module name="MemberName"/> | ||
<module name="MethodName"/> | ||
<module name="PackageName"/> | ||
<module name="ParameterName"/> | ||
<module name="StaticVariableName"/> | ||
<module name="TypeName"/> | ||
<module name="AvoidStarImport"/> | ||
<module name="IllegalImport"/> | ||
<module name="RedundantImport"/> | ||
<module name="UnusedImports"/> | ||
<module name="FileLength"/> | ||
<module name="LineLength"> | ||
<property name="max" value="120"/> | ||
</module> | ||
<module name="MethodLength"/> | ||
<module name="ParameterNumber"/> | ||
<module name="EmptyForIteratorPad"/> | ||
<module name="MethodParamPad"/> | ||
<module name="NoWhitespaceAfter"/> | ||
<module name="NoWhitespaceBefore"/> | ||
<module name="OperatorWrap"/> | ||
<module name="ParenPad"/> | ||
<module name="TypecastParenPad"/> | ||
<!-- <module name="TabCharacter"/> --> | ||
<module name="WhitespaceAfter"/> | ||
<module name="WhitespaceAround"> | ||
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Removed generic types args spaces as looks untidy."/> | ||
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND,WILDCARD_TYPE"/> | ||
</module> | ||
<module name="ModifierOrder"/> | ||
<module name="RedundantModifier"/> | ||
<module name="AvoidNestedBlocks"/> | ||
<module name="EmptyBlock"/> | ||
<module name="LeftCurly"/> | ||
<module name="NeedBraces"/> | ||
<module name="RightCurly"/> | ||
<module name="AvoidInlineConditionals"> | ||
<property name="severity" value="ignore"/> | ||
</module> | ||
<module name="DoubleCheckedLocking"/> | ||
<module name="EmptyStatement"/> | ||
<module name="EqualsHashCode"/> | ||
<module name="HiddenField"/> | ||
<module name="IllegalInstantiation"/> | ||
<module name="InnerAssignment"/> | ||
<module name="MagicNumber"/> | ||
<module name="MissingSwitchDefault"/> | ||
<module name="RedundantThrows"/> | ||
<module name="SimplifyBooleanExpression"/> | ||
<module name="SimplifyBooleanReturn"/> | ||
<module name="DesignForExtension"> | ||
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Services must not have annotated methods which are final. This causes problems with Spring proxying."/> | ||
<property name="severity" value="info"/> | ||
</module> | ||
<module name="FinalClass"/> | ||
<module name="HideUtilityClassConstructor"/> | ||
<module name="InterfaceIsType"/> | ||
<module name="VisibilityModifier"/> | ||
<module name="ArrayTypeStyle"/> | ||
<module name="FinalParameters"/> | ||
<module name="GenericIllegalRegexp"> | ||
<property name="severity" value="ignore"/> | ||
<property name="format" value="\s+$"/> | ||
<property name="message" value="Line has trailing spaces."/> | ||
</module> | ||
<module name="TodoComment"/> | ||
<module name="UpperEll"/> | ||
</module> | ||
<module name="PackageHtml"/> | ||
<module name="NewlineAtEndOfFile"> | ||
<property name="severity" value="ignore"/> | ||
</module> | ||
<module name="Translation"/> | ||
<module name="SuppressionCommentFilter"> | ||
<property name="offCommentFormat" value="CHECKSTYLE OFF\: ([\w\|]+)"/> | ||
<property name="onCommentFormat" value="CHECKSTYLE ON\: ([\w\|]+)"/> | ||
<property name="checkFormat" value="$1"/> | ||
</module> | ||
</module> |
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,39 @@ | ||
<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>com.google.api</groupId> | ||
<artifactId>google-api-translate-java</artifactId> | ||
<version>0.93-SNAPSHOT</version> | ||
<name>google-api-translate-java</name> | ||
<description>A Java wrapper for the Google Translate service</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.json</groupId> | ||
<artifactId>json</artifactId> | ||
<version>20090211</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>com.google.api.translate.TranslatorFrame</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</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,66 @@ | ||
/** | ||
* Files.java | ||
* | ||
* Copyright (C) 2009, Richard Midwinter | ||
* | ||
* This file is part of google-api-translate-java. | ||
* | ||
* google-api-translate-java is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* google-api-translate-java is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with google-api-translate-java. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.google.api; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
public class Files { | ||
|
||
private Files() { | ||
} | ||
|
||
/** | ||
* Writes a String to a given file. | ||
* | ||
* @param file The file to write to. | ||
* @param content The text to write to the given file. | ||
* @throws IOException Thrown on IO errors. | ||
*/ | ||
public static void write(final File file, final String content) throws IOException { | ||
BufferedWriter bw = new BufferedWriter(new FileWriter(file)); | ||
bw.write(content); | ||
bw.close(); | ||
} | ||
|
||
/** | ||
* Reads a file to a String. | ||
* @param file The file to read from. | ||
* @return The content of the file as a String. | ||
* @throws IOException Thrown on IO errors. | ||
*/ | ||
public static String read(final File file) throws IOException { | ||
final StringBuilder sb = new StringBuilder(); | ||
String line; | ||
|
||
final BufferedReader br = new BufferedReader(new FileReader(file)); | ||
while ((line = br.readLine()) != null) { | ||
sb.append(line); | ||
sb.append('\n'); | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
} |
Oops, something went wrong.