localization in asp.net web forms with one global resource

前端 未结 3 773
广开言路
广开言路 2021-01-22 06:12

I want to have one some resource files like this:

Mui.resx
Mui.fr.resx
Mui.es.resx
...

and I want to be able to do in my codebehind something l

3条回答
  •  梦毁少年i
    2021-01-22 06:31

    Yes it is possible. You can add your resource file from File-New- Resource File and there you can add their own Resource key and their values as you want either in English or other language.,

    Check these How to: Retrieve Resource Values Programmatically and ASP.NET Web Page Resources Overview

    To retrieve global resources using strong typing

    • Get the resource using the following syntax:

      Resources.Class.Resource

    Example:

    String welcome;
    welcome = Resources.WebResources.WelcomeText;
    

    But if you using Localization Have you check this MSDN resouce:
    Walkthrough: Using Resources for Localization with ASP.NET

    Check the section Explicit Localization with ASP.NET on the link above.

    Example:

    label's text attribute now has an explicit expression stating the base file from which to retrieve the resource and the key to select.

    
    

    And on your page: Simple call with full path of resource key.

    Check this great article - Resources and Localization that will explain you more about this.

    Edit- Web.Config Culture Settings:
    Add this
    in web.config under

    If you want it on some pages then use <@Page> directive's Culture and UICulture attributes.

提交回复
热议问题