Base solution for your next web application
Open Closed

String format localisation in AppAuthorizationProvider #10368


User avatar
0
Astech created

Hi,

We are using string format to join two or more localisations together. For example:

<?xml version="1.0" encoding="utf-8" ?> <localizationDictionary culture="en"> <texts> <text name="CreateNewSomething">Create new {0}</text> <text name="Role">Role</text> <text name="OrganisationUnit">Organisation Unit</text> </texts> </localizationDictionary>

We are then using it these in our views like so: string.Format(@L("CreateNewSomething"),@L("Role").ToLower())

This works great. However, we have now run into a problem trying to set the text for permissions in AppAuthorizationProvider.cs: roles.CreateChildPermission(AppPermissions.Pages_Administration_Roles_Create, L("CreatingNewRole"));

The second parameter here expects ILocalizableString and not String. Therefore we cannot do a string format in the same way as above.

Is there a way to do this please?

Thanks,

Prerequisites

  • What is your product version? - v10.0.0
  • What is your product type (Angular or MVC)? - MVC JQuery
  • What is product framework type (.net framework or .net core)? - Core

1 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @Astech The reason it requires ILocalizableString not normal string is, it translates given ILocalizableString every time it is needed. For example one of your client can request permission with en display names, other can request it with tr. Therefore, a language-independent parameter is required. You should create localization keys for all of your permissions display names.