Open Closed

Missing Localization culture in Angular Interface #243


0
drpdev2 created

Hi guys,

I found that Volo.Identity.Pro module was lack of vietnamese. So I have to update empty string of target culture language as the following image. But it is not good way for many tenants or other cultures. Can I add a new localization json file into Volo Identity module and other modules? Can I modify values of the existed localization json files in Volo module packages? Could you share me the steps? Thanks

  • ABP Framework version: v2.9.0
  • UI type: Angular 9
  • Identity Server Seperated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:

15 Answer(s)
  • 0
    liangshiwei created
    Support Team

    Hi,

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

  • 0
    drpdev2 created

    Hi @liangshiwei, I refered to https://docs.abp.io/en/abp/latest/Localization#extending-existing-resource As I know, the document is only describe extending existing resource file in order to reuse in other classes. But It seems not point out how to add new or modify existing culture language file of Volo abp module. Could you share me the steps?

    1. How to add a new localization json file into Volo Identity Pro module?
    2. And how to modify values of the existed localization json files in Volo Identity Pro module or other Abp module packages?
  • 1
    liangshiwei created
    Support Team

    • en.json Extend existing languages
    ```json
        {
          "culture": "en",
          "texts": {
            "TestKey": "This is test value"
          }
        }
    ```
    
    • vi.json A new languages files
    ```json
        {
          "culture": "vi",
          "texts": {
            "TestKey": "Đây là giá trị được thử nghiệm"
          }
        }
    ```
    

    Set as embedded file:

    <ItemGroup>
        <EmbeddedResource Include="Localization\Identity\*.json" />
        <Content Remove="Localization\Identity\*.json" />
     </ItemGroup>
    

    Extend localized resources for modules:

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

    Add Vietnamese culture:

    That's all

  • 0
    drpdev2 created

    @liangshiwei Thank you! It works well.

  • 0
    syabp created

    Hi @liangshiwei, thank for your guidance, that worked well for Volo Identiy. But when i try to add new vi.json file for Volo.Abp.Account.Application.Contracts(2.9.0) (package installed), i got some issues below: I can't see any vietnamese value in resource AbpAccount - Language Texts management:

    But Vietnamese values showed correctly in ui:

    And when i switch back to english, it seem a little weird:

    What should i do?

  • 0
    drpdev2 created

    Hi @liangshiwei, I have the same problem about AccountResource.

    I added Volo.Abp.Account.Application.Contracts" Version="2.9.0" to XXX.Domain project. and add this code into xxxDomainModule.cs

    options.Resources.Get<Volo.Abp.Account.Localization.AccountResource>().AddVirtualJson("/Localization/Account");
    

    But Identity Server Seperated cannot start. Could you give me how to fix it?

    ---> Volo.Abp.AbpException: Can not find a resource with given type: Volo.Abp.Account.Localization.AccountResource, Volo.Abp.Account.Application.Contracts, Version=2.9.0.0, Culture=neutral, PublicKeyToken=null
       at Volo.Abp.Localization.LocalizationResourceDictionary.Get[TResource]()
    
  • 0
    alper created
    Support Team

    @drpdev2 did you solve it or do you want me to check it?

  • 0
    drpdev2 created

    Hi @alper: The issue has not solved yet. Can you kindly check it?

  • 0
    alper created
    Support Team

    ok. we'll check it.

  • 0
    maliming created
    Support Team

    hi @syabp and @drpdev2

    You're should be use the Pro packages of account module instead of open source ones.

  • 0
    drpdev2 created

    Hi @maliming, As your image, What pro packages will be to install to XXX.Domain project? Localization of Pro is not exist. Could you kindly share how to configure here? I took an error as below image.

  • 0
    maliming created
    Support Team

    hi @drpdev2

    It's only install the XXX.Domain pakcages in Domain layer.

    You should configure the localization in different layers.

    Configure Account.Pro.Localizetion.AccountResource in your Application.Contract layer because the Volo.Abp.Account.Pro.Public.Application.Contracts or Volo.Abp.Account.Pro.Admin.Application.Contracts packages are installed the layer.

  • 0
    drpdev2 created

    @maliming: Could you guide step by step to do it? I cannot find the package: Volo.Abp.Account.Pro.Localization.AccountResource What packages should we install? and how to fix this configure?

    ABP Framework version: v2.9.0 UI type: Angular 9 Identity Server Seperated (Angular): yes

  • 0
    maliming created
    Support Team

    hi @drpdev2

    The AccountResource is exist in the Volo.Abp.Account.Pro.Shared.Application.Contracts package

    If you stil can't resolve this problem you can send a email to me([email protected]), We can remotely check it via teamviewer.

  • 0
    drpdev2 created

    Thanks @mailiming.

    I found the package name. I implemented the localizationfor AccountResource in ApplicationContract layer as the following. It works well.

    public class PortalApplicationContractsModule : AbpModule
        {
            public override void ConfigureServices(ServiceConfigurationContext context)
            {
                Configure<AbpLocalizationOptions>(options =>
                {
                    options.Resources.Get<AccountResource>().AddVirtualJson("/Localization/Account");
                });
    
                base.ConfigureServices(context);
            }
        }