{"id":58676,"date":"2023-12-25T09:40:25","date_gmt":"2023-12-25T08:40:25","guid":{"rendered":"https:\/\/ar3dp.de\/docs\/programmieren\/xamarin-forms-basis-applikation-app-template\/lokalisierung\/"},"modified":"2023-12-25T09:40:25","modified_gmt":"2023-12-25T08:40:25","slug":"lokalisierung","status":"publish","type":"docs","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/xamarin-forms-basis-applikation-app-template\/lokalisierung\/","title":{"rendered":"Localization"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Our app template already offers integrated localization, i.e. the user is automatically shown the language that is set on their device (if there is a language file for it). If the language is unknown, the English language pack will be loaded automatically.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Use localized content<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To access localized content in the app, you can do the following.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Namespace<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To get access to the localization, you have to include the following namespace.<\/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 files you can access the translations as follows.<\/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\">Add new language<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To add a new language, follow the steps below.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a new language file (resource file)<\/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\">Set language file to public<\/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\">Insert translation<\/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 translation-block\" style=\"background-color:#ffbf00\"><span class=\"text text-white\"><strong class=\"text-uppercase\">Caution!<\/strong> The Name column must not be changed! This value serves as a key.<\/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\">The most common flags are already available here. If your language is missing here, you can simply add the missing flag here or contact us and we will update the template accordingly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span class=\"font-weight-semi-bold\">Danger!<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you add a new image or flag here, please note the necessary build settings for the other files.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Register language<\/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;<strong>App.xaml.cs<\/strong>&#8221; Datei erledigt werden. Im Constructor 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\nLocalizationManager.Instance.SetLanguages(new List&lt;LocalizationInfo&gt;()\n{\n    \/\/https:\/\/www.fincher.org\/Utilities\/CountryLanguageList.shtml\n    new LocalizationInfo(&quot;English&quot;, &quot;English&quot;, LocalizationManager.Instance.GetImageUri(&quot;en-US&quot;), &quot;Andreas&quot;, &quot;en-US&quot;, 100, true),\n    new LocalizationInfo(&quot;German&quot;, &quot;Deutsch&quot;,   LocalizationManager.Instance.GetImageUri(&quot;de-DE&quot;), &quot;Andreas&quot;, &quot;de-DE&quot;, 100, true),\n});<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Simply copy one of the entries here and adjust it for the desired language.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Set and check language<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now everything should be adjusted and you can check the function or the new language. To do this, create and start the app and visit the language settings.<\/p>\n\n\n<div class=\"wp-block-image is-resized\">\n<figure class=\"aligncenter size-medium\"><img decoding=\"async\" width=\"750\" height=\"500\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-750x500.png\" alt=\"\" class=\"wp-image-58132\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-750x500.png 750w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-480x320.png 480w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/05\/maui_app_template_localize_5-600x400.png 600w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">To change the language, simply click on the desired language in the list and restart the app. The app should then appear in the desired language.<\/p>","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":58608,"menu_order":3,"comment_status":"open","ping_status":"closed","template":"","meta":{"_featured":false,"_is_vendor_doc":"0","footnotes":""},"doc_tag":[],"class_list":["post-58676","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58676","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=58676"}],"version-history":[{"count":1,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58676\/revisions"}],"predecessor-version":[{"id":58678,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58676\/revisions\/58678"}],"up":[{"embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58608"}],"next":[{"title":"Firebase","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/xamarin-forms-basis-applikation-app-template\/firebase\/","href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58684"}],"prev":[{"title":"Navigation","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/xamarin-forms-basis-applikation-app-template\/navigation\/","href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58673"}],"wp:attachment":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/media?parent=58676"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/doc_tag?post=58676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}