Learn More, Pay Less!
Limited Time Offer!
Open Closed

Localization resource overrides #8730


User avatar
0
ninomartini created
  • Template: app
  • Created ABP Studio Version: 0.9.17
  • Tiered: No
  • Multi-Tenancy: Yes
  • UI Framework: angular
  • Theme: leptonx
  • Theme Style: dark
  • Database Provider: ef
  • Database Management System: sqlserver
  • Separate Tenant Schema: No
  • Mobile Framework: react-native
  • Progressive Web App: No
  • Public Website: No
  • Include Tests: Yes
  • Optional Modules:
    • GDPR
    • TextTemplateManagement
    • LanguageManagement
    • AuditLogging
    • OpenIddictAdmin

I created a localization resource to override some of the default values. For example, I wanted to override the default values of 'Name' and 'Surname' to 'First Name' and 'Last Name for AbpAccount and AbpIdentity. I am able to get the desired behavior when I run my application local. However, I don't see my modifications when running from production.

Any suggestions?


7 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, can you please share what you have done to override the localization entries? For example, you might be followed this documentation, but the options might be configured between the debug pragma statements (e.g. #if DEBUG)

    Or did you change the localization entries on the angular UI side? (https://abp.io/docs/latest/framework/ui/angular/localization) If you did, then the environment might not be set correctly.

  • User Avatar
    0
    ninomartini created

    Hello,

    I created folders for AbpAccount and AbpIdentiy under Localizations within the Domain.Shared project.

    Domain.Shared/Localizations/AbpAccount/en.json

    {
    	"Culture": "en",
    	"Texts": {
    		"DisplayName:Name": "First name",
    		"DisplayName:Surname": "Last name"
    	}
    }
    
    

    Domain.Shared/Localizations/AbpIdentity/en.json

    {
    	"Culture": "en",
    	"Texts": {
    		"DisplayName:Name": "First name",
    		"DisplayName:Surname": "Last name",
    		"Name": "First name",
    		"Surname": "Last name"
    	}
    }
    

    I modified the DomainSharedModule's ConfigureServices as follows:

    Configure<AbpLocalizationOptions>(options =>
    {
        ...
        
        options.Resources
            .Get<IdentityResource>()
            .AddVirtualJson("/Localization/AbpIdentity");
    
        ...
    });
    

    I modified the ApplicationContractModule's ConfigurationServices as follows:

    Configure<AbpLocalizationOptions>(options =>
    {
        options.Resources
            .Get<AccountResource>()
            .AddVirtualJson("/Localization/AbpAccount");
    });
    
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hello,

    I created folders for AbpAccount and AbpIdentiy under Localizations within the Domain.Shared project.

    Domain.Shared/Localizations/AbpAccount/en.json

    { 
      "Culture": "en", 
      "Texts": { 
      	"DisplayName:Name": "First name", 
      	"DisplayName:Surname": "Last name" 
      } 
    } 
     
    

    Domain.Shared/Localizations/AbpIdentity/en.json

    { 
      "Culture": "en", 
      "Texts": { 
      	"DisplayName:Name": "First name", 
      	"DisplayName:Surname": "Last name", 
      	"Name": "First name", 
      	"Surname": "Last name" 
      } 
    } 
    

    I modified the DomainSharedModule's ConfigureServices as follows:

    Configure<AbpLocalizationOptions>(options => 
    { 
        ... 
         
        options.Resources 
            .Get<IdentityResource>() 
            .AddVirtualJson("/Localization/AbpIdentity"); 
     
        ... 
    }); 
    

    I modified the ApplicationContractModule's ConfigurationServices as follows:

    Configure<AbpLocalizationOptions>(options => 
    { 
        options.Resources 
            .Get<AccountResource>() 
            .AddVirtualJson("/Localization/AbpAccount"); 
    }); 
    

    It seems that you did everything right. By any chance, can you share your project via email, so I can better assist you? (support@abp.io with the ticket number)

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Update: I got your project and checking currently. I will write you back asap.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi again, I have checked your project and found the problem. Everything you did was correct and necessary, however, it seems you missed setting the related localization files as EmbeddedResource. This is required for the production environment.

    You should add the following lines to the *.Domain.Shared.csproj file, and then it should work as expected:

    
      <ItemGroup>
        <EmbeddedResource Include="Localization\ManasotaErp\*.json" />
        <Content Remove="Localization\ManasotaErp\*.json" />
      </ItemGroup>
    
      <ItemGroup>
        <EmbeddedResource Include="Localization\AbpIdentity\*.json" />
        <Content Remove="Localization\AbpAccount\*.json" />
      </ItemGroup>
    
    

    Best regards.

  • User Avatar
    1
    ninomartini created

    I wanted to let you know that embedding the resources in the project file has solved the issue. Thanks so much for your time and assistance in troubleshooting this—it’s greatly appreciated!

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    I wanted to let you know that embedding the resources in the project file has solved the issue. Thanks so much for your time and assistance in troubleshooting this—it’s greatly appreciated!

    Thank you 🙏

Made with ❤️ on ABP v9.2.0-preview. Updated on February 13, 2025, 10:35