mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-17 15:27:43 +01:00
fixes to i18n service
This commit is contained in:
parent
6ee109dc80
commit
567d527a71
@ -4,6 +4,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="Bit.App.Pages.GeneratorPage"
|
x:Class="Bit.App.Pages.GeneratorPage"
|
||||||
xmlns:pages="clr-namespace:Bit.App.Pages"
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
|
xmlns:i18n="clr-namespace:Bit.App.Utilities"
|
||||||
x:DataType="pages:GeneratorPageViewModel"
|
x:DataType="pages:GeneratorPageViewModel"
|
||||||
Title="{Binding PageTitle}">
|
Title="{Binding PageTitle}">
|
||||||
<ContentPage.BindingContext>
|
<ContentPage.BindingContext>
|
||||||
@ -16,6 +17,10 @@
|
|||||||
Text="Generator!"
|
Text="Generator!"
|
||||||
HorizontalOptions="Center"
|
HorizontalOptions="Center"
|
||||||
VerticalOptions="CenterAndExpand" />
|
VerticalOptions="CenterAndExpand" />
|
||||||
|
<Label
|
||||||
|
Text="{i18n:Translate AttachmentLargeWarning, P1='10 MB'}"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
VerticalOptions="CenterAndExpand" />
|
||||||
<Label
|
<Label
|
||||||
Text=""
|
Text=""
|
||||||
HorizontalOptions="Center"
|
HorizontalOptions="Center"
|
||||||
|
@ -10,7 +10,7 @@ namespace Bit.App.Services
|
|||||||
{
|
{
|
||||||
public class MobileI18nService : II18nService
|
public class MobileI18nService : II18nService
|
||||||
{
|
{
|
||||||
private const string ResourceId = "UsingResxLocalization.Resx.AppResources";
|
private const string ResourceId = "Bit.App.Resources.AppResources";
|
||||||
|
|
||||||
private static readonly Lazy<ResourceManager> _resourceManager = new Lazy<ResourceManager>(() =>
|
private static readonly Lazy<ResourceManager> _resourceManager = new Lazy<ResourceManager>(() =>
|
||||||
new ResourceManager(ResourceId, IntrospectionExtensions.GetTypeInfo(typeof(MobileI18nService)).Assembly));
|
new ResourceManager(ResourceId, IntrospectionExtensions.GetTypeInfo(typeof(MobileI18nService)).Assembly));
|
||||||
@ -41,12 +41,12 @@ namespace Bit.App.Services
|
|||||||
Thread.CurrentThread.CurrentUICulture = Culture;
|
Thread.CurrentThread.CurrentUICulture = Culture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string T(string id, params string[] p)
|
public string T(string id, string p1, string p2, string p3)
|
||||||
{
|
{
|
||||||
return Translate(id, p);
|
return Translate(id, p1, p2, p3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Translate(string id, params string[] p)
|
public string Translate(string id, string p1, string p2, string p3)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrWhiteSpace(id))
|
if(string.IsNullOrWhiteSpace(id))
|
||||||
{
|
{
|
||||||
@ -61,7 +61,19 @@ namespace Bit.App.Services
|
|||||||
result = $"{{{id}}}";
|
result = $"{{{id}}}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string.Format(result, p);
|
if(p1 == null && p2 == null && p3 == null)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else if(p2 == null && p3 == null)
|
||||||
|
{
|
||||||
|
return string.Format(result, p1);
|
||||||
|
}
|
||||||
|
else if(p3 == null)
|
||||||
|
{
|
||||||
|
return string.Format(result, p1, p2);
|
||||||
|
}
|
||||||
|
return string.Format(result, p1, p2, p3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using Xamarin.Forms.Xaml;
|
|||||||
|
|
||||||
namespace Bit.App.Utilities
|
namespace Bit.App.Utilities
|
||||||
{
|
{
|
||||||
[ContentProperty("Text")]
|
[ContentProperty("Id")]
|
||||||
public class TranslateExtension : IMarkupExtension
|
public class TranslateExtension : IMarkupExtension
|
||||||
{
|
{
|
||||||
private II18nService _i18nService;
|
private II18nService _i18nService;
|
||||||
|
@ -5,7 +5,7 @@ namespace Bit.Core.Abstractions
|
|||||||
public interface II18nService
|
public interface II18nService
|
||||||
{
|
{
|
||||||
CultureInfo Culture { get; set; }
|
CultureInfo Culture { get; set; }
|
||||||
string T(string id, params string[] p);
|
string T(string id, string p1, string p2, string p3);
|
||||||
string Translate(string id, params string[] p);
|
string Translate(string id, string p1, string p2, string p3);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user