|
| 1 | +[](https://www.nuget.org/packages/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/) |
| 2 | + |
| 3 | +### Language Translator |
| 4 | + |
| 5 | +[Language Translator][language_translator] translates text from one language to another. The service offers multiple domain-specific models that you can customize based on your unique terminology and language. Use Language Translator to take news from across the globe and present it in your language, communicate with your customers in their own language, and more. |
| 6 | + |
| 7 | +### Installation |
| 8 | +#### Nuget |
| 9 | +``` |
| 10 | +
|
| 11 | +PM > Install-Package IBM.WatsonDeveloperCloud.LanguageTranslator.v3 |
| 12 | +
|
| 13 | +``` |
| 14 | +#### .csproj |
| 15 | +```xml |
| 16 | + |
| 17 | +<ItemGroup> |
| 18 | + <PackageReference Include="IBM.WatsonDeveloperCloud.LanguageTranslator.v3" Version="2.4.0" /> |
| 19 | +</ItemGroup> |
| 20 | + |
| 21 | +``` |
| 22 | +### Usage |
| 23 | +Select a domain, then identify or select the language of text, and then translate the text from one supported language to another. |
| 24 | + |
| 25 | +#### Instantiating and authenticating the service |
| 26 | +Before you can send requests to the service it must be instantiated and api key or access token must be set. |
| 27 | +```cs |
| 28 | +TokenOptions tokenOptions = new TokenOptions() |
| 29 | +{ |
| 30 | + IamApiKey = "<iam-apikey>", |
| 31 | + IamAccessToken = "<iam-access-token>", |
| 32 | + IamUrl = "<service-endpoint>" |
| 33 | +}; |
| 34 | + |
| 35 | +var _languageTranslator = new LanguageTranslator(tokenOptions, "<version-date>"); |
| 36 | +``` |
| 37 | + |
| 38 | +#### Translate |
| 39 | +Translates input text from the source language to the target language. |
| 40 | +```cs |
| 41 | +// Translate '"Hello! How are you?' from English to Portuguese using the Language Translator service |
| 42 | +var results = _languageTranslator.Translate("en", "pt", "Hello! How are you?"); |
| 43 | +``` |
| 44 | + |
| 45 | +#### Identifiable languages |
| 46 | +Return the list of languages it can detect. |
| 47 | +```cs |
| 48 | +// returns a list of identifiable languages |
| 49 | +var result = _languageTranslator.GetIdentifiableLanguages(); |
| 50 | +``` |
| 51 | + |
| 52 | +#### Identify language |
| 53 | +Identify the language in which a text is written. |
| 54 | +```cs |
| 55 | +// identifies the language of a body of text. |
| 56 | +var result = _languageTranslator.Identify("<text-to-identify>"); |
| 57 | +``` |
| 58 | + |
| 59 | +#### List models |
| 60 | +Lists available models for language translation with option to filter by source or by target language. |
| 61 | +```cs |
| 62 | +// lists all language models |
| 63 | +var result = _languageTranslator.ListModels(); |
| 64 | +``` |
| 65 | + |
| 66 | +<!-- #### Create a model |
| 67 | +Uploads a TMX glossary file on top of a domain to customize a translation model.Depending on the size of the file, training can range from minutes for a glossary to several hours for a large parallel corpus. Glossary files must be less than 10 MB. The cumulative file size of all uploaded glossary and corpus files is limited to 250 MB. |
| 68 | +```cs |
| 69 | +``` --> |
| 70 | + |
| 71 | +#### Delete a model |
| 72 | +Deletes trained translation models. |
| 73 | +```cs |
| 74 | +// deletes a custom languge model |
| 75 | +var result = _languageTranslator.DeleteModel("<custom-model-id>"); |
| 76 | +``` |
| 77 | + |
| 78 | +#### Get a model details |
| 79 | +Returns information, including training status, about a specified translation model. |
| 80 | +```cs |
| 81 | +// gets details of a particular model |
| 82 | +var result = _languageTranslator.GetModelDetails("<model-id>"); |
| 83 | +``` |
| 84 | + |
| 85 | +[language_translator]: https://console.bluemix.net/docs/services/language-translator/getting-started.html |
0 commit comments