Starts in:
0 DAY
2 HRS
3 MIN
47 SEC
Starts in:
0 D
2 H
3 M
47 S
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 v9.1.0-preview. Updated on November 20, 2024, 13:06