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

How to implement localization for permission #90


User avatar
0
lcyhjx created

Hi In AuthorizationProvider, we can initialize permissions,

public class BOMAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            //TODO: Localize (Change FixedLocalizableString to LocalizableString)

            context.CreatePermission("CanCreateQuestions", new FixedLocalizableString("Can create questions"));
            context.CreatePermission("CanDeleteQuestions", new FixedLocalizableString("Can delete questions"));
            context.CreatePermission("CanDeleteAnswers", new FixedLocalizableString("Can delete answers"));
            //context.CreatePermission("CanAnswerToQuestions", new FixedLocalizableString("Can answer to questions"), isGrantedByDefault: true);
            context.CreatePermission("CanAnswerToQuestions", new FixedLocalizableString("Can answer to questions"));

        }
    }

My question is how to implement localization for permissions which will be displayed on GUI. For example, in localization xml file, define a localization string as below

<text name="Permission_Create_Question" value="Can create questions" />

in another localization xml file, define a localization string as below

<text name="Permission_Create_Question" value="新增提问" />

what change should I do to implement it? Thanks!


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

    Hi,

    Use LocalizableString instead of FixedLocalizableString. LocalizableString needs a key and a localization source name. So, you should define the localization source before (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Localization#DocLocalizationSources">http://www.aspnetboilerplate.com/Pages/ ... ionSources</a>).