www.element4solution.com

e4s.translate
Class E4ExternalTranslation

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.translate.E4ExternalTranslation

public final class E4ExternalTranslation
extends E4Object

Embedd some external translation tool. The tool needs to understand the translation request using a URL connection, and the result must be embedded in either &tt;HTML> or <XML< output with a unique identification. This identification might be a sequence of HTML or XML tags. Beside this, the language codes (Language must match in lower case letters the languages provided. Additionally, some settings are required in your properties file (@link #externalTranslationPossible()}. Please note, that you might require some license agreement for the translation services embedded! This is not part of the e4s, and it depends on the tool and license you require.

Since:
JDK 1.4
See Also:
E4Label, Language

Field Summary
static java.lang.String SETTINGS_CREDITS
          Some external translation services are free, but they require the display of an logo.
static java.lang.String SETTINGS_RESULT_POSTFIX
          Definition for an external translation program result (ending with).
static java.lang.String SETTINGS_RESULT_PREFIX
          Definition for an external translation program result (beginning with).
static java.lang.String SETTINGS_URL_REQUEST_PATTERN
          Definition for an external translation program call.
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4ExternalTranslation()
           
 
Method Summary
static java.lang.String _getSVNVersionString()
          Get version info string from subversion.
static java.lang.String externalTranslation(java.lang.String txt, Language src_lan, Language dest_lan)
          Get an online translation from any external translation service, connected using a URL.
static boolean externalTranslationPossible()
          Test, if the necessary settings are contained in the property file.
static java.lang.String getCredits()
          Get external translation logo.
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, finalize, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, toString, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SETTINGS_URL_REQUEST_PATTERN

public static final java.lang.String SETTINGS_URL_REQUEST_PATTERN
Definition for an external translation program call. e.g. http://babelfish.altavista.com/tr?doit=done&intl=1&lp=<SLAN>_<DLAN>&tt=urltext&trtext=<TEXT> This is an URL string that must be defined in the systems property file (E4Settings), and the <SLAN> will be replaced using the source language, the <DLAN> will be replaced using the destination language and the <TEXT> tag will be replaced the text for translation in URL encoding. This setting is required.

See Also:
E4Settings, Language, E4ExternalTranslation(), SETTINGS_RESULT_PREFIX, SETTINGS_RESULT_POSTFIX, Constant Field Values

SETTINGS_RESULT_PREFIX

public static final java.lang.String SETTINGS_RESULT_PREFIX
Definition for an external translation program result (beginning with). e.g. <td bgcolor=white class=s><div style=padding:10px;> The results are read in by the external translation service program, the string afterward this definition will be extracted until SETTINGS_RESULT_POSTFIX. This setting is required.

See Also:
SETTINGS_URL_REQUEST_PATTERN, Constant Field Values

SETTINGS_RESULT_POSTFIX

public static final java.lang.String SETTINGS_RESULT_POSTFIX
Definition for an external translation program result (ending with). This setting is required. e.g. </div></td>

See Also:
SETTINGS_URL_REQUEST_PATTERN, Constant Field Values

SETTINGS_CREDITS

public static final java.lang.String SETTINGS_CREDITS
Some external translation services are free, but they require the display of an logo. You can define such a .gif or .jpg file here.

See Also:
getCredits(), Constant Field Values
Constructor Detail

E4ExternalTranslation

public E4ExternalTranslation()
Method Detail

externalTranslation

public static java.lang.String externalTranslation(java.lang.String txt,
                                                   Language src_lan,
                                                   Language dest_lan)
Get an online translation from any external translation service, connected using a URL. This requires the following parameters defined in your properties: SETTINGS_URL_REQUEST_PATTERN, SETTINGS_RESULT_PREFIX and SETTINGS_RESULT_POSTFIX.

Parameters:
txt - the text for translation
src_lan - the source language
dest_lan - the destination language
Returns:
null if translation fails for any reasons, or definitions are missing
See Also:
externalTranslationPossible()

externalTranslationPossible

public static boolean externalTranslationPossible()
Test, if the necessary settings are contained in the property file.

Returns:
true, if SETTINGS_URL_REQUEST_PATTERN, SETTINGS_RESULT_PREFIX and SETTINGS_RESULT_POSTFIX are defined in the E4Settings.
See Also:
E4ExternalTranslation()

getCredits

public static java.lang.String getCredits()
Get external translation logo.

Returns:
definition for SETTINGS_CREDITS

_getSVNVersionString

public static java.lang.String _getSVNVersionString()
Get version info string from subversion.

Returns:
the version info string.
See Also:
E4Util.getRevisionCodeFromSVN(Class)

www.element4solution.com