Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize extension property in Angular doesn't match documentation #19807

Open
1 task done
antonGritsenko opened this issue May 14, 2024 · 0 comments
Open
1 task done
Assignees
Labels

Comments

@antonGritsenko
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description

The localization of the extension property seems broken or documentation is not up to date.

Reproduction Steps

Based on https://docs.abp.io/en/abp/latest/Module-Entity-Extensions#display-name

  1. Generate new solution using latest version 8.1.1, call it SimpleTemplate, use angular as UI
  2. Change SimpleTemplateModuleExtensionConfigurator.cs to following (just uncomment sample code):
 private static void ConfigureExtraProperties()
 {
     ObjectExtensionManager.Instance.Modules()
          .ConfigureIdentity(identity =>
          {
              identity.ConfigureUser(user =>
              {
                  user.AddOrUpdateProperty<string>( //property type: string
                      "SocialSecurityNumber", //property name
                      property =>
                      {
                          //validation rules
                          property.Attributes.Add(new RequiredAttribute());
                          property.Attributes.Add(new StringLengthAttribute(64) { MinimumLength = 4 });

                          property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true;

                          //...other configurations for this property
                      }
                  );
              });
          });
 }
  1. Change aspnet-core\src\Angr.SimpleTemplate.Domain.Shared\Localization\SimpleTemplate\en.json to
{
  "culture": "en",
  "texts": {
    "Menu:Home": "Home",
    "Welcome": "Welcome",
    "LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io.",
    "SocialSecurityNumber": "SSN",
     "DisplayName:SocialSecurityNumber": "SSN wit DisplayName",
      "SSNCustomKey": "SSN with custom key"
  }
}

Rune the app, open the edit user form: NOK, still SocialSecurityNumber
4. Change SimpleTemplateModuleExtensionConfigurator.cs to

ObjectExtensionManager.Instance.Modules()
     .ConfigureIdentity(identity =>
     {
         identity.ConfigureUser(user =>
         {
             user.AddOrUpdateProperty<string>( //property type: string
                 "SocialSecurityNumber", //property name
                 property =>
                 {
                     //validation rules
                     property.Attributes.Add(new RequiredAttribute());
                     property.Attributes.Add(new StringLengthAttribute(64) { MinimumLength = 4 });
                     property.DisplayName = new FixedLocalizableString("Social security no");
                     property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true;

                     //...other configurations for this property
                 }
             );
         });
     });

Run the app: OK
5. Change SimpleTemplateModuleExtensionConfigurator.cs to

ObjectExtensionManager.Instance.Modules()
     .ConfigureIdentity(identity =>
     {
         identity.ConfigureUser(user =>
         {
             user.AddOrUpdateProperty<string>( //property type: string
                 "SocialSecurityNumber", //property name
                 property =>
                 {
                     //validation rules
                     property.Attributes.Add(new RequiredAttribute());
                     property.Attributes.Add(new StringLengthAttribute(64) { MinimumLength = 4 });
                      property.DisplayName = LocalizableString.Create<SimpleTemplateResource>("SSNCustomKey");
                     property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true;

                     //...other configurations for this property
                 }
             );
         });
     });

Execute the app: NOK, now display name of the property changed to SSNCustomKey

  1. Change SimpleTemplateModuleExtensionConfigurator.cs to
ObjectExtensionManager.Instance.Modules()
     .ConfigureIdentity(identity =>
     {
         identity.ConfigureUser(user =>
         {
             user.AddOrUpdateProperty<string>( //property type: string
                 "SocialSecurityNumber", //property name
                 property =>
                 {
                     //validation rules
                     property.Attributes.Add(new RequiredAttribute());
                     property.Attributes.Add(new StringLengthAttribute(64) { MinimumLength = 4 });
                      property.DisplayName = LocalizableString.Create<SimpleTemplateResource>("::SSNCustomKey");
                     property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true;

                     //...other configurations for this property
                 }
             );
         });
     });

Execute the app: OK, now display name of the property changed to "SSN with custom key"

Expected behavior

Localization still works

Actual behavior

Localization doesn't work as documented, moreover, the behavior changed from the prev versions.

Regression?

Yes, it works in v6 with "DisplayName:SocialSecurityNumber"

Known Workarounds

No response

Version

8.1.1

User Interface

Angular

Database Provider

EF Core (Default)

Tiered or separate authentication server

Tiered

Operation System

Windows (Default)

Other information

I believe this is kind bug in the Angular, because my own app and app created from the template just flooded with warnings like this (I have 27 in just create app from the template):

The localization source separator (::) not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants