A new method for localized web applications

xiaoxiao2021-04-06  233

Since the Internet has emerged 10 years ago, corporate groups have continued to open up international markets. Businesses not only have global network rendering through their own Web site, but more and more companies are also publishing and / perhaps enterprise-level web applications in order to eventually serve customers around the world. Since most customers prefer to conduct business in their language and environments, it is necessary to prepare localized web sites and applications. There is no doubt that no matter which deployment model (intelligent client, web site, web service), in particular, the architecture and design, the localization task needs to pay time and energy. Effective development tools can affect the quality of the architecture, but weird is that it is still insufficient for developing tools for the localization of web applications. Results Many companies have to help more traditionally, more troublesome localization, and spend a lot of time and money.

Microsoft ASP.NET 2.0 version promises to better transform the web developers to achieve localization. By using more tools, new runtime features, new runtime, and a new-specific programming API, new runtime, and a newly-specific programming API, and developers can be quickly separated from the ASP.NET page. Reduce the code to access the localized content, expand the environment that meets the additional demand, and integrates a consistent programming model. This article will lead you to an ASP.NET development that is newly improved to prepare localized applications.

Localization using .NET 1.x

.NET Framework 1.x introduces a new localization architecture that provides non-inserted progressive deployment for language support, and the method is to drag and drop it into the new accessory set (or only resource assemblies). This type of spoke deployment example allows developers to manage localized content that is accurately selected by the ResourceManager class by the public language runtime. One advantage of ResourceManager is that it interacts with a packaged resource callback mechanism. The most appropriate language is found according to the runtime language settings of the application, so loading each ResourceSet to retrieve the process of localized content without the need to write code for management.

Windows or web applications can use resources to localize Windows forms, but Visual Studio 2003 makes the Windows developer's localized Windows form easier. When a Localizable property of a form is set to TRUE, resources for localized FORM and Control properties will be automatically generated. The attribute value is pressed into the default resource for later translation, through these resources, the generated code uses the resourceManager class instance fill control when running. ResourceManager first considers the Currentuiculture settings that are performing threads, and try to find the resource of the matching language in the resourceset, and finally help the resource callback process.

Note Please read the information about the resource callback process here.

The .NET Framework also contains many class-related classes that consider Currentuicultuiculture when generating output results such as formatting dates, time, and currency values, thereby further reducing the workload required for developers.

Note Please read more information about the language related to the language from the MSDN reference resource.

Although the deployment model of the accessory assembly can be applied to the ASP.NET application, the tools that are missing to developers can be integrated into the programming example of the Web Form. Currently, resource entities are generated for the web page, access these resources at runtime, and the correct language for each request is required to complete. So the web application localization does not have much consideration to use resources as an integration section. Localization Web Contents have caused a website that repeated the entire specific language, whereby localization of static content and writing custom code for any shared code to manage localized data sources. ASP.NET 2.0 greatly improves the method. Note MSDN article discussed the structured method for ASP.NET 1.1 localization.

Back to top

ASP.NET 2.0 New Localization Function

ASP.NET 2.0 is built on the .NET 1.x localization function, which has implemented the functions available to workflow and web developers. The following summarizes the design objectives to facilitate the next generation of localized support:

• Provide a tool for web applications that support resource generation. • Provide new declarative and runtime programming constructs for resource access. • Simplify the process of applying the correct language and automatically instantiate ResourceManager for page requests. • Support for XCOPY deployment and compilation steps of small commercial sites. • Support for enterprise-level development versions with scalability of all resource resources. • Make sure that ASP.NET controls and other applicable runtime components and adapters integrate new localization functions.

Visual Studio 2005 and ASP.NET 2.0 integrated new features ensure that the web application is localized, it provides tools to extract localized content from the web page, providing integrated runtime support for resource supporting the stateless request model, through Advanced declarative constructs Bind resources to page output, providing a new way to automatically select language for round-trip processes. The following features are specifically used to support these goals:

Strongly Typed Resources - The core status of the .NET Framework 2.0 is strong type resource support, which provides the developer to provide intelligent awareness, simplifying the code required to access the resource at runtime.

Managed Resource Editor - Visual Studio .NET 2.0 includes a new resource editor to better create and manage resource instances, such as strings, images, external files, and other complex types.

Resource GenerationFor Web Forms - Windows Form developers have benefited from automated internationalization. Now, Visual Studio 2005 will support fast internationalization, automatically generate web forms, user controls, and homepage resources.

The Improved Runtime Support - ResourceManager instance is managed by runtime, and server code can easily access it through more accessible programming interfaces.

Localization Expressions - Advanced declarative expressions for web pages map resource entities to control properties, HTML properties, or static contents. These expressions can also be extended, providing other methods to control the process of adding localization content to the HTML output.

Automatic Culture Selection - The language selection of each web request can be automatically connected to the browser preference.

Resource Provider Model - A new resource provider model allows developers to publish resources for optional data sources (for example, flat files, database tables), while accessing the programming models of these resources remain consistent.

These flexible functions are sufficient to provide a bits support for small companies that need reliable and effective solutions, and still meet the complex needs of large organizations to apply a variety of deployment architecture in additional scalability. The improved new model uses the resources of the web application, combines the Windows Form Programming model, and considers the development cycle and the runtime requirements of the Web. The following sections describe these new features implemented in the beta 1 version, and also commented on the improvements you expect in the Beta 2 versions. Back to top

Generate local resources

The .NET resource implements selectively replaces the content for a particular language and language area, so the same code base can support multiple languages. However, generating resources for web pages requires a lot of artificial labor, so it is difficult to mobilize the enthusiasm of developers using this method for web applications. ASP.NET 2.0 provides a simple way to generate resources for web pages while supporting a variety of complex content agents, including HTML elements, and properties, static content, and server controls.

Generate resources for a specific web form, you need to select Generate Local Resource from the "Tools" menu of Visual Studio 2005, and then create local resources for any page that is opened in the Design View (including Web Forms, User Controls, and Main Perspections). This step automatically generates a default .NET XML resource for a set of pages, placing it in a dedicated subdirectory established for local resource (change this directory name in Beta 2).

Figure 1. Web form, user control, and home page can be internationally internationally within Visual Studio .NET 2.0. This particular view is displayed as a default resource generated by some pages.

Local resource stores in .resx files, file naming rules correspond to the page served by local resources (see Figure 1). For example, after generating resources for the homepage named Site.Master, the new .resx file appears in / localResources. For web forms named Default.aspx, the generated resource is stored in a file called Default.aspx.resx.

Visual Studio Designer Checks Page and Its Controls (ASP.NET Server Control, Custom Control, and HTML Controls Set to Runat = "Server" - Find the properties tagged as localizableam - and populate these resources:

[Localizable]

Public Virtual String Text

{

Get {...}

Set {...}

}

The localized property of each control automatically presses the resource, uniquely identifies each property with the keyword. The keyword contains a prefix that identifies the page control name and attribute name. Each attribute value is set to the default value of the control unless specified in the control declaration. The following LinkButton declares a value specified for PostbackURL and Text properties:

Runat = "Server"> Change SELECTED CULTURE

Figure 2 shows the resource generated for the LinkButton after generating local resources for the host page (see CultureInfo.ascx in the sample project). Resources are stored in the resource file (see CultureInfo.ascx.resx), which is default unmatched attributes such as PostBackURL.

Figure 2. The hostage of the HTML control of the ASP.NET server control, custom server control, and server-side HTML controls generate local resources.

When generating resources, the control declaration is also modified to declare that the attribute is associated with the resource entity. Some new declarative expressions are also identified for the page parser, which triggers code generation, using resource values ​​to fill control properties at runtime. The declarative localized expression is a new construction of ASP.NET 2.0, similar to data binding statements, is specifically designed for accessing resources. These expressions have two forms: implicit and display. Implicit expression is automatically inserted when generated local resource generation and supports multiple resource entities to a set of control properties in a single declaration statement. Explicit expression is a declaration that developers added for further control of page localization.

The following hiped expressions identified by Meta: ResourceKey are generated for the LinkButton declaration, now, it sets the resource key prefix for this control:

Runat = "Server" Meta: ResourceKey = "LinkButtonResource1">

Change Selected Culture

After the resource entity of the control property uses this prefix, the runtime will automatically map to the correct control attribute. Each attribute value in the control declaration remains originally unable, including those values ​​that are pressed into the resource. These default values ​​will appear in the Design View, provide contexts for controls within the page. When parsing the page, the code generated by the localized expression applies the resource to the control properties. Developers do not need to write the code to instantiate the ResourceManager to access these local resources at runtime.

The runtime resource value is prioritized, and no resource is replaced by the default value. This is very useful for web developers because they can view page content before the site deployment is completed. In Properties WINDOW, the localized content is labeled by a special icon, indicating that their value is extracted from the resource. Figure 3 shows an ASP.NET ImageButton control, some of which bind to the shared resource (with blue identity), and other bind to local resources (with red identity). The contents of using expressions binding properties will be discussed in depth in the back section.

Figure 3. In the Properties WINDOW view, it is easy to locate the localization content identified by the special icon.

So far, the focus of discussion is to generate local resources. By default, it is intended to generate implicit localized expressions and resources for localized control properties, and attributes binding attributes to shared application resources. In addition, it may also automatically generate local resources for non-localized control properties, other HTML elements, and static content. Apply explicit localized expressions to these pages and control elements. In other words, developers can declare to identify content that require localization so that the resource generation of the page contains these content or selectively extract from alternatives.

Back to top

Shared application resources

Automatically generate local resources for each page will cause resurgence and excess translation work. Fortunately, ASP.NET 2.0 has a reuse model established by the home page and user control, which supports headlines, menus, bars, and other parts of HTML in Web forms. Each home page, user controls, and web forms have their own local resource collection, which reduces resource repetition. Moreover, the resource entity, such as terms, error messages, and function drivers (for example, direction attributes) are very useful when merging and sharing between all pages. The local resource of each page is automatically generated by the designer, while the shared application resources need to be created manually. This means adding a new application resource to the solution, placing it in a dedicated directory specified by the shared resource (this directory will be changed) in Beta 2). This is consistent with the method of generating shared resources in the 1.x application, however, the new resource editor simplifies creation and editing resource entities, and shared resources have been intelligent through intelligent perceivement support. Shared resources are also involved in the resolution of the new page and the runtime model of ASP.NET 2.0. They can be bound to the page by explicit localization expressions, at this time, the ResourceManager automatically instantiates and caches, and developers do not have to manage the life cycle of the running access resource.

Figure 2 and Figure 4. Display a new Managed Resource Editor for Visual Studio 2005. Figure 2 is a resource string editor that is similar to the resource editor in Visual Studio. Figure 4 illustrates a list of predefined resource types supported by the editor, including strings, icons, other image file types, audio file types, and other files with XML. In addition to these predefined types supported by the resource editor, it is also possible to program other complex types into resources. At this time, the basic resource file is based on XML.

Figure 4. New Managed Resource Editor integration supports a variety of predefined data types, providing replacement views, showing a thumbnail of Image resource types.

Document-based resources (eg, images, sounds, and XML files) are inserted via the editor, defined by default as a RESXFILEREF entity. For example, the following code is an external image and an XML file, respectively, a resource entity:

../ images / spain.gif; system.drawing.bitmap,

System.drawing, Version = 2.0.3600.0, Culture = Neutral,

PublicKeyToken = B03F5F7F11D50A3A

Runat = "Server" Meta: ResourceKey = "LinkButtonResource1">

Change Culture Settings

This expression sets the expected prefix for all resource entities related to the control properties - thus implicit expression. Automatic resource generation only considers localization properties, but actually any resource entity, you can bind to this property in the compiled page code as long as you use the prefix with a legitimate property name. In the example above, LinkButtonResource1 is a resource keyword prefix, and the resources displayed in Figure 2 are applied to all attributes of the same control instance (i.e., LinkButtonResource1.text) use this prefix.

This declarative statement (META: ResourceKey) notifies the ASP.NET page parser generating code for retrieval attribute values ​​from the default local resource. Results The code is ultimately accessing the resource using the runtime method with the help of getPageResourceObject (in this method name in Beta 2). In the sample code provided, the compiled CultureInfo.ascx page uses the following code to create and instantiate LinkButton and LNKSelectCulture:

LinkButtonButton1 = new linkbutton ();

THIS.LNKSELECTCULTURE = Button1;

Button1.id = "lnkselectculture";

Button1.postbackURL = "Selectculture.aspx"; button1.accesskey = (String)

Base.getPageResourceObject ("LinkButtonResource1.accessKey));

Button1.softKeyLabel = (String)

Base.getPageResourceObject ("LinkButtonResource1.softKeyLabel"));

Button1.text = (String)

Base.getPageResourceObject ("LinkButtonResource1.text")));

Button1.tooltip = (String)

Base.getPageResourceObject ("LinkButtonResource1.tooltip");

Button1.visible = ((bool)

Base.getPageResourceObject ("LinkButtonResource1.visible",

TypeOf (Control), "Visible");

Implicit localized expressions are applied to all server control declarations when generating page resources. You can use the following alternative syntax to cancel this behavior, indicating that the control should not be localized:

Runat = "Server" Meta: localize = "false"> Change Culture

Settings

Individual control properties that are not important to localization strategies can manually remove them from local resources using the Managed Resource Editor shown in Figure 2. This reduces the number of code generated by the page parser to apply the local resource entity to the control attribute, as the code only reflects those entities existing in the default local resource of the page. This also means that additional keywords added to localized resources will not be applied at runtime because this is not generated.

Such localized expressions use the new Expression Builder that is released with .NET Framework 2.0. Implicit localized expressions generate code from a single declarative statement to populate all the localized server control properties to save the developers. At the same time, it also deletes a manual step required to currently 1.x web applications, ie, a custom data binding statement or custom code is usually required to extract from a localized resource or data source. The following will preview how to automatically generate additional resources for static text and specific control properties (including those who do not have a localizableAttribute tag).

Back to top

Explicit localized expression

Although it is easy to automatically generate resources for localized control attributes, developers also need a solution that supports localized specific attribute values ​​and other content blocks. Explicit localization expressions are assigned a specific resource entity to the server control properties and other HTML elements. For example, the following imageButton control declaration uses an explicit expression to set the AlternateText property:

ImageURL = "~ / images / idositelogo.jpg"

AlternateText = '<% $ resources: missionStatement%>'

PostbackURL = "http://www.idesign.net" /> Explicit localized expressions use the following syntax:

<% $ resources: [ApplicationKey], ResourceKey%>

The above example omits ApplicationKey because the MissionsTatement value is extracted from local resource. The resourceKey value identifies the extracted resource entity, and the default value represents the designer default value. The designer default value exists only when designing, providing a developer or web designer editing page layout.

Explicit expression can also be generated by the Expressions dialog box in the "Properties" window shown in Figure 6. This dialog supports creation of explicit expression values ​​to bind control properties to local resources or shared resources.

Figure 6. Using the Expressions dialog box, developers can visually map resources to properties and generate explicit localized expressions.

With this dialog, developers can create explicit expressions using the "Properties" window, just like setting other control properties. If ClassName is omitted in Expression Properties (see Figure 6), the drop-down list will display the available local resource keywords (assuming a resource has been created). Otherwise, the explicit expression corresponding to the local resource will generate a local resource entity that matches the keywordKey. This else reduces the workload required for developers to create resource entities and generating fill properties at runtime.

If you access a shared resource, classname should identify an legitimate resource file name in the global resource directory. Unlike local resources, the explicit expressions corresponding to shared resources do not automatically generate these resources.

Implicit and explicit localized expressions can be used in order to extract from shared resource, while other properties are extracted from local resource. The following code example shows that the ImageButton control declares gets the AlternateText property from a shared resource (Glossary.resx), all other properties use implicit expression syntax from local resource extraction:

ImageURL = "~ / images / idositelogo.jpg"

AlternateText = '<% $ resources: glossary, missionsatate%>'

Postbackurl = "http://www.idesign.net"

Meta: ResourceKey = "ImageButtonResource1" />

After using explicit localized expressions, where the details are controlled, which attributes will be possible to be implemented. For control declarations including explicit and implicit expressions, page resources are generated in the following:

• Explicit expression binding properties If a shared resource is specified, it will be omitted in local resource generation. • The properties of the explicit expression binding of the local resource generates a resourceKey entry point for a default value. • The remaining unbinded expressive properties of explicit expressions, generate a resourceKey.PropertyName entry point with the default attribute value of the control declaration or control.

As previously mentioned, the page is parsed, the code in the declaration is automatically generated in order to extract the attribute value from the shared or local resource. In the sample code above, the resulting code creates an ImageButton control, sets the AlternateText property from the Glossary shared resource, and the remaining localized properties are set by local resource settings: imageButtonButton1 = new imageButton ();

// Other Initialization Code

Button1.id = "btnidesign";

Button1.accessKey = (String)

Base.getPageResourceObject ("ImageButtonResource1.accessKey);

Button1.alternateText = (string) Base.GetAppResourceObject ("Glossary",

"MissionStatement");

Button1.imageURL = (string)

Base.getPageResourceObject ("ImageButtonResource1.imageurl);

Button1.tooltip = (string)

Base.getPageResourceObject ("ImageButtonResource1.Tooltip");

Button1.visible = (bool)

Base.getPageResourceObject ("ImageButtonResource1.visible",

TypeOf (Control), "Visible");

Back to top

Localized HTML element and static text

Use implicit and explicit localization expressions, making it easy to generate resources for server control properties. However, preparing to localize a page, you must also consider other content such as HTML pages, direction properties, and static content. Localization expressions can also be applied to @PAGE instructions and other parts of HTML, first declare the other localization part of the generated page resource.

HTML control:

The HTML control is running on the server (runat = "Server") to reflect the advantages of implicit or explicit expressions. Once marked as a server-side control, a local resource that is automatically generated to the localized property applied to the control. HTML Server Controls are like ASP.NET, custom server controls, can also bind to implicit or explicit expressions, which can be generated using the previously mentioned Expressions dialog.

The HTML element of the header head can also be declare to resource, which is useful for page headings and style sheets. The HTML page title element is very special, because it is also a PAGE property that can be set by @PAGE instructions. By default, hidden expressions are assigned to each page when generated by the local resource:

<% @ Page language = "c #" codefile = "default.aspx.cs" inherits = "_ default" Meta: ResourceKey

This expression can also be modified to an explicit expression for extracting values ​​from a shared resource (not local resource):

These expressions cannot cover the element value of the HTML header, but without these values, the expression can also be applied directly to the <title> element, and the explicit expression is used below:</p> <p><head runat = "server"> <title></p> <p><asp: literal text = '<% $ resources: glossary, defaultPagetitle%>' Runat = "Server"> </ asp: literal></p> <p></ title></p> <p></ hEAD></p> <p>Directional attribute</p> <p>Improved direction setting support is added by the new Direction property, which is supported by controls such as <asp: panel>. Because a shared resource identifying the overall direction of the application is used, the default "LTR" direction can be identified in the default shared resource, and this value is overwritten based on the language that can specify "LTR".</p> <p>In order to control the direction of the browser scroll bar and set the overall direction of the site, the following explicit expression is extracted from the shared resource by the designer default value "LTR":</p> <p><html runat = "server" DIR = '<% $ resources: common, direction%>>></p> <p>...</p> <p></ html></p> <p>Panel can also be used to set the direction of the included control:</p> <p><asp: panel runat = "server" direction = '<% resources: common, direction%>>>></p> <p>...</p> <p></ asp: panel></p> <p>For more information on the Visual Studio .NET direction, please visit this site.</p> <p>Static text</p> <p>Localization expressions are used to set control properties and other HTML elements; however, many web pages to perform localized Web have already included a large amount of static content blocks with ASP.NET controls. The new ASP.NET Localize control is used to mark the static content as a localized so that the resource generates this part of the static content. If the Control is the message of Meta: ResourceKey, the specified keyword (equally adapted to other controls):</p> <p><ask: localize id = "welcomecontent" runat = "server"</p> <p>Meta: ResourceKey = "Welcome"> Welcome! </ asp: localize></p> <p>The above example generates a new local resource entry point for the Text property of the Localize control, and the resource prefix is ​​"Welcome.Text). To explicitly populate static content from a shared resource, you can specify a Text property through an explicit localized expression:</p> <p><ask: localize id = "welcomeContent" runat = "server" text = '<% $ resources: glossary,</p> <p>Welcometext%>> Welcome! </ asp: localize></p> <p>As with other situations, these declarative statements analyze into code to request the Resource Settings Control Properties, here is the Text property. Any HTML tag that appears in the control statement statement will be included in the resource generation, which makes the translation process complex, so it is best not to include the tag.</p> <p>Localize control is superior to its base class LITERAL control, it is very similar to the Literal control when it is runtime; however, the designer ignores it and allows developers to edit static content directly in Design View (unlike Literal Controls) In the Design View it is bound to a container). Back to top</p> <p>Resource localization and deployment</p> <p>The new statement statement, the automatic generation of page resources, and strong type sharing resources make developers to prepare localized web applications easier. The default resource stored under / localresources and / resources directory (which is the local resource and shared resource) can translate the supported language, and the translated resource is copied to the source directory. The naming rules of the translation resource follow the rules used by 1.x. The translated .resx file name contains language code. Figure 7 shows an extension view of an example engineering, where the page resource is translated into Spanish, French and Italian.</p> <p>Figure 7. Consistent with the resource naming rules of 1.x, name the .resx file according to the language code.</p> <p>Typical .NET Framework 1.x application is published in the localized accessory set, and ASP.NET 2.0 has new optional deployments:</p> <p>1. ASP.NET 2.0 Operation Continues to support the traditional deployment model - / bin directory contains local assembly dependencies, and subdirectory for each support language contains the attached (only resource) assembly. 2. ASP.NET 2.0 Precipate the web page (ie page, user control, and main page), local resources, and code separation files are processed as a separate file - compile them to the deployable assembly. Shared resources are also precompiled to the assembly used to deploy. Any reference resource entry point (eg, image or XML file) is compiled into the program set unit. Basically, the pre-compilation of the ASP.NET 2.0 web application is a binary container that provides higher level protection by encapsulation. 3. ASP.NET 2.0 also supports complete runtime compilation. This means all web pages, code separation files, other source code, resource (sharing, and local), and other supported application files can be deployed in the original format. Then, the runtime compiler is responsible for resolving the page and generates an assembly at any time. This model provides maximum flexibility, but mainly for lightweight web applications, such applications are frequently changed, and high-level source code security is not required. 4. ASP.NET 2.0 is also possible to implement a mixing multiple features. That is, compiling all code separated files and other resources to the binary set for deployment, the page and resources can be deployed into strength. This can flexibly edit page layout and resource content or deploy new native resources for one or more pages, without affecting unaffected application sets.</p> <p>For second, third, four, the ASP.NET 2.0 compiler automatically compiles the / localresources and / resources directory to the assembly. As for the third and fourth items, the compilation of local resources is compiled, that is, the first access page or modify the page source (or its .resx file). " Due to the compilation provider with .RESX, it is possible to deploy without compiling steps.</p> <p>As mentioned in the first item, it is still existing for the reusant support for 1.x assembly, non-specific resources and related accessory assemblies. This deployment model does not use 2.0 localized expressions, and access these resources are not conducted by the default runtime resource provider model. Extensible models with expression compilers and resource providers, the resources deployment of efficient features and 1.x supported by Comprehensive Utilization 2.0 will be useful.</p> <p>Back to top</p> <p>Running resource provider</p> <p>In order to use RESOURCEMANAGER in the ASP.NET 1.x application, instantiate ResourceManager in the code before performing data binding statements or applications from other mechanisms of resource retrieval values. When accessing local resources and sharing resources, ASP.NET .0 is automatically instantiated for resource manager automatically, and does not need to write code to manage this process. Because the declarative statement fills the control properties and HTML elements using the declarative statement, do not need to write any code to generate a fully localized page! The default ResourceProviderFactory is responsible for using the related designer factory to instantiate the resource provider when designing the relevant designer factory, instantiate the resource provider for the page and shared resource. Developers can write code to access the value of local resources, the method is explicitly published in beta 1 PageReSourceObject:</p> <p>IF (this.context.user.Identity.isauthenticated)</p> <p>Mnulogin.text = getPageResourceObject ("login");</p> <p>Else</p> <p>Mnulogin.text = string.format (getPageResourceObject ("logoutuser",</p> <p>This.Context.user.Identity.name);</p> <p>When the HTML output of the resource requires runtime decisions, it can be used to overwrite the declarative localized expression. To access the shared page resource, you can use another method disclosed in the Page object:</p> <p>String cultures =</p> <p>This.GetAppResourceObject ("Supportedcultures");</p> <p>For shared resources, developers are more inclined to use intelligent perception and strong type resource access. The following example is to retrieve an XML resource stored as a String type:</p> <p>String Cultures = Resources.cultures.supportedcultures;</p> <p>In the end, getPageResourceObject and GetAppresourceObject access the correct resource by configuring resource providers. If a custom resource provider is created, these methods will be able to retrieve from those shared resources using GetAppResourceObject.</p> <p>Back to top</p> <p>Preferred language selection</p> <p>ASP.NET 1.x applications traditionally use two main methods to select the language each request. For applications that copy the entire site in a particular language subdirectory, the language and UI language used by the <globalization> element in web.config:</p> <p><system.Web></p> <p><globalization culture = "es-es" uicle = "es"></p> <p></system.web></p> <p>These declarative settings are useless to use a single code base. Manually set the language of each request thread that requires runtime code so that you can dynamically select the language for each requestible user. The user's preferred language can collect from the database configuration file, a language setting of an HTTP cookie or web browser. In any case, the UI language of the setting request thread determines which localized resource extracting resources from the runtime RSOOURCEMANAGER, and the language setting affects the format related to the language.</p> <p>ASP.NET 2.0 introduces a new feature that automatically selects runtime language based on the favorite of the WEB browser. The @PAGE instruction is used to identify whether the specific page should be performed according to the browser's preference, it also supports the settings of the language and UI language:</p> <p><% @ Page uicle = "auto" culture = "auto"> application web.config file can also apply this setting to the entire application:</p> <p><system.Web></p> <p><globalization culture = "auto: en-us" uicle = "auto: en"></p> <p></system.web></p> <p>If the HTTP header is not available, the AUTO's colon allows you to specify a default language. Because a specific language must be set, the above example must be EN-US as a language displayed.</p> <p>The final result is the actuT_lang header that automatically detects the browser when running, and the thread is set to the first language in the user language preferred list in the early stage of the page cycle. If a configuration file is stored for the application, or the user can select a specific language through the site, the developer must write code to override the AUTO settings processed at runtime. The sample code illustrates a use skill of this situation.</p> <p>Back to top</p> <p>summary</p> <p>In order to more quickly adapt to the requirements of product release throughout the world, it is imperative to define a globalization strategy in the early days of the development cycle. Using ASP.NET .0 These new localization features, developers can make more easily implement the strategy of localized applications, while reducing the system overhead of the development cycle. The page resource automatically generated and the new Managed Resource Editor makes creating a web application resource more natural. Using a declarative localized expression, you may ensure that all necessary page elements are localized and help automatically generate appropriate page resources. A new runtime model means that developers can choose no longer compile the subscriber set, no longer instantiate the resource manager, and do not set the request thread according to the language. It will eventually be conducive to publishing a strong web application with a single code set, thereby reducing the cost and payment of the solution applied to the global market.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-132249.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="132249" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.028</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'IyZzJUztjAkX_2BIPmXwB1w2EhznCAIythZb7gn2hSBQ_2BdtU6L11bWqG19oaT3NejdWq8ATmPrMCJcW3iqIucerg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>