|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
namespace ex_Localization3.Resources.Localization;
|
|
|
|
|
|
|
|
|
@ -43,10 +44,9 @@ public class LocalizedStringExtension : IMarkupExtension<string>
|
|
|
|
|
IProvideValueTarget? provideValueTarget = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;
|
|
|
|
|
CultureChanged += (src, args) =>
|
|
|
|
|
{
|
|
|
|
|
(provideValueTarget?.TargetObject as BindableObject)?.SetValue((provideValueTarget?.TargetProperty as BindableProperty), typeof(AppResourcesVM).GetProperty(Key)?.GetValue(AppRes) as string ?? "");
|
|
|
|
|
(provideValueTarget?.TargetObject as BindableObject)?.SetValue((provideValueTarget?.TargetProperty as BindableProperty), typeof(AppResources).GetProperty(Key, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null) as string ?? "");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return typeof(AppResourcesVM).GetProperty(Key)?.GetValue(AppRes) as string ?? "";
|
|
|
|
|
return typeof(AppResources).GetProperty(Key, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null) as string ?? "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
|
|
|
|
|