C# Class Westwind.Globalization.TranslationServices

Provides basic translation features via several Web interfaces NOTE: These services may change their format or otherwise fail.
Mostrar archivo Open project: RickStrahl/Westwind.Globalization Class Usage Examples

Public Methods

Method Description
GetBingAuthToken ( string clientId = null, string clientSecret = null ) : string

Retrieves an oAuth authentication token to be used on the translate API request. The result string needs to be passed as a bearer token to the translate API. You can find client ID and Secret (or register a new one) at: https://datamarket.azure.com/developer/applications/

TranslateBing ( string text, string fromCulture, string toCulture, string accessToken = null ) : string

Uses the Bing API service to perform translation Bing can translate up to 1000 characters. Requires that you provide a CLientId and ClientSecret or set the configuration values for these two. More info on setup: http://weblog.west-wind.com/posts/2013/Jun/06/Setting-up-and-using-Bing-Translate-API-Service-for-Machine-Translation

TranslateGoogle ( string text, string fromCulture, string toCulture, string googleApiKey = null ) : string

Translates a string into another language using Google's translate API JSON calls. Class TranslationServices

TranslateGoogleApi ( string text, string fromCulture, string toCulture, string googleApiKey = null ) : string

Translates a string into another language using Google's translate API JSON calls. Class TranslationServices

Method Details

GetBingAuthToken() public method

Retrieves an oAuth authentication token to be used on the translate API request. The result string needs to be passed as a bearer token to the translate API. You can find client ID and Secret (or register a new one) at: https://datamarket.azure.com/developer/applications/
public GetBingAuthToken ( string clientId = null, string clientSecret = null ) : string
clientId string The client ID of your application
clientSecret string The client secret or password
return string

TranslateBing() public method

Uses the Bing API service to perform translation Bing can translate up to 1000 characters. Requires that you provide a CLientId and ClientSecret or set the configuration values for these two. More info on setup: http://weblog.west-wind.com/posts/2013/Jun/06/Setting-up-and-using-Bing-Translate-API-Service-for-Machine-Translation
public TranslateBing ( string text, string fromCulture, string toCulture, string accessToken = null ) : string
text string Text to translate
fromCulture string Two letter culture name
toCulture string Two letter culture name
accessToken string Pass an access token retrieved with GetBingAuthToken. /// If not passed the default keys from .config file are used if any
return string

TranslateGoogle() public method

Translates a string into another language using Google's translate API JSON calls. Class TranslationServices
public TranslateGoogle ( string text, string fromCulture, string toCulture, string googleApiKey = null ) : string
text string
fromCulture string
toCulture string
googleApiKey string Google Api key - if not specified it's read from the configuration
return string

TranslateGoogleApi() public method

Translates a string into another language using Google's translate API JSON calls. Class TranslationServices
public TranslateGoogleApi ( string text, string fromCulture, string toCulture, string googleApiKey = null ) : string
text string
fromCulture string
toCulture string
googleApiKey string Google Api key - if not specified it's read from the configuration
return string