Skip to content

Commit 1d72b32

Browse files
committed
2 parents 5eb47fd + ac23958 commit 1d72b32

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

README.md

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# XLocalizer.Translate
2-
Translation abstractions extension pack for XLocalizer
2+
Auto translation support pack for [XLocalizer](https://github.com/LazZiya/XLocalizer)
33

44
## Install
55
Install from nuget:
@@ -17,19 +17,9 @@ PM > Install-Package XLocalizer.Translate.IBMWatsonTranslate
1717
````
1818

1919
## Usage
20-
The current package uses [RapidApi](https://rapidapi.com/collection/translation-apis) to access free translation services that dosen't require a credit card for subscription.
21-
So before using this package you will need create an application key in RapidApi, see [RapidAPI Quick Start Guide](https://docs.rapidapi.com/docs/basics-creating-a-project), then subscribe to one of more of below translation services.
20+
Some translation services requires API keys, for all details visit: [DOCS.Ziyad.info](http://docs.ziyad.info/XLocalizer/translate-services.md)
2221

23-
1. [Create RapidAPI key](https://docs.rapidapi.com/v2.0/docs/keys)
24-
25-
2. Subscribe to translation services, you can go with the free plans :)
26-
- [Google Translate](https://rapidapi.com/googlecloud/api/google-translate1/pricing)
27-
- [MyMemory](https://rapidapi.com/translated/api/mymemory-translation-memory/pricing)
28-
- [SYSTRAN.io](https://rapidapi.com/systran/api/systran-io-translation-and-nlp)
29-
- [Yandex Translate](https://tech.yandex.com/translate/)
30-
- [IBM Watson Language Translate](https://cloud.ibm.com/catalog/services/language-translator)
31-
32-
3. Goto your project and add the keys to user secrets:
22+
Goto your project and add the keys to user secrets:
3323
> Right click on the project name and select Manage User Secrets
3424
#### Google Translate, MyMemory, SYSTRAN.io via RapidApi Secrets:
3525
````json
@@ -61,20 +51,20 @@ So before using this package you will need create an application key in RapidApi
6151

6252
4. Register one or more services in startup:
6353
````cs
64-
services.AddSingleton<IStringTranslator, IBMWatsonStringTranslator>();
65-
services.AddHttpClient<IStringTranslator, GoogleTranslateStringTranslator>();
66-
services.AddHttpClient<IStringTranslator, YandexTranslateStringTranslator>();
67-
services.AddHttpClient<IStringTranslator, MyMemoryTranslateStringTranslator>();
68-
services.AddHttpClient<IStringTranslator, SystranTranslateStringTranslator>();
54+
services.AddSingleton<ITranslator, IBMWatsonStringTranslator>();
55+
services.AddHttpClient<ITranslator, GoogleTranslateStringTranslator>();
56+
services.AddHttpClient<ITranslator, YandexTranslateStringTranslator>();
57+
services.AddHttpClient<ITranslator, MyMemoryTranslateStringTranslator>();
58+
services.AddHttpClient<ITranslator, SystranTranslateStringTranslator>();
6959
````
7060

7161
6. Inject one or all services:
7262
````cs
7363
public class IndexModel : PageModel
7464
{
75-
private readonly IStringTranslator _translator;
65+
private readonly ITranslator _translator;
7666

77-
public IndexModel(IStringTranslator translator)
67+
public IndexModel(ITranslator translator)
7868
{
7969
_translator = translator;
8070
}
@@ -86,17 +76,12 @@ public class IndexModel : PageModel
8676
}
8777
````
8878

89-
The translation result is an object of type [`TranslationResult`](https://github.com/LazZiya/TranslationServices/blob/master/LazZiya.TranslationServices/TranslationResult.cs).
79+
The translation result is an object of type [`TranslationResult`](https://github.com/LazZiya/XLocalizer.Translate/blob/master/XLocalizer.Translate/TranslationResult.cs).
9080

9181
Sample result for "Welcome" translation:
9282
````
9383
{ text: "Hoşgeldiniz", statusCode: 200, target: "tr", source: "en"}
9484
````
9585

9686
## Extending Translation Services
97-
If you want to add more services just implement the interface `ITranslationService` and register it as in the builtin servies:
98-
- [GoogleTranslateService](https://github.com/LazZiya/TranslationServices/blob/master/LazZiya.TranslationServices.GoogleTranslate/GoogleTranslateService.cs)
99-
- [YandexTranslateService](https://github.com/LazZiya/TranslationServices/blob/master/LazZiya.TranslationServices.YandexTranslate/YandexTranslateService.cs)
100-
- [MyMemoryTranslateService](https://github.com/LazZiya/TranslationServices/blob/master/LazZiya.TranslationServices.MyMemoryTranslate/MyMemoryTranslateService.cs)
101-
- [SystranTranslateService](https://github.com/LazZiya/TranslationServices/blob/master/LazZiya.TranslationServices.SystranTranslate/SystranTranslateService.cs)
102-
- [IBMWatsonTranslateService](https://github.com/LazZiya/TranslationServices/blob/master/LazZiya.TranslationServices.IBMWatsonTranslate/IBMWatsonTranslateService.cs)
87+
If you want to add more services just implement the interface `ITranslator` and register it in startup.

0 commit comments

Comments
 (0)