Selaa lähdekoodia

Resize popups and new image localized

Krzysztof Krysiński 2 vuotta sitten
vanhempi
commit
c1c614e61e

+ 8 - 0
src/PixiEditor/Data/Localization/Languages/en.json

@@ -14,6 +14,14 @@
   "LANGUAGE": "Language",
   "GENERAL": "General",
 
+  "PERCENTAGE": "Percentage",
+  "ABSOLUTE": "Absolute",
+  "PRESERVE_ASPECT_RATIO": "Preserve aspect ratio",
+  "ANCHOR_POINT": "Anchor point",
+
+  "RESIZE_IMAGE": "Resize image",
+  "RESIZE": "Resize",
+
   "DISCORD": "Discord",
   "DISCORD_DETAILS": "Staring at absolutely",
   "DISCORD_STATE": "nothing",

+ 2 - 1
src/PixiEditor/Views/Dialogs/DialogTitleBar.xaml

@@ -5,6 +5,7 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PixiEditor.Views.Dialogs"
+             xmlns:views="clr-namespace:PixiEditor.Views"
              mc:Ignorable="d"
              x:Name="uc"
              Height="35" d:DesignWidth="300">
@@ -15,7 +16,7 @@
         </Grid.ColumnDefinitions>
         <TextBlock 
             TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" 
-            Text="{Binding ElementName=uc, Path=TitleText}"
+            views:Translator.Key="{Binding ElementName=uc, Path=TitleText}"
             Foreground="White" 
             FontSize="15" 
             Margin="5,0,0,0" 

+ 1 - 1
src/PixiEditor/Views/Dialogs/NewFilePopup.xaml

@@ -36,7 +36,7 @@
         </i:Interaction.Behaviors>
 
         <dial:DialogTitleBar DockPanel.Dock="Top"
-            TitleText="Create a new image" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}" />
+            TitleText="CREATE_NEW_IMAGE" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}" />
 
         <Button DockPanel.Dock="Bottom" Width="70" Margin="0,15,0,15" HorizontalAlignment="Center"
                 IsDefault="True" Content="Create" x:Name="createButton"

+ 2 - 2
src/PixiEditor/Views/Dialogs/ResizeCanvasPopup.xaml

@@ -33,7 +33,7 @@
         </i:Interaction.Behaviors>
 
         <dial:DialogTitleBar DockPanel.Dock="Top"
-            TitleText="Resize canvas" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}" />
+            TitleText="RESIZE_CANVAS" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}" />
 
         <Button DockPanel.Dock="Bottom" Width="70" HorizontalAlignment="Center" Margin="15"
                 Style="{StaticResource DarkRoundButton}" Content="Resize" Click="Button_Click" IsDefault="True" />
@@ -55,7 +55,7 @@
                                   />
                 <Separator Margin="10,5,10,0" Background="{StaticResource AccentColor}" Height="1" />
                 <DockPanel>
-                    <Label Content="Anchor point:" Foreground="White" Margin="25,5,0,0" HorizontalAlignment="Left"
+                    <Label base:Translator.Key="ANCHOR_POINT" Foreground="White" Margin="25,5,0,0" HorizontalAlignment="Left"
                            FontSize="12" />
                     <userControls:AnchorPointPicker AnchorPoint="{Binding Path=SelectedAnchorPoint, Mode=TwoWay, ElementName=window}"
                                              HorizontalAlignment="Right"

+ 2 - 2
src/PixiEditor/Views/Dialogs/ResizeDocumentPopup.xaml

@@ -31,10 +31,10 @@
         </i:Interaction.Behaviors>
 
         <dial:DialogTitleBar DockPanel.Dock="Top"
-            TitleText="Resize image" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}"/>
+            TitleText="RESIZE_IMAGE" CloseCommand="{x:Static SystemCommands.CloseWindowCommand}"/>
 
         <Button DockPanel.Dock="Bottom" Width="70" HorizontalAlignment="Center" Margin="15"
-                Style="{StaticResource DarkRoundButton}" Content="Resize" Click="Button_Click" IsDefault="True" />
+                Style="{StaticResource DarkRoundButton}" local:Translator.Key="RESIZE" Click="Button_Click" IsDefault="True" />
 
         <userControls:SizePicker HorizontalAlignment="Center" Width="240" Height="180" Margin="0,30,0,0"
             x:Name="sizePicker"

+ 11 - 25
src/PixiEditor/Views/Translator.cs

@@ -53,45 +53,31 @@ public class Translator : UIElement
         if (e.NewValue is string key)
         {
             LocalizedString localizedString = new(key);
+            Binding binding = new()
+            {
+                Path = new PropertyPath("(0)", Translator.ValueProperty),
+                RelativeSource = new RelativeSource(RelativeSourceMode.Self)
+            };
+
             if(d is TextBox textBox)
             {
-                textBox.SetBinding(TextBox.TextProperty, new Binding()
-                { 
-                    Path = new PropertyPath("(views:Translator.Value)"),
-                    RelativeSource = new RelativeSource(RelativeSourceMode.Self) 
-                });
+                textBox.SetBinding(TextBox.TextProperty, binding);
             }
             else if (d is TextBlock textBlock)
             {
-                textBlock.SetBinding(TextBlock.TextProperty, new Binding()
-                { 
-                    Path = new PropertyPath("(views:Translator.Value)"),
-                    RelativeSource = new RelativeSource(RelativeSourceMode.Self) 
-                });
+                textBlock.SetBinding(TextBlock.TextProperty, binding);
             }
             else if (d is Run run)
             {
-                run.SetBinding(Run.TextProperty, new Binding()
-                { 
-                    Path = new PropertyPath("(views:Translator.Value)"),
-                    RelativeSource = new RelativeSource(RelativeSourceMode.Self) 
-                });
+                run.SetBinding(Run.TextProperty, binding);
             }
             else if (d is ContentControl contentControl)
             {
-                contentControl.SetBinding(ContentControl.ContentProperty, new Binding()
-                { 
-                    Path = new PropertyPath("(views:Translator.Value)"),
-                    RelativeSource = new RelativeSource(RelativeSourceMode.Self) 
-                });
+                contentControl.SetBinding(ContentControl.ContentProperty, binding);
             }
             else if (d is HeaderedItemsControl menuItem)
             {
-                menuItem.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding()
-                {
-                    Path = new PropertyPath("(views:Translator.Value)"),
-                    RelativeSource = new RelativeSource(RelativeSourceMode.Self)
-                });
+                menuItem.SetBinding(HeaderedItemsControl.HeaderProperty, binding);
             }
 
             d.SetValue(ValueProperty, localizedString.Value);

+ 5 - 6
src/PixiEditor/Views/UserControls/SizePicker.xaml

@@ -51,7 +51,7 @@
                                               ElementName=uc, 
                                               Converter={converters:EnumBooleanConverter}, 
                                               ConverterParameter=Percentage
-                                              }">Percentage:</RadioButton>
+                                              }" local:Translator.Key="PERCENTAGE"/>
                 <userControls:SizeInput Grid.Column="1" Grid.Row="0" 
                                      VerticalAlignment="Center"
                                      x:Name="PercentageSizePicker"
@@ -78,8 +78,7 @@
                              IsChecked="{Binding Path=SelectedUnit,  
                                               ElementName=uc, 
                                               Converter={converters:EnumBooleanConverter}, 
-                                              ConverterParameter=Pixel}"
-                              >Absolute:</RadioButton>
+                                              ConverterParameter=Pixel}" local:Translator.Key="ABSOLUTE"/>
 
             </Grid>
 
@@ -94,7 +93,7 @@
                     <RowDefinition />
                 </Grid.RowDefinitions>
 
-                <TextBlock Grid.Column="0" Grid.Row="0" Foreground="Snow" Text="Width:" VerticalAlignment="Center" HorizontalAlignment="Left" />
+                <TextBlock Grid.Column="0" Grid.Row="0" Foreground="Snow" local:Translator.Key="WIDTH" VerticalAlignment="Center" HorizontalAlignment="Left" />
                 <userControls:SizeInput Grid.Column="1" Grid.Row="0"
                              x:Name="WidthPicker"
                              Width="80"
@@ -109,7 +108,7 @@
                     </i:Interaction.Triggers>
                 </userControls:SizeInput>
 
-                <TextBlock Grid.Column="0" Grid.Row="1" Foreground="Snow" Text="Height:" VerticalAlignment="Center" HorizontalAlignment="Left"/>
+                <TextBlock Grid.Column="0" Grid.Row="1" Foreground="Snow" local:Translator.Key="HEIGHT" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                 <userControls:SizeInput Grid.Column="1" Grid.Row="1"
                              x:Name="HeightPicker" 
                              IsEnabled="{Binding EditingEnabled, ElementName=uc}"
@@ -126,7 +125,7 @@
                   Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2"
                   Name="aspectRatio" 
                   IsChecked="{Binding ElementName=uc, Path=PreserveAspectRatio}"
-                  Content="Preserve aspect ratio" 
+                  local:Translator.Key="PRESERVE_ASPECT_RATIO"
                   Foreground="White" 
                   HorizontalAlignment="Left" 
                   VerticalAlignment="Center" />