Translation
Stay organized with collections
Save and categorize content based on your preferences.
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()
|
Public Methods
Returns a new instance of Translator
that can translate from the source language to the target language (both specified in
options
).
To release the resources associated with a Translator, you need to ensure that
close()
is called on the resulting Translator
object once it will no longer be used.
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 2024-10-31 UTC.
[null,null,["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eTranslation\u003c/code\u003e class is the entry point for getting a \u003ccode\u003eTranslator\u003c/code\u003e object for language translation.\u003c/p\u003e\n"],["\u003cp\u003eYou can create a \u003ccode\u003eTranslator\u003c/code\u003e instance using the \u003ccode\u003egetClient()\u003c/code\u003e method with \u003ccode\u003eTranslatorOptions\u003c/code\u003e specifying the source and target languages.\u003c/p\u003e\n"],["\u003cp\u003eTo avoid resource leaks, call \u003ccode\u003eclose()\u003c/code\u003e on the \u003ccode\u003eTranslator\u003c/code\u003e object when it is no longer needed.\u003c/p\u003e\n"]]],["The `Translation` class provides a way to obtain a `Translator` instance for language translation. It extends the `Object` class. The key action is using the static `getClient` method, which takes `TranslatorOptions` as input, to create a new `Translator`. This `Translator` is configured to translate between the source and target languages defined within the provided `TranslatorOptions`. After the `Translator` object is no longer needed, it is important to use the `close()` method.\n"],null,["# Translation\n\npublic class **Translation** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nEntry point to get a [Translator](/android/reference/com/google/mlkit/nl/translate/Translator) for\ntranslating from the source language to the target language specified in [options](/android/reference/com/google/mlkit/nl/translate/TranslatorOptions).\n\nAn [Translator](/android/reference/com/google/mlkit/nl/translate/Translator) is\ncreated via [getClient(TranslatorOptions)](/android/reference/com/google/mlkit/nl/translate/Translation#getClient(com.google.mlkit.nl.translate.TranslatorOptions)).\n\nExample: \n\n Translator translator = Translation.getClient(options); \n\n### Public Method Summary\n\n|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [Translator](/android/reference/com/google/mlkit/nl/translate/Translator) | [getClient](/android/reference/com/google/mlkit/nl/translate/Translation#getClient(com.google.mlkit.nl.translate.TranslatorOptions))([TranslatorOptions](/android/reference/com/google/mlkit/nl/translate/TranslatorOptions) options) Returns a new instance of [Translator](/android/reference/com/google/mlkit/nl/translate/Translator) that can translate from the source language to the target language (both specified in [options](/android/reference/com/google/mlkit/nl/translate/TranslatorOptions)). |\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\nPublic Methods\n--------------\n\n#### public static [Translator](/android/reference/com/google/mlkit/nl/translate/Translator)\n**getClient** ([TranslatorOptions](/android/reference/com/google/mlkit/nl/translate/TranslatorOptions) options)\n\nReturns a new instance of [Translator](/android/reference/com/google/mlkit/nl/translate/Translator)\nthat can translate from the source language to the target language (both specified in\n[options](/android/reference/com/google/mlkit/nl/translate/TranslatorOptions)).\n\nTo release the resources associated with a Translator, you need to ensure that\n[close()](/android/reference/com/google/mlkit/nl/translate/Translator#close())\nis called on the resulting [Translator](/android/reference/com/google/mlkit/nl/translate/Translator)\nobject once it will no longer be used."]]