Open Closed

Cross-solution localization #7744


User avatar
0
alexander.nikonov created
  • ABP Framework version: v8.1.3
  • UI Type: Angular
  • Database System: EF Core (Oracle)
  • Auth Server Separated

Moving to Redis server and dynamic permissions allowed us to simplify the process of Role / Permission management. So now Redis cache contains permissions of all the running solutions.

However, one problem remained: localization. One of the solutions contains Role / Permission management page which displays ALL the permissions. But each permission localized name resides in the corresponding solution. We don't want to move the permission localization to a separate project.

The most simple way to resolve this would be to consume all the solutions' Domain.Shared projects:

    options.Resources
        .Add<PermissionManagementResource>("en")
        .AddBaseTypes(typeof(SolutionAResource), typeof(SolutionBResource), typeof(SolutionCResource))

But it would create a coupling we want to avoid. We might have a new solution D in future - which means we will have to modify the code above again.

The question is - what is an alternative way to have localization from all the solutions always actual, but still be able to do search by a localized name after receiving the permissions from all the solutions using

    var permissionListResultDto = await _permissionAppService.GetAsync(RolePermissionValueProvider.ProviderName, role.Name);
    

?


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

    Hi,

    You can specify localized resource names for permissions

    myGroup.AddPermission("test", LocalizableString.Create("MyPermission1", "PermissionResource"));

  • User Avatar
    0
    alexander.nikonov created

    I do have localization for permissions, but the translations are stored in the resource files (in Domain.Shared project) of the respective applications: A, B, C. So to show the display names of all of them on a central Permission Management page, I need to retrieve the translations from those projects.

    And to my knowledge, there are only two options here:

    1. to consume all the resources (i.e. Domain.Shared projects - which are now published as Nuget package) in the solution where the Permission Management page is;
    2. make an API call to A, B, C solutions endpoints to retrieve resources on the Permission Management page and map them on resource keys on front-end side;

    I don't like variant #1 because of the reasons described previously. And I don't like variant #2 much either, because there could be a lot of excessive data - /api/abp/application-localization endpoint only accepts the language parameter, no any resource key mask...

    I thought that maybe there's a better way?

    I cannot hardcode display name of the permission in the property, if this is what you meant, because I have a multi-language app, so the permission display name needs to be changed depending on the current UI language.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Unfortunately there is no better way

  • User Avatar
    0
    alexander.nikonov created

    Unfortunately there is no better way

    Well, maybe Ocelot Gateway project would help it? Will it work to merge localizations from all running sites (i.e. merge the "application-localization" endpoints results) and finally get the full list at the site with Role Management page, will the page "see" all those?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You should put the localization files in the same project

  • User Avatar
    0
    alexander.nikonov created

    Understood... Thank you.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11