Base solution for your next web application
Open Closed

How to localize error messages #180


User avatar
0
wangwei22 created

Hi! I have two questions to ask:

  1. Is there a way to localize the error message for AbpAuthorizationException?
  2. Can the localization file "AbpWeb.xml" be overrided? and if so, how to do it?

Thanks first.


4 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Localizations can be overrided.

    First, you should check current localizations: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/tree/master/src/Abp.Web/Web/Localization/AbpWebXmlSource">https://github.com/aspnetboilerplate/as ... bXmlSource</a>

    Then you can override it or add new texts/languages in your module's preinitialize:

    Configuration.Localization.Sources.Extensions.Add(...);
    

    Check and try it. if you can not do it write here again.

    Have a nice day.

  • User Avatar
    0
    wangwei22 created

    Hi, I need more help. Now I still get the the wrong local message when I learning the sample in Module Zero. When I try to add a question, a exception is thrown in QuestionAppService, then I get the follow error: "An internal error occurred during your request!"

    How can I localize it?

    PS. Here is what did I do:

    1. Build a language file(actually is Chinese, already added in Module Zero) and add it to Location directory in Web project.
    |--Localization
    |----AbpExtends
    |------AbpExtends.en.xml
    |------AbpExtends.xml
    
    1. Add follow codes in Web project's preinitialize:
    Configuration.Localization.Sources.Add(
                    new XmlLocalizationSource(
                        "AbpExtends",
                        HttpContext.Current.Server.MapPath("~/Localization/AbpExtends")
                        )
                    );
    
  • User Avatar
    0
    hikalkan created
    Support Team

    I added it to documentation: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Localization#DocExtending">http://www.aspnetboilerplate.com/Pages/ ... cExtending</a>

  • User Avatar
    0
    wangwei22 created

    Following the new doc, I go it. Thanks a lot.