Filter by title

Multi-Lingual Objects

The Volo.Abp.MultiLingualObject package is not published on NuGet. It was removed from the release pipeline in #8271 and re-designing this feature is tracked in #11698. The source code is still maintained in the framework repository, so you can copy the Volo.Abp.MultiLingualObjects project into your solution if you want to use the pattern described below.

The Volo.Abp.MultiLingualObjects project provides a contract and a selection service for objects that store one translation per language. Persistence mapping is application-specific; it does not create a database relationship for the translations.

Getting the Code

Copy the Volo.Abp.MultiLingualObjects project into your solution and reference it from the project that defines the consuming module.

Add AbpMultiLingualObjectsModule as a dependency of that module:

using Volo.Abp.Modularity;
using Volo.Abp.MultiLingualObjects;

[DependsOn(typeof(AbpMultiLingualObjectsModule))]
public class MyApplicationModule : AbpModule
{
}

Define a Multi-Lingual Object

Implement IMultiLingualObject<TTranslation> on the object and IObjectTranslation on its translation type:

using System.Collections.Generic;
using Volo.Abp.MultiLingualObjects;

public class Product : IMultiLingualObject<ProductTranslation>
{
    public ICollection<ProductTranslation> Translations { get; set; } =
        new List<ProductTranslation>();
}

public class ProductTranslation : IObjectTranslation
{
    public string Language { get; set; } = string.Empty;

    public string Name { get; set; } = string.Empty;
}

Language stores a culture name such as en, en-US or tr.

Select a Translation

Inject IMultiLingualObjectManager and call GetTranslationAsync:

using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiLingualObjects;

public class ProductService
    : ITransientDependency
{
    private readonly IMultiLingualObjectManager _multiLingualObjectManager;

    public ProductService(
        IMultiLingualObjectManager multiLingualObjectManager)
    {
        _multiLingualObjectManager = multiLingualObjectManager;
    }

    public Task<ProductTranslation?> GetTranslationAsync(Product product)
    {
        return _multiLingualObjectManager
            .GetTranslationAsync<Product, ProductTranslation>(product);
    }
}

With the default arguments, the manager uses CultureInfo.CurrentUICulture.Name. It selects translations in this order:

  1. An exact translation for the current UI culture.
  2. A translation for a parent of the current UI culture when fallbackToParentCultures is true.
  3. A translation for the language configured by LocalizationSettingNames.DefaultLanguage.
  4. The first available translation.

The method returns null when the collection is null or empty. To disable only the parent-culture fallback, set fallbackToParentCultures to false. The default-language and first-available fallbacks still apply.

Select Translations in Bulk

Use GetBulkTranslationsAsync to select translations for multiple objects with the same culture and fallback settings:

var results = await _multiLingualObjectManager
    .GetBulkTranslationsAsync<Product, ProductTranslation>(products);

foreach (var (product, translation) in results)
{
    // Use product and its selected translation.
}

Each result keeps the source object together with its selected translation. An object with no translations gets a null translation.

Contributors


Last updated: July 21, 2026 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

ABP Community Talks
Low-Code, High Precision
13 Aug, 17:00
Online
Watch the Event
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.