Translation class
- Inheritance
-
- Object
- TranslateDataManage
- TranslateUtil
- Translation
Constructors
- Translation.new({required String apiKey, void onError(Object)?})
-
Provides an instance of this class.
The instance of the class created with this constructor will send the events on the fly.
Also, if a request returns an error, this will be logged but the text will be lost.
token
is the token associated with your project.onError
is a callback function that will be executed in case there is an error, otherwisedebugPrint
will be used.prefsKey
key to use in the SharedPreferences. If you leave it empty a default name will be used.
Properties
- apiKey → String
-
Returns the value of the token in google.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- http ↔ Client
-
We can inject the client required, useful for testing
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
translateResult
↔ RxMap<
String, Map< String, String> > -
The key is origin content.
and the value is the translated content with language.
getter/setter pairinherited
-
translatingMap
↔ RxMap<
String, TranslateStatus> -
The key is message ID.
getter/setter pairinherited
Methods
-
clear(
) → void -
Please call this after change language.
inherited
-
detectLang(
{required String text}) → Future< TranslationModel> -
Detects source lang.
text
text to detect. -
get(
String textMessage, {String? to}) → String -
Get translate result, if not contain will return the origin content.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setError(
String messageId) → void -
inherited
-
setOk(
{required String originContent, required String result, required String targetLanguage, required String messageId}) → String -
inherited
-
setTranslating(
String messageId) → void -
inherited
-
status(
String messageId) → TranslateStatus -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
translate(
{required String text, String? to}) → Future< TranslationModel> -
Sends a request to translate.
text
text to translate.to
to what language translate. -
translateWithCache(
String text, String messageId, {String? to, bool cache = true}) → Future< String?> -
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited