meta info
  • Title: Use MyMemory Translation For Localization
  • Keywords: localization, asp.net-core, translate, online, mymemory, service
  • Description: Learn how to use mymemory translation service for localization of Asp.Net Core web apps with XLocalizer.Translate.
  • Author: Ziya Mollamahmut
  • Date: 12-Nov-2020
  • Image: https://github.com/LazZiya/Docs/raw/master/XLocalizer/v1.0/images/xlocalizer-logo.png
  • Image-alt: XLocalizer Logo
  • Version: v1.0

Use MyMemory 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.MyMemoryTranslate

MyMemoryTranslateService

This service is directly connected to MyMemory Api's, and it offers free anonymous usage, but the daily limit is low! However, you can increase the free daily usage by providing a valid email address and an API key that can be generated via MyMemory: API key generator.

{
  "XLocalizer.Translate": {
    "MyMemory": {
        "Key": "...",
        "Email": "..."
    }
  }
}

Right click on the project name and select Manage User Secrets

  • Register in startup
services.AddHttpClient<ITranslator, MyMemoryTranslateService>();
  • Use with XLocalizer
services.AddRazorPages()
        .AddXLocalizer<LocSource, MyMemoryTranslateService>(ops =>
        {
            // ...
            ops.AutoTranslate = true;
        });

MyMemoryTranslateServiceRapidApi

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

  • Register in startup
services.AddHttpClient<ITranslator, MyMemoryTranslateServiceRapidApi>();
  • Use with XLocalizer
services.AddRazorPages()
        .AddXLocalizer<LocSource, MyMemoryTranslateServiceRapidApi>(ops =>
        {
            // ...
            ops.AutoTranslate = true;
        });