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

38 lines
945 B
C#
Raw Normal View History

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