ASP.NET Localization

From no name for this wiki
Revision as of 10:13, 30 October 2010 by Claude (talk | contribs) (Resourcen)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

So übersetzt man eine ASP.NET Seite:

Default.aspx:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplicationInternationalization._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        <asp:Label ID="LabelTitle" runat="server" Text="<%$ Resources:labeltitle %>"/>
    </h2>
        <asp:Label ID="LabelContent" runat="server" Text="<%$ Resources:MyResources, someglobalkey %>"/>
        <asp:Label ID="LabelXY" runat="server" meta:resourcekey="LabelXYkEY" /> 
</asp:Content>

Lokale Resourcen: Ordner App_LocalResources anlegen. Resource-Datein mit dem gleichen Namen anlegen, mit der Endung .resx. Strings in Form von Key-Value Paaren hinzufügen. Beispiele:

Default.aspx.resx
Default.aspx.fr.resx

für meta Dinger Sachen wie LabelXYkEY.Text anlegen.

Gobale Resourcen: Ordner App_GlobalResources anlegen. Eine Datei Names MyResources.resx in diesem Ordner anlegen. Strings in Form von Key-Value Paaren hinzufügen.

Spezielles Control:

<asp:Localize runat="server" meta:resourcekey="LiteralResource1">Disclaimer: The rate calculation above is based on 
exchange rates published on Dec 9th, 2004 by the United States Federal Reserve 
Bank of New York. For up-to-date exchange rates please go to the website of this 
organization. This sample application is not intended to provide accurate or 
up-to-date currency conversions.</asp:Localize>

Spezielle Methoden in Page: GetLocalResourceObject http://msdn.microsoft.com/de-de/library/ms153597.aspx

Resourcen