Abp: How To change IdentityResource translations in My own module?

Created on 15 Dec 2019  ·  8Comments  ·  Source: abpframework/abp

I'm writing a an application Called PmsCloud and also it has a PmsCloudResource file. I added fa language in my application and using fa.json file. how can I add fa translation for IdentityResource in my application. for example I need to translate Premission:Create in AbpIdentity module.
teşekkür :)

Most helpful comment

@maliming I read this but as you can see in my last code I should Add my own resource first and then I can extened other resources . this point not mentioned in the document.

All 8 comments

@maliming I wroe the code as same as the document but didn't work.
``` C#
options.Resources
.Add("fa")
.AddBaseTypes(typeof(IdentityResource)) // <=== Inherit from IdentityResource
.AddVirtualJson("/Localization/PmsCloud");

 only  permissions under `PmsCloud` module translated:
``` json
                {
                    "name": "PmsCloud.Countries",
                    "displayName": "مدیریت کشورها",
                    "parentName": null,
                    "isGranted": true,
                    "allowedProviders": [],
                    "grantedProviders": [
                        {
                            "providerName": "R",
                            "providerKey": "admin"
                        }
                    ]
                },
                {
                    "name": "PmsCloud.Countries.Create",
                    "displayName": "ایجاد",  <====TRANSLATED
                    "parentName": "PmsCloud.Countries",
                    "isGranted": true,
                    "allowedProviders": [],
                    "grantedProviders": [
                        {
                            "providerName": "R",
                            "providerKey": "admin"
                        }
                    ]
                },
   {
                    "name": "AbpIdentity.Roles.Create",
                    "displayName": "Create",  <======NOT_TRANSLATED
                    "parentName": "AbpIdentity.Roles",
                    "isGranted": true,
                    "allowedProviders": [],
                    "grantedProviders": [
                        {
                            "providerName": "R",
                            "providerKey": "admin"
                        }
                    ]
                },

and here is my fa.json file in Localization/PmsCloud :

{
  "culture": "fa",
  "texts": {
    "Menu:Home": "خانه",
    "Welcome": "خوش آمدید",
    "LongWelcomeMessage": "سیستم جامع مدیریت هتل و اقامت گاه ها",
    "Login": "ورود",
    "Permission:Create": "ایجاد", <===Override_Translation
    "Permission:Edit": "ویرایش",
    "Permission:Delete": "حذف",
    "Permission:PmsManagement": "مدیریت PMS",
    "Permission:CurrencyManagement": "مدیریت ارزها",
    "Permission:CountryManagement": "مدیریت کشورها",
    "Permission:ProvinceManagement": "مدیریت استان ها",
    "Permission:IdentityManagement": "مدیریت کاربران",
    "Permission:RoleManagement": "مدیریت نقش ها",
    "Permission:CityManagement": "مدیریت شهر ها",
    "Permission:HotelChainManagement": "مدیریت زنجیره هتل",
    "Permission:GuestProfileManagement": "مدیریت پروفایل مهمان ها",
    "Permission:RoomManagement": "مدیریت اقامت گاه ها",
    "Permission:MpeManagement": "مدیریت Mpe",
    "Permission:RateManagement": "مدیریت نرخ گذاری"


  }
}

Try Extending Existing Resource.

https://docs.abp.io/en/abp/latest/Localization#extending-existing-resource

@maliming I already tried that but nothing changed.
C# options.Resources .Get<PmsCloudResource>() .AddBaseTypes(typeof(IdentityResource));

Please provide a project to reproduce your problem.

@maliming Thanks I resolved that issue by changing the code as below:
``` C#
options.Resources
.Add("fa")
.AddBaseTypes(typeof(AbpValidationResource))
.AddVirtualJson("/Localization/PmsCloud");

            options.Resources
            .Get<IdentityResource>()
            .AddVirtualJson("/Localization/PmsCloud");

```

image

@maliming I read this but as you can see in my last code I should Add my own resource first and then I can extened other resources . this point not mentioned in the document.

Was this page helpful?
0 / 5 - 0 ratings