Open Closed

‘Partial’ localization files #7996


User avatar
0
karl.ettinger@energieag.at created
  • ABP Framework version: v8.0.3
  • UI Type: Blazor Server
  • Database System: EF Core Oracle

Hello

We have a 30 year old Windows desktop software that we are migrating to Blazor Server with ABP Framework. This old software has a database in which all system data for the software is stored. This includes the database structure definitions, form definitions, authorisations and much more. For the new software, we have written a code generator that uses this data and creates as much new ABP code as possible. The generated partial C# code files are structured according to the system, that there is a main file and one or more ‘sub’ files for the main file. Example: AnlMangager.cs, AnlMangager.g.cs or AnlAppService.cs, AnlAppService.Xxx1.g.cs, AnlAppService.Xxx2.g.cs. All *.g.cs are always newly created by the generator. During creation, however, the main file (e.g. AnlMangager.cs) is checked to see whether the method to be generated already exists. If so, the method is not recreated.

This works very well. The situation is different with the localisation files (en.json, de-DE.json, ...). Unfortunately, these cannot be created according to the above scheme, as the ABP framework does not provide ‘partial’ files for localisation, in the sense of en.json, en.Xxx1.json or de-DE.json, de-DE.Xxx1.json, de-DE.Xxx2.json.

Do you have any idea how I can change the behaviour of the ABP framework so that I can split the localisation files into several files?


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

    Hi,

    You can consider using different Localization Resource.

    for example

    [LocalizationResourceName("MyResource")]
    public class MyResource
    {
    
    }
    
    [LocalizationResourceName("MyPartialResource")]
    public class MyPartialResource
    {
    
    }
    
    Configure<AbpLocalizationOptions>(options =>
    {
        options.Resources
            .Add<MyResource>("en")
            .AddBaseTypes(typeof(MyResource))
            .AddVirtualJson("/Localization/MyResource");
    
        options.Resources
            .Add<MyPartialResource>("en")
            .AddVirtualJson("/Localization/MyPartialResource")
            .AddBaseTypes(typeof(MyResource)); //Inherit from an existing resource
            
        options.DefaultResourceType = typeof(MyPartialResource);
    });
    
  • User Avatar
    0
    karl.ettinger@energieag.at created

    Hi,

    Thanks for the example. I will give it a try.

Made with ❤️ on ABP v9.0.0-preview Updated on October 03, 2024, 12:03