Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Localization not working in BackgroundJob #897


User avatar
0
paul lee created

Hi All,

I am following BackgroundJobAndNotificationDemo from Abp.Samples to try to get this document generation background job working.

I have a BackgroundJob defined as follows and following the sample project, this class lives in the Core module:

public class ExcelGenerationJob : BackgroundJob<ExcelGenerationJobArgs>, ITransientDependency
{
  // Some other code....

  public ExcelGenerationJob()
  {
    LocalizationSourceName = ProjectConsts.LocalizationSourceName;
  }

  // However, I get whatever string I passed to L() back here 
  public void ComposeAdText()
  {
    var stringBuilder = new StringBuilder();
    stringBuilder.AppendLine(L("AdTextLine1"));
    
    // Here in the Log I always see AdTextLine1 being attached to the log line...
    Logger.Debug("Localizing AdTextLine1 - " + stringBuilder.ToString()); 
  }
}

I tried to debug a bit and see that base.LocalizationManager.GetAllSources().Count is always 0. So what's the proper way to initialize Localization to get this working?

Thanks.


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Are your localization XML files in the Core project?

  • User Avatar
    0
    paul lee created

    Yes, both classes are in the Core project. The same setup as one of your wonderful samples. However, I can't get it to work.

  • User Avatar
    0
    hikalkan created
    Support Team

    I did not undestand the reason. You can create issue for it on Github and I will try to add localization to background job sample.