FirebaseTranslator
Stay organized with collections
Save and categorize content based on your preferences.
This class is deprecated.
The standalone ML Kit SDK replaces this API. For more information, refer to the migration guide.
Entry point for Translation.
This class can be used from any thread.
Public Method Summary
void |
close()
Closes the translator object and releases any system resources associated with
it.
|
Task<Void>
|
downloadModelIfNeeded()
Downloads the model files required for translation, if they are not already
present.
|
Task<Void>
|
|
Task<String>
|
translate( String input)
Translates the given input from the source language into the
target language.
|
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
From interface java.io.Closeable
From interface java.lang.AutoCloseable
Public Methods
public void close ()
Closes the translator object and releases any system resources associated with
it.
public Task<Void>
downloadModelIfNeeded ()
Downloads the model files required for translation, if they are not already present.
The download will be triggered as soon as there is a network connection, with no other
conditions.
Returns
- A
Task
that will be completed when the required files have been downloaded.
Downloads the model files required for translation, if they are not already present,
when the given conditions
are met.
Returns
- A
Task
that will be completed when the required files have been downloaded.
Translates the given input
from the source language into the target
language. Source and target languages are provided in the
options
object that was used to get the instance.
Parameters
input |
A string in the source language |
Returns
- The translated string in the target language
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-08-14 UTC.
[null,null,["Last updated 2020-08-14 UTC."],[],[],null,["# FirebaseTranslator\n\npublic class **FirebaseTranslator** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nimplements [Closeable](//developer.android.com/reference/java/io/Closeable.html) \n**This class is deprecated.** \n\nThe standalone ML Kit SDK replaces this API. For more information, refer to the [migration guide](//developers.google.com/ml-kit/migration).\n\nEntry point for Translation.\n\nThis class can be used from any thread. \n\n### Public Method Summary\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [close](/docs/reference/android/com/google/firebase/ml/naturallanguage/translate/FirebaseTranslator#close())() Closes the translator object and releases any system resources associated with it. |\n| [Task](//developers.google.com/android/reference/com/google/android/gms/tasks/Task.html)\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [downloadModelIfNeeded](/docs/reference/android/com/google/firebase/ml/naturallanguage/translate/FirebaseTranslator#downloadModelIfNeeded())() Downloads the model files required for translation, if they are not already present. |\n| [Task](//developers.google.com/android/reference/com/google/android/gms/tasks/Task.html)\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [downloadModelIfNeeded](/docs/reference/android/com/google/firebase/ml/naturallanguage/translate/FirebaseTranslator#downloadModelIfNeeded(com.google.firebase.ml.common.modeldownload.FirebaseModelDownloadConditions))([FirebaseModelDownloadConditions](/docs/reference/android/com/google/firebase/ml/common/modeldownload/FirebaseModelDownloadConditions) conditions) Downloads the model files required for translation, if they are not already present, when the given `conditions` are met. |\n| [Task](//developers.google.com/android/reference/com/google/android/gms/tasks/Task.html)\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e | [translate](/docs/reference/android/com/google/firebase/ml/naturallanguage/translate/FirebaseTranslator#translate(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) input) Translates the given `input` from the source language into the target language. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFrom interface java.io.Closeable \n\n|---------------|---------|\n| abstract void | close() |\n\nFrom interface java.lang.AutoCloseable \n\n|---------------|---------|\n| abstract void | close() |\n\nPublic Methods\n--------------\n\n#### public void **close** ()\n\nCloses the translator object and releases any system resources associated with\nit. \n\n#### public [Task](//developers.google.com/android/reference/com/google/android/gms/tasks/Task.html)\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e\n**downloadModelIfNeeded** ()\n\nDownloads the model files required for translation, if they are not already present.\nThe download will be triggered as soon as there is a network connection, with no other\nconditions. \n\n##### Returns\n\n- A [Task](//developers.google.com/android/reference/com/google/android/gms/tasks/Task.html) that will be completed when the required files have been downloaded. \n\n#### public [Task](//developers.google.com/android/reference/com/google/android/gms/tasks/Task.html)\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e\n**downloadModelIfNeeded** ([FirebaseModelDownloadConditions](/docs/reference/android/com/google/firebase/ml/common/modeldownload/FirebaseModelDownloadConditions) conditions)\n\nDownloads the model files required for translation, if they are not already present,\nwhen the given `conditions` are met. \n\n##### Returns\n\n- A [Task](//developers.google.com/android/reference/com/google/android/gms/tasks/Task.html) that will be completed when the required files have been downloaded. \n\n#### public [Task](//developers.google.com/android/reference/com/google/android/gms/tasks/Task.html)\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e\n**translate** ([String](//developer.android.com/reference/java/lang/String.html) input)\n\nTranslates the given `input` from the source language into the target\nlanguage. Source and target languages are provided in the [options](/docs/reference/android/com/google/firebase/ml/naturallanguage/translate/FirebaseTranslatorOptions) object that was used to get the instance. \n\n##### Parameters\n\n| input | A string in the source language |\n|-------|---------------------------------|\n\n##### Returns\n\n- The translated string in the target language"]]