Open Closed

Localization via RabbitMQ #5294


User avatar
0
nguyenngoc.son created
  • ABP Framework version: v7.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: From service A, we're sending one message to service B via RabbitMQ, however when service B proceed the message, it using default localizaion instead of language that currently use by user.
  • Steps to reproduce the issue:"

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try:

    public abstract class EventDataWithCultureName
    {
        public class CultureName {get; set;}
    }
    
    public class MyEventData: EventDataWithCultureName
    {
        ......
    }
    
    await _distributedEventBus.PublishAsync(
        new MyEventData
        {
            CultureName = CultureInfo.CurrentCulture.Name
        }
    );
    
    
    public class MyHandler: IDistributedEventHandler<MyEventData>, ITransientDependency
    {
        public async Task HandleEventAsync(MyEventData eventData)
        {
            using (CultureHelper.Use(CultureInfo.GetCultureInfo(eventData.CultureName)))
            {
               ....
            }
        }
    }
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11