bitwarden-android/src/App/Utilities/I18nExtension.cs

38 lines
945 B
C#
Raw Normal View History

2019-04-11 22:33:10 +03:00
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Bit.App.Utilities
{
2019-04-11 22:43:13 +03:00
[ContentProperty("Id")]
2019-04-22 20:47:45 +03:00
public class I18nExtension : IMarkupExtension
2019-04-11 22:33:10 +03:00
{
private II18nService _i18nService;
2019-04-22 20:47:45 +03:00
public I18nExtension()
2019-04-11 22:33:10 +03:00
{
_i18nService = ServiceContainer.Resolve<II18nService>("i18nService");
}
public string Id { get; set; }
public string P1 { get; set; }
public string P2 { get; set; }
public string P3 { get; set; }
2019-06-21 00:05:28 +03:00
public bool Header { get; set; }
2019-04-11 22:33:10 +03:00
public object ProvideValue(IServiceProvider serviceProvider)
{
2019-06-21 00:05:28 +03:00
var val = _i18nService.T(Id, P1, P2, P3);
2019-06-21 00:26:42 +03:00
/*
if (Header && Device.RuntimePlatform == Device.iOS)
2019-06-21 00:05:28 +03:00
{
return val.ToUpper();
}
2019-06-21 00:26:42 +03:00
*/
2019-06-21 00:05:28 +03:00
return val;
2019-04-11 22:33:10 +03:00
}
}
}