meta info

XLocalizer for Asp.Net Core

By Ziya Mollamahmut

Goodbye "manually creating localization resources", welcome XLocalizer...!

What is XLocalizer

This is a nuget package that offers localization for Asp.Net Core based on .resx, .xml, db or any other custom file/db type. Powered by online translation and auto resource creating. XLocalizer has many powerful features and can be extended with custom tools.

  • Online Translation: Auto translation of missed localized values.
  • Auto Key Adding: Auto adding missing keys to the resources files.
  • Multiple Resource Type Support: Built-in localization support based on .RESX, .XML, DB. Extendable localization support based on any custom file/db type.
  • Export to Resx: Resources from any source type can be exported to .RESX files via built-in exporters.
  • Do it Fast: Custom cache support for speeding up the process of getting localized values from sources.
  • Standard interfaces: Easy to use due to using the standard localization interfaces: IStringLocalizer, IHtmlLocalizer, IStringLocalizerFactory and IHtmlLocalizerFactory.

How it Works

XLocalizer will translate and save localized keys into automatically created resource files. Since XLocalizer modules are implementing the default localization interfaces (IStringLocalizer, etc.) so any text passed into the localization services will be translated automatically and added into the relevant resource file/db.

Additionally, XLocalizer has built-in modules to localize all system error messages like (DataAnnotations, ModelBinding and Identity errors) without any additional workload.

XLocalizer Simplified Workflow

Quick Setup

services.AddRazorPages()
    .AddXLocalizer<LocSource, GoogleTranslateService>(ops =>
    {
        ops.ResourcesPath = "LocalizationResources";
        ops.AutoTranslate = true;
        ops.AutoAddKeys = true;
        ops.UseExpressMemoryCache = true;
        ops.TranslateFromCulture = "en";
    });

For more details see setup instructions based on project type:

See also:

Disclaimer Third Parties

All product and company names of translation services are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.

During the development of XLocalizer I've used many online translation services with the freemium plan, but it is up to you to use a priced plan from the respective service.

Each translation service has its pros and cons. MyMemory Translate provided the best results for the languages I've been working with (in terms performans and amount of free translation requests). So, in this documentation you will see most samples refering to MyMemory Translate as the translation service. But you are free to use any other service that fits your needs.