Base solution for your next web application
Open Closed

IdentityResultExtensions - How to localize error text #12302


User avatar
0
dominici created

Dear support, I'm looking for identity result localization in Italian language.

I see that localization of identity result should be supported but I'm not sure how to do it.

The extension IdentityResultExtensions try to find a localized string from this localization source: AbpZeroConsts.LocalizationSourceName (hard coded) This const value is "AbpZero" so different from my project resources.

I've also tried to define my custom IdentityErrorDescriber. It works as expected but the next instruction identityResult.CheckErrors(LocalizationManager) obviously doesn't work and change all the error message to a generic error message.

So, before changing some Asp Net Zero code, I would like to know if the IdentityResultExtensions it's ok and what is the right way to localize it in Italian

Thanks in advance

Br, Fabrizio

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

4 Answer(s)
  • User Avatar
    -1
    m.aliozkaya created
    Support Team

    Hi @dominici,

    Can you check this file? https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Localization/AbpZeroTemplate/AbpZeroTemplate-it.xml

    Also, this document may help https://aspnetboilerplate.com/Pages/Documents/Localization

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    dominici created

    Dear support, please read the request before posting generic link. It's a very specific question, I've already checked the documentation and I've also checked if someone have had similar issue.

    Any TECHNICAL suggestion?

    Thanks,

    Fabrizio

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Identity related localization is stored in AspNet Boilerplate here https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Zero.Common/Zero/Localization/Source/AbpZero-it.xml.

    You need to extend it in your final solution. To do that, you can follow https://aspnetboilerplate.com/Pages/Documents/Localization#extending-localization-sources.

    Let me know if this doesn't work for you.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    dominici created

    Hello @ismcagdas, following your suggestions, I've created a new localization file on my core module project:

    project -> [MyProject].Core folder -> [MyProject].Core/Localization/AbpZeroXmlSource file -> AbpZero-it.xml

    and I've registered it on my core core module project:

                [MyProject]LocalizationConfigurer.Configure(Configuration.Localization);
                
                // Override default AbpZero localization 
                Configuration.Localization.Sources.Extensions.Add(
                        new LocalizationSourceExtensionInfo("AbpZero",
                            new XmlEmbeddedFileLocalizationDictionaryProvider(
                                Assembly.GetExecutingAssembly(),
                                "[MyProject].Localization.AbpZeroXmlSource"
                            )
                        )
                    );
    

    And finally it works as expected! :-)

    I hope this helps somebody else.

    Last, in my opinion, i think:

    • IdentityResult localization is a common aspect, consider to add it by default on project creation
    • Abp.IdentityFramework.IdentityResultExtensions class localize errors starting from the english description. Why? Probably there is a reason but, if possible, I think it's better to work using IdentityError.Code

    Thanks for support

    Br, Fabrizio

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)