public abstract class BaseTranslate extends java.lang.Object implements IMachineTranslation
Modifier and Type | Field and Description |
---|---|
protected boolean |
enabled |
protected IMTGlossarySupplier |
glossarySupplier |
Constructor and Description |
---|
BaseTranslate() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
cleanSpacesAroundTags(java.lang.String machineText,
java.lang.String sourceText)
Attempt to clean spaces added around tags by machine translators.
|
protected void |
clearCache()
Clear the machine translation cache.
|
java.lang.String |
getCachedTranslation(Language sLang,
Language tLang,
java.lang.String text)
Get cached translation.
|
protected java.lang.String |
getCredential(java.lang.String id)
Retrieve a credential with the given ID.
|
protected java.lang.String |
getFromCache(Language sLang,
Language tLang,
java.lang.String text) |
protected abstract java.lang.String |
getPreferenceName() |
java.lang.String |
getTranslation(Language sLang,
Language tLang,
java.lang.String text)
Translate.
|
protected boolean |
isCredentialStoredTemporarily(java.lang.String id)
Determine whether a credential has been stored "temporarily" according to the definition in
setCredential(String, String, boolean) . |
boolean |
isEnabled()
Determine whether or not the MT provider has been enabled by the user.
|
protected java.lang.String |
putToCache(Language sLang,
Language tLang,
java.lang.String text,
java.lang.String result) |
protected void |
setCredential(java.lang.String id,
java.lang.String value,
boolean temporary)
Store a credential.
|
void |
setEnabled(boolean enabled)
Turn the MT provider on or off
|
void |
setGlossarySupplier(IMTGlossarySupplier glossarySupplier)
Set a glossary supplier to provide relevant glossary terms if desired.
|
protected abstract java.lang.String |
translate(Language sLang,
Language tLang,
java.lang.String text) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, isConfigurable, showConfigurationUI
protected boolean enabled
protected IMTGlossarySupplier glossarySupplier
public boolean isEnabled()
IMachineTranslation
isEnabled
in interface IMachineTranslation
public void setEnabled(boolean enabled)
IMachineTranslation
setEnabled
in interface IMachineTranslation
public void setGlossarySupplier(IMTGlossarySupplier glossarySupplier)
IMachineTranslation
setGlossarySupplier
in interface IMachineTranslation
public java.lang.String getTranslation(Language sLang, Language tLang, java.lang.String text) throws java.lang.Exception
IMachineTranslation
getTranslation
in interface IMachineTranslation
sLang
- source languagetLang
- target languagetext
- text for translationjava.lang.Exception
public java.lang.String getCachedTranslation(Language sLang, Language tLang, java.lang.String text)
IMachineTranslation
getCachedTranslation
in interface IMachineTranslation
sLang
- source languagetLang
- target languagetext
- text for translationprotected abstract java.lang.String getPreferenceName()
protected abstract java.lang.String translate(Language sLang, Language tLang, java.lang.String text) throws java.lang.Exception
java.lang.Exception
protected java.lang.String cleanSpacesAroundTags(java.lang.String machineText, java.lang.String sourceText)
machineText
- The text returned by the machine translatorsourceText
- The original source segmentprotected java.lang.String getFromCache(Language sLang, Language tLang, java.lang.String text)
protected java.lang.String putToCache(Language sLang, Language tLang, java.lang.String text, java.lang.String result)
protected void clearCache()
protected java.lang.String getCredential(java.lang.String id)
setCredential(String, String, boolean)
.id
- ID or key of the credential to retrieveprotected void setCredential(java.lang.String id, java.lang.String value, boolean temporary)
temporary
is false
, in the program's persistent preferences encoded in
Base64. Retrieve a credential with getCredential(String)
.id
- ID or key of the credential to storevalue
- value of the credential to storetemporary
- if false
, encode with Base64 and store in persistent preferences as wellprotected boolean isCredentialStoredTemporarily(java.lang.String id)
setCredential(String, String, boolean)
. The result will be false
if the
credential is not stored at all, or if it is stored permanently.id
- ID or key of credentialtrue
only if the credential is stored temporarilysetCredential(String, String, boolean)
,
getCredential(String)