Use Yandex Translate For Localization
By Ziya Mollamahmut
This nuget is based on the free plan of Yandex Translate .
See GitHub repo
Install
PM > Install-Package XLocalizer.Translate.YandexTranslate
Notice: To install the latest preview add -Pre
to the command line
Add Yandex Translate API key to user secrets
Right click on the project name and select Manage User Secrets , then add the API key as below:
{
"XLocalizer.Translate" : {
"YandexTranslateApiKey" : " xxx-yandex-translate-api-key-xxx"
}
}
Register in startup
using XLocalizer . Translate
using XLocalizer . Translate . YandexTranslate
services . AddHttpClient< ITranslator , YandexTranslateService > ( ) ;
Use with XLocalizer
// Configure XLocalizer to use the translation service
// and enable online translation
services . AddRazorPages ( )
. AddXLocalizer < LocSource , YandexTranslateService > ( ops =>
{
// ...
ops . AutoTranslate = true ;
} ) ;