{"id":58003,"date":"2023-01-29T09:04:37","date_gmt":"2023-01-29T08:04:37","guid":{"rendered":"https:\/\/ar3dp.de\/docs\/programmieren\/net-maui-basis-applikation-app-template\/lokalisierung\/"},"modified":"2023-01-29T09:04:37","modified_gmt":"2023-01-29T08:04:37","slug":"lokalisierung","status":"publish","type":"docs","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/lokalisierung\/","title":{"rendered":"Localization"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Unsere App-Vorlage bietet bereits eine integrierte Lokalisierung, sprich dem Nutzer wird automatisch die Sprache angezeigt, welche auf seinem Ger\u00e4t eingestellt ist (sofern es daf\u00fcr eine Sprachdatei gibt). Sollte die Sprache unbekannt sein, dann wird automatisch das englische Sprachpaket geladen.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lokalisierte Inhalte verwenden<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Um auf lokalisierte Inhalte in der App zuzugreifen, k\u00f6nnt Ihr wie folgt vorgehen.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Namespace<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Um Zugriff auf die Lokalisierung zu erhalten, m\u00fcsst Ihr folgenden Namespace einbinden.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csharp&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;C#&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;csharp&quot;}\">using AppBasement.Resources.Localization;<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application\/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}\">xmlns:localization=&quot;clr-namespace:AppBasement.Resources.Localization&quot;<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">C#<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In Klassen k\u00f6nnt Ihr \u00fcber das &#8220;Strings&#8221;-Objekt auf die \u00dcbersetzung zugreifen.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csharp&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;C#&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;csharp&quot;}\">await Shell.Current.DisplayAlert(\n    Strings.DialogActionNotAvailableInDemoModeHeadline,\n    Strings.DialogActionNotAvailableInDemoModeContent,\n    Strings.Close\n    );<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">XAML<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In XAML Dateien k\u00f6nnt Ihr wie folgt auf die \u00dcbersetzungen zugreifen.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application\/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}\">Text=&quot;{x:Static localization:Strings.ButtonClose}&quot;<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Neue Sprache hinzuf\u00fcgen<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Um eine neue Sprache hinzuzuf\u00fcgen, sind folgende Schritte zu beachten.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Neue Sprachdatei anlegen (Ressourcen-Datei)<\/h3>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"455\" height=\"452\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_1.png\" alt=\"Projektmappen-Explorer\" class=\"wp-image-58122\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_1.png 455w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_1-180x180.png 180w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_1-12x12.png 12w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_1-380x377.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_1-100x100.png 100w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_1-50x50.png 50w\" sizes=\"(max-width: 455px) 100vw, 455px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p class=\"wp-block-paragraph\">Im Projektmappen-Explorer w\u00e4hlt Ihr den Ordner &#8220;Localization&#8221; mit der rechten Maustaste an und f\u00fcgt anschlie\u00dfend \u00fcber den Men\u00fcpunkt &#8220;Hinzuf\u00fcgen =&gt; Neues Element&#8221; ein neues <strong>Ressourcendatei (resx) <\/strong>hinzu.<\/p>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Die Dateivorlage findet Ihr am schnellsten, wenn Ihr &#8220;res&#8221; in der Suchleiste oben rechts angebt.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"941\" height=\"653\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_2.png\" alt=\"\" class=\"wp-image-58123\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_2.png 941w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_2-768x533.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_2-18x12.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_2-380x264.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_2-590x409.png 590w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Benennt die Datei &#8220;Strings.xx-XX.resx&#8221;, wobei &#8220;xx-XX&#8221; f\u00fcr die gew\u00fcnschte Sprache steht, im Beispiel hier &#8220;de-DE&#8221; f\u00fcr Deutsch. Eine \u00dcbersicht aller L\u00e4ndercodes findet Ihr, unter anderem, <a href=\"https:\/\/www.fincher.org\/Utilities\/CountryLanguageList.shtml\" target=\"_blank\" data-type=\"URL\" data-id=\"https:\/\/www.fincher.org\/Utilities\/CountryLanguageList.shtml\" rel=\"noreferrer noopener nofollow\">hier<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sprachdatei auf \u00f6ffentlich stellen<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Nach dem Hinzuf\u00fcgen der Sprachdatei wird diese in der Regel automatisch ge\u00f6ffnet. Falls nicht, die neue Datei im &#8220;<span class=\"font-weight-semi-bold\">Localization<\/span>&#8220;-Ordner doppelklicken. Bei <span class=\"font-weight-semi-bold\">Zugriffsmodifier <\/span>den Wert auf &#8220;<span class=\"font-weight-semi-bold\">public<\/span>&#8221; setzen. Andernfalls ist der Inhalt nicht zugreifbar.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"742\" height=\"290\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_3.png\" alt=\"\" class=\"wp-image-58126\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_3.png 742w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_3-18x7.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_3-380x149.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_3-590x231.png 590w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">\u00dcbersetzung einf\u00fcgen<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Nun kopiert den Inhalt aus der originalen &#8220;Strings.resx&#8221;-Datei und \u00fcbersetzt die Spalte &#8220;Wert&#8221; in die gew\u00fcnschte Sprache.<\/p>\n\n\n\n<div class=\"alert-box alert text-center font-size-1 rounded-0 mb-0\" style=\"background-color:#ffbf00\"><span class=\"text text-white\"><strong class=\"text-uppercase\">Achtung!<\/strong> Die Spalte Name darf nicht ge\u00e4ndert werden! Dieser Wert dient als Schl\u00fcssel.<\/span><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Flagge einf\u00fcgen<\/h3>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"322\" height=\"400\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_4.png\" alt=\"\" class=\"wp-image-58129\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_4.png 322w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_4-10x12.png 10w\" sizes=\"(max-width: 322px) 100vw, 322px\" \/><\/figure>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p class=\"wp-block-paragraph\">In den Spracheinstellungen werden zu den jeweiligen Sprachen auch die Flaggen angezeigt. Diese werden im &#8220;<strong>Resourcen<\/strong>&#8220;-Ordner &#8220;Images\/Flags&#8221; verwaltet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Die g\u00e4ngigsten Flaggen sind hier bereits verf\u00fcgbar. Sollte hier Ihre Sprache fehlen, dann k\u00f6nnen Sie hier einfach die fehlende Flagge mit hinzuf\u00fcgen oder uns kontaktieren und wir aktualisieren das Template dementsprechend.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span class=\"font-weight-semi-bold\">Achtung!<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sollten Sie hier ein neues Bild bzw. Flagge hinzuf\u00fcgen, beachten Sie bitte die n\u00f6tigen Build-Einstellungen der anderen Dateien.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Sprache registrieren<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Abschlie\u00dfend muss die Sprache im <strong>LocalizationManager<\/strong> hinzugef\u00fcgt werden. Dies muss in der &#8220;AppHostBuilderExtension.cs&#8221; Datei erledigt werden. In der <code>ConfigureApp<\/code> Methode findet Ihr folgenden Abschnitt.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csharp&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;C#&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;csharp&quot;}\">\/\/ Available languages\n                .ConfigureLocalizationManager([\n                    \/\/https:\/\/www.fincher.org\/Utilities\/CountryLanguageList.shtml\n                    new(&quot;English&quot;, &quot;English&quot;, LocalizationManager.GetImageUri(&quot;&quot;, &quot;en-US&quot;), &quot;Andreas&quot;, &quot;en-US&quot;, 100, true),\n                    new(&quot;German&quot;, &quot;Deutsch&quot;, LocalizationManager.GetImageUri(&quot;&quot;, &quot;de-DE&quot;), &quot;Andreas&quot;, &quot;de-DE&quot;, 100, true),\n                ], &quot;&quot;)<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Kopiert hier einfach einen der Eintr\u00e4ge und passt diesen f\u00fcr die gew\u00fcnschte Sprache an.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sprache einstellen und \u00fcberpr\u00fcfen<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Nun sollte alles soweit angepasst werden und Ihr k\u00f6nnt die Funktion bzw. die neue Sprache \u00fcberpr\u00fcfen. Erstellt und startet dazu die App und besucht die Spracheinstellungen.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" width=\"1242\" height=\"2688\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5.png\" alt=\"\" class=\"wp-image-58132\" style=\"width:621px;height:1344px\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5.png 1242w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-768x1662.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-710x1536.png 710w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-946x2048.png 946w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-6x12.png 6w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-380x822.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-590x1277.png 590w\" sizes=\"(max-width: 1242px) 100vw, 1242px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Zum Wechseln der Sprache einfach auf die gew\u00fcnschte Sprache in der Liste Klicken und die App neu starten. Anschlie\u00dfend sollte die App in der gew\u00fcnschten Sprache erscheinen.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unsere App-Vorlage bietet bereits eine integrierte Lokalisierung, sprich dem Nutzer wird automatisch die Sprache angezeigt, welche auf seinem Ger\u00e4t eingestellt ist (sofern es daf\u00fcr eine Sprachdatei gibt). Sollte die Sprache unbekannt sein, dann wird automatisch das englische Sprachpaket geladen. Lokalisierte Inhalte verwenden Um auf lokalisierte Inhalte in der App zuzugreifen, k\u00f6nnt Ihr wie folgt vorgehen&#8230;.<\/p>","protected":false},"author":1,"featured_media":0,"parent":57992,"menu_order":4,"comment_status":"open","ping_status":"closed","template":"","meta":{"_featured":false,"_is_vendor_doc":"0","footnotes":""},"doc_tag":[],"class_list":["post-58003","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/comments?post=58003"}],"version-history":[{"count":1,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58003\/revisions"}],"predecessor-version":[{"id":58959,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58003\/revisions\/58959"}],"up":[{"embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/57992"}],"next":[{"title":"ViewModels","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/viewmodels\/","href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/57995"}],"prev":[{"title":"Navigation","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/navigation\/","href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58136"}],"wp:attachment":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/media?parent=58003"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/doc_tag?post=58003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}