From 35f61826895cd36f6dbf47599c5a5a96ef561e7c Mon Sep 17 00:00:00 2001 From: Chebotov Nikolay Date: Tue, 24 Mar 2020 17:19:19 +0300 Subject: [PATCH] Add fix: change TabBar localization by settings --- DotNetRu.Clients.UI/AppShell.xaml | 4 ++++ DotNetRu.Clients.UI/AppShell.xaml.cs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/DotNetRu.Clients.UI/AppShell.xaml b/DotNetRu.Clients.UI/AppShell.xaml index bd518245..7778aef6 100644 --- a/DotNetRu.Clients.UI/AppShell.xaml +++ b/DotNetRu.Clients.UI/AppShell.xaml @@ -26,24 +26,28 @@ diff --git a/DotNetRu.Clients.UI/AppShell.xaml.cs b/DotNetRu.Clients.UI/AppShell.xaml.cs index 520020c7..90ed81ec 100644 --- a/DotNetRu.Clients.UI/AppShell.xaml.cs +++ b/DotNetRu.Clients.UI/AppShell.xaml.cs @@ -1,3 +1,6 @@ +using DotNetRu.Clients.Portable.Helpers; +using DotNetRu.Clients.Portable.ViewModel; +using DotNetRu.Utils.Helpers; using Xamarin.Forms; namespace DotNetRu.Clients.UI @@ -15,6 +18,22 @@ public AppShell() // Can't set BackgrounColor as StaticResource, see https://github.com/xamarin/Xamarin.Forms/issues/7055 SetBackgroundColor(this, backgroundColor); + + MessagingCenter.Subscribe(this, MessageKeys.LanguageChanged, sender => this.UpdateTabBarLocalization()); + } + + public void UpdateTabBarLocalization() + { + Device.BeginInvokeOnMainThread(() => + { + if (this.BindingContext is ViewModelBase viewModel) + { + this.NewsTab.Title = viewModel.Resources["News"] ?? this.NewsTab.Title; + this.SpeakersTab.Title = viewModel.Resources["Speakers"] ?? this.SpeakersTab.Title; + this.MeetupsTab.Title = viewModel.Resources["Meetups"] ?? this.MeetupsTab.Title; + this.AboutTab.Title = viewModel.Resources["About"] ?? this.AboutTab.Title; + } + }); } } }