i18n extension

This commit is contained in:
Kyle Spearrin 2019-04-22 13:47:45 -04:00
parent b48c231500
commit c3fe3292ad
5 changed files with 17 additions and 17 deletions

View File

@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Pages.LoginPage"
xmlns:pages="clr-namespace:Bit.App.Pages"
xmlns:i18n="clr-namespace:Bit.App.Utilities"
xmlns:u="clr-namespace:Bit.App.Utilities"
xmlns:bv="clr-namespace:Bit.App.Controls.BoxedView"
x:DataType="pages:LoginPageViewModel"
Title="{Binding PageTitle}">
@ -13,22 +13,22 @@
</ContentPage.BindingContext>
<ContentPage.ToolbarItems>
<ToolbarItem Icon="cogs.png" Text="{i18n:Translate LogIn}" Clicked="LogIn_Clicked" />
<ToolbarItem Icon="cogs.png" Text="{u:I18n LogIn}" Clicked="LogIn_Clicked" />
</ContentPage.ToolbarItems>
<StackLayout>
<bv:BoxedView HasUnevenRows="True" VerticalOptions="Start">
<bv:BoxedSection HeaderHeight="0">
<bv:EntryCell Title="{i18n:Translate EmailAddress}"
<bv:EntryCell Title="{u:I18n EmailAddress}"
ValueText="{Binding Email}" />
<bv:EntryCell Title="{i18n:Translate MasterPassword}"
<bv:EntryCell Title="{u:I18n MasterPassword}"
ValueText="{Binding MasterPassword}"
IsPassword="True"
Button1Icon="cogs"
Button1Command="{Binding ShowPasswordCommand}" />
</bv:BoxedSection>
</bv:BoxedView>
<Button Text="{i18n:Translate GetPasswordHint}" VerticalOptions="EndAndExpand"></Button>
<Button Text="{u:I18n GetPasswordHint}" VerticalOptions="EndAndExpand"></Button>
</StackLayout>
</ContentPage>

View File

@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Pages.GeneratorPage"
xmlns:pages="clr-namespace:Bit.App.Pages"
xmlns:i18n="clr-namespace:Bit.App.Utilities"
xmlns:u="clr-namespace:Bit.App.Utilities"
x:DataType="pages:GeneratorPageViewModel"
Title="{Binding PageTitle}">
<ContentPage.BindingContext>
@ -18,7 +18,7 @@
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Label
Text="{i18n:Translate AttachmentLargeWarning, P1='10 MB'}"
Text="{u:I18n AttachmentLargeWarning, P1='10 MB'}"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Label

View File

@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Pages.HomePage"
xmlns:pages="clr-namespace:Bit.App.Pages"
xmlns:i18n="clr-namespace:Bit.App.Utilities"
xmlns:u="clr-namespace:Bit.App.Utilities"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
x:DataType="pages:HomeViewModel"
Title="{Binding PageTitle}">
@ -19,12 +19,12 @@
<StackLayout VerticalOptions="CenterAndExpand">
<Image Source="logo.png"
VerticalOptions="Center" />
<Label Text="{i18n:Translate LoginOrCreateNewAccount}"
<Label Text="{u:I18n LoginOrCreateNewAccount}"
class="text-lg"
HorizontalTextAlignment="Center"></Label>
<Button Text="{i18n:Translate LogIn}"
<Button Text="{u:I18n LogIn}"
Clicked="LogIn_Clicked"></Button>
<Button Text="{i18n:Translate CreateAccount}"></Button>
<Button Text="{u:I18n CreateAccount}"></Button>
</StackLayout>
</StackLayout>

View File

@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Pages.ViewPage"
xmlns:pages="clr-namespace:Bit.App.Pages"
xmlns:i18n="clr-namespace:Bit.App.Utilities"
xmlns:u="clr-namespace:Bit.App.Utilities"
xmlns:bv="clr-namespace:Bit.App.Controls.BoxedView"
x:DataType="pages:ViewPageViewModel"
Title="{Binding PageTitle}">
@ -13,14 +13,14 @@
</ContentPage.BindingContext>
<ContentPage.ToolbarItems>
<ToolbarItem Icon="cogs.png" Text="{i18n:Translate Edit}" />
<ToolbarItem Icon="cogs.png" Text="{u:I18n Edit}" />
</ContentPage.ToolbarItems>
<bv:BoxedView HasUnevenRows="True">
<bv:BoxedSection HeaderHeight="0">
<bv:EntryCell Title="{i18n:Translate EmailAddress}"
<bv:EntryCell Title="{u:I18n EmailAddress}"
ValueText="{Binding Email}" />
<bv:EntryCell Title="{i18n:Translate MasterPassword}"
<bv:EntryCell Title="{u:I18n MasterPassword}"
ValueText="{Binding MasterPassword}"
IsPassword="True"
Button1Icon="cogs"

View File

@ -7,11 +7,11 @@ using Xamarin.Forms.Xaml;
namespace Bit.App.Utilities
{
[ContentProperty("Id")]
public class TranslateExtension : IMarkupExtension
public class I18nExtension : IMarkupExtension
{
private II18nService _i18nService;
public TranslateExtension()
public I18nExtension()
{
_i18nService = ServiceContainer.Resolve<II18nService>("i18nService");
}