Intro
Tlumach.NET is a flexible library that provides translation and localization support to all kinds of .NET applications: from desktop WinForms, WPF, UWP, WinUI, and console to mobile MAUI and Avalonia to server MVC, Razor Pages, and Blazor.
Table of Contents
- Configuration Files: Structure and format of a configuration file
- Translation Files and Formats: Everything related to translation files, their formats, and supported locations
- Strings and Translations: Everything about the fundamentals - text strings and translation units
- Templates and Placeholders: What are templated translation units and how to use placeholders in translation units efficiently
- Generator: What Generator is and when you use it
- Language management: How to list and switch languages
- Integration with XAML: Binding of XAML elements to generated translation units for automatic updates of the UI
- Dependency Injection: Using Tlumach via Dependency Injection in modern .NET versions
- Localization of Data Annotations: Localizing the messages and the display names of validation attributes
- Localization of FluentValidation: Localizing the built-in messages of FluentValidation, the messages and the names of rules, and error codes
- Localization of MVC and Razor Pages: View and HTML localizers, tag helpers, the culture selector, model binding messages, and display names in ASP.NET Core MVC and Razor Pages
- Template Engines: Using translations in Scriban, Fluid (Liquid), and Handlebars.Net templates, e.g. for localized emails and reports
- Localization of MudBlazor: Providing the built-in texts of MudBlazor components (data grid filters and pager, table pager, date picker, ...) from Tlumach in the language of each user
- Localization of Syncfusion Blazor: Providing the built-in texts of Syncfusion Blazor components (grid pager, filter menus, search box, date picker, ...) from Tlumach in the language of each user, with the official translations of Syncfusion as an optional fallback
- Writers: Tlumach writer classes and how to use them
- Packages: Which NuGet packages to reference for each kind of application
- Glossary: The list of most frequent terms in this documentation
The Ways to Use Tlumach
Tlumach can be used in different ways depending on your application type and the way the localized text is to be used:
- XAML-based desktop and mobile .NET applications, use in XAML UIs. You can bind XAML attributes to translation units as shown below. This way, when the language is switched in the translation manager, UI elements get updated automatically.
- Windows Forms applications. You can assign translation keys to controls in the Visual Studio Designer using the
TranslationProvidercomponent or bind controls to translation units in code. In both cases, the controls get updated automatically when the language is switched. - Blazor applications (Server, WebAssembly, static SSR, Hybrid). The
TlumachTextcomponent and theTlumachComponentBasehelpers show translations in the language of each user, and the components get updated automatically when the language is switched. - ASP.NET Core MVC and Razor Pages applications.
IViewLocalizer,IHtmlLocalizer, the tag helpers, and theHtml.Tlumachhelper show translations in the language of each request; model binding messages and display names are localized, too, and the<tlumach-culture-selector>tag helper lets users switch the language. - Websites and Web, console, and server applications which output the text from code or web files. There, you can access generated TranslationUnit instances in code to pick the text for current or specific locale. The use of generated TranslationUnit objects ensures that there is no mistake made when referencing the text.
- Any application. The basic way to access translations is to create and use an instance of the TranslationManager class to retrieve specific translation units by key (a simple string). This class is always available and used internally by TranslationUnit objects.
Each of the ways is documented below.
Getting Started
It is a good idea to check out the samples in the Tlumach repository on GitHub before proceeding with the below instructions.
Choose the desired way of using Tlumach to read specific Getting Started instructions:
- Getting Started for integration with WPF
- Getting Started for integration with UWP
- Getting Started for integration with WinUI
- Getting Started for integration with MAUI
- Getting Started for integration with Avalonia
- Getting Started for integration with Windows Forms
- Getting Started for integration with Blazor
- Getting Started for integration with ASP.NET Core MVC
- Getting Started for integration with Razor Pages
- Getting Started for integration with MudBlazor
- Getting Started for integration with Syncfusion Blazor
- Getting Started for integration with FluentValidation
- Getting Started for integration with Scriban
- Getting Started for integration with Fluid
- Getting Started for integration with Handlebars.Net
- Getting Started for work with generated translation units (recommended for web, server, and console applications)
- Getting Started for work via Dependency Injection
- Getting Started for work via TranslationManager (for fine control over the process and for creating translation tools)