Use Google Translate For Localization
By Ziya Mollamahmut
This nuget containes two services, you can use any of them depending on your requirements:
See GitHub repo
Install
PM > Install-Package XLocalizer.Translate.GoogleTranslate
This service is directly connected to Google Translate Api's, and it offers free usage, but it requires a subscription!
{
"XLocalizer.Translate": {
"Google": {
"Key": "..."
}
}
}
Right click on the project name and select Manage User Secrets
services.AddHttpClient<ITranslator, GoogleTranslateService>();
services.AddRazorPages()
.AddXLocalizer<LocSource, GoogleTranslateService>(ops =>
{
// ...
ops.AutoTranslate = true;
});
GoogleTranslateServiceRapidApi
This service is connected to RapidApi, and it requires a RapidApi key and a subscription to any paid or free plan.
{
"XLocalizer.Translate": {
"RapidApiKey": "...",
}
}
Right click on the project name and select Manage User Secrets
services.AddHttpClient<ITranslator, GoogleTranslateServiceRapidApi>();
services.AddRazorPages()
.AddXLocalizer<LocSource, GoogleTranslateServiceRapidApi>(ops =>
{
// ...
ops.AutoTranslate = true;
});