Assets/Watson/Scripts/Services/LanguageTranslation/LanguageTranslation.cs
/// <summary>
/// Translate the provided text using the specified source and target.
/// </summary>
/// <param name="text">The text to translate.</param>
/// <param name="source">The ID of the source language.</param>
/// <param name="target">The ID of the target language.</param>
/// <param name="callback">The callback to receive the translated text.</param>
/// <returns>Returns true on success.</returns>
Translate the provided text using the specified source and target.
Translate the provided text using the specified source and target .
public bool GetTranslation(string text, string source, string target, TranslateCallback callback)
        {
            if (string.IsNullOrEmpty(text))
                throw new ArgumentNullException("text");
            if (string.IsNullOrEmpty(source))
                throw new ArgumentNullException("source");
            if (string.IsNullOrEmpty(target))
                throw new ArgumentNullException("target");
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["source"] = source;
            parameters["target"] = target;
            parameters["text"] = new string[] { text };
            return GetTranslation(Json.Serialize(parameters), callback);
        }
public bool GetTranslation ( string text , string source , string target , TranslateCallback callback ) { if ( string . IsNullOrEmpty ( text ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( source ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( target ) ) throw new ArgumentNullException ( " " ) ; Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ; parameters [ " " ] = source ; parameters [ " " ] = target ; parameters [ " " ] = new string [ ] { text } ; return GetTranslation ( Json . Serialize ( parameters ) , callback ) ; }
Translate the provided text using the specified source and target.
Translate the provided text using the specified source and target .
Returns true on success.
Returns true on success .
text
string
The text to translate.
The text to translate .
source
string
The ID of the source language.
The ID of the source language .
target
string
The ID of the target language.
The ID of the target language .
callback
TranslateCallback
The callback to receive the translated text.
The callback to receive the translated text .