Skip to content

Commit

Permalink
Merge pull request #4 from teonsen/localize
Browse files Browse the repository at this point in the history
support English and Japanese localization (just a machine translation)
  • Loading branch information
weihuajiang committed Feb 11, 2020
2 parents 174063c + 89e8028 commit b3056ca
Show file tree
Hide file tree
Showing 55 changed files with 2,418 additions and 106 deletions.
21 changes: 11 additions & 10 deletions ScratchEditor/CreateFunctionDlg.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ScratchNet"
xmlns:lclz="clr-namespace:ScratchEditor.localization"
FontSize="12" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
Title="CreateFunctionDlg" Height="300" Width="400" MinWidth="400">
<Window.Resources>
Expand Down Expand Up @@ -132,17 +133,17 @@
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
<TextBlock Text="添加一个数字参数:" Grid.Row="2" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
<TextBlock Text="添加一个字符串参数:" Grid.Row="3" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
<TextBlock Text="添加一个布尔参数:" Grid.Row="4" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
<TextBlock Text="添加一个文本标签:" Grid.Row="5" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
<Button Grid.Row="2" Grid.Column="2" Width="80" Click="OnAddNumber" Margin="5" >数字</Button>
<Button Grid.Row="3" Grid.Column="2" Width="80" Click="OnAddString" Margin="5">字符串</Button>
<Button Grid.Row="4" Grid.Column="2" Width="80" Click="OnAddBoolean" Margin="5">布尔</Button>
<Button Grid.Row="5" Grid.Column="2" Width="80" Click="OnAddText" Margin="5">文字</Button>
<TextBlock Text="{x:Static lclz:Strings.lblAddNumericParam}" Grid.Row="2" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lclz:Strings.lblAddStringParam}" Grid.Row="3" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lclz:Strings.lblAddBoolParam}" Grid.Row="4" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lclz:Strings.lblAddTextLabel}" Grid.Row="5" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
<Button Content="{x:Static lclz:Strings.btnNumber}" Grid.Row="2" Grid.Column="2" Width="80" Click="OnAddNumber" Margin="5"/>
<Button Content="{x:Static lclz:Strings.btnString}" Grid.Row="3" Grid.Column="2" Width="80" Click="OnAddString" Margin="5"/>
<Button Content="{x:Static lclz:Strings.btnBool}" Grid.Row="4" Grid.Column="2" Width="80" Click="OnAddBoolean" Margin="5"/>
<Button Content="{x:Static lclz:Strings.btnText}" Grid.Row="5" Grid.Column="2" Width="80" Click="OnAddText" Margin="5"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="7" Grid.ColumnSpan="4">
<Button Name="ButtonOK" Width="120" Content="确定" Margin="5" Click="OnConfirm"/>
<Button Name="ButtonCancel" Width="120" Content="取消" Margin="5" Click="OnCancel"/>
<Button Name="ButtonOK" Width="120" Content="{x:Static lclz:Strings.btnOK}" Margin="5" Click="OnConfirm"/>
<Button Name="ButtonCancel" Width="120" Content="{x:Static lclz:Strings.btnCancel}" Margin="5" Click="OnCancel"/>
</StackPanel>
</Grid>
</Window>
4 changes: 2 additions & 2 deletions ScratchEditor/GraphicScriptEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public GraphicScriptEditor()
};

//generate group, future load from file
CreateVariableButton = new Button() { Content = "创建变量", Margin = new Thickness(5), Width = 80 };
CreateVariableButton = new Button() { Content = ScratchEditor.Localize.GetString("btnCreateVariables"), Margin = new Thickness(5), Width = 80 };
CreateVariableButton.Click += CreateVariableButton_Click;
CreateVariableButton.HorizontalAlignment = HorizontalAlignment.Left;

CreateFunctionButton = new Button() { Content = "创建积木", Margin = new Thickness(5), Width = 80 };
CreateFunctionButton = new Button() { Content = ScratchEditor.Localize.GetString("btnCreateBlocks"), Margin = new Thickness(5), Width = 80 };
CreateFunctionButton.Click += CreateFunctionButton_Click;
CreateFunctionButton.HorizontalAlignment = HorizontalAlignment.Left;

Expand Down
48 changes: 35 additions & 13 deletions ScratchEditor/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions ScratchEditor/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
Expand All @@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
Expand All @@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
Expand All @@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
Expand All @@ -109,9 +112,13 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="colors" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>colors.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
45 changes: 45 additions & 0 deletions ScratchEditor/Properties/colors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Motion
ScratchNet.WaitStatement:#4C97FF
ScratchNet.MoveStatement:#4C97FF
ScratchNet.RotationStatement:#4C97FF
ScratchNet.ReflectionStatement:#4C97FF
ScratchNet.SetRotationModeStatement:#4C97FF
ScratchNet.SetDegreeStatement:#4C97FF
ScratchNet.SetPositionStatement:#4C97FF
ScratchNet.SetPositionXStatement:#4C97FF
ScratchNet.SetPositionYStatement:#4C97FF
ScratchNet.TimedMoveStatement:#4C97FF
ScratchNet.XPositionExpression:#4C97FF
ScratchNet.YPositionExpression:#4C97FF
ScratchNet.DegreeExpression:#4C97FF
// Looks
ScratchNet.ResizeStatement:#9966FF
ScratchNet.SetImageStatement:#9966FF
ScratchNet.SetNextImageStatement:#9966FF
ScratchNet.ShowStatement:#9966FF
ScratchNet.HideStatement:#9966FF
ScratchNet.SizeExpression:#9966FF
// Logic
ScratchNet.CompareExpression:#59C059
ScratchNet.LogicExpression:#59C059
ScratchNet.NotExpression:#59C059
// Operator
ScratchNet.BinaryExpression:#59C059
ScratchNet.ConditionalExpression:#59C059
ScratchNet.RandomExpression:#59C059
// Control
ScratchNet.IfStatement:#FFAB19
ScratchNet.ForStatement:#FFAB19
ScratchNet.WhileStatement:#FFAB19
ScratchNet.BreakStatement:#FFAB19
ScratchNet.ContinueStatement:#FFAB19
ScratchNet.ReturnStatement:#FFAB19
ScratchNet.LogStatement:#FFAB19
ScratchNet.TryStatement:#FFAB19
// Event
ScratchNet.StartEventHandler:#FFBF00
ScratchNet.KeyEventHandler:#FFBF00
ScratchNet.ClickEventHandler:#FFBF00
ScratchNet.MessageEvetHandler:#FFBF00
// Variable
ScratchNet.AssignmentStatement:#FF8C1A
32 changes: 32 additions & 0 deletions ScratchEditor/ScratchEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@
<Compile Include="GraphicScriptEditor.xaml.cs">
<DependentUpon>GraphicScriptEditor.xaml</DependentUpon>
</Compile>
<Compile Include="localization\Localize.cs" />
<Compile Include="localization\Strings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="localization\Strings.ja-JP.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.ja-JP.resx</DependentUpon>
</Compile>
<Compile Include="localization\Strings.zh-CN.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.zh-CN.resx</DependentUpon>
</Compile>
<Compile Include="ParameterIndicator.xaml.cs">
<DependentUpon>ParameterIndicator.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -117,6 +133,18 @@
<DependentUpon>TextBoxExpressionHolder.xaml</DependentUpon>
</Compile>
<Compile Include="util\Utility.cs" />
<EmbeddedResource Include="localization\Strings.ja-JP.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.ja-JP.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="localization\Strings.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="localization\Strings.zh-CN.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.zh-CN.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -182,6 +210,10 @@
<ItemGroup>
<Resource Include="images\delete-512.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\colors.txt" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
15 changes: 8 additions & 7 deletions ScratchEditor/SetVariableNameDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ScratchNet"
xmlns:lclz="clr-namespace:ScratchEditor.localization"
xmlns:t="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
SizeToContent="Height" WindowStartupLocation="CenterOwner"
Title="设置变量名称" Height="200" Width="400">
Title="{x:Static lclz:Strings.title_SetVariable}" Height="200" Width="400">
<Window.Resources>
<local:TextNotEmptyConverter x:Key="TextNotEmptyConverter"/>
</Window.Resources>
Expand All @@ -21,13 +22,13 @@
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="变量名:" Margin="5" VerticalAlignment="Center"/>
<TextBox Name="VariableName" Grid.Column="1" Margin="5" Grid.ColumnSpan="2" MinWidth="300"/>
<RadioButton Name="GlobalScope" Content="适用于全部角色" Grid.Column="1" Grid.Row="1" Margin="5" IsChecked="True"/>
<RadioButton Name="LocalScope" Content="适用于全部角色" Grid.Column="2" Grid.Row="1" Margin="5"/>
<TextBlock Text="{x:Static lclz:Strings.xaml_VariableName}" Margin="5,6,153,6" VerticalAlignment="Center" Grid.ColumnSpan="2" HorizontalAlignment="Right"/>
<TextBox Name="VariableName" Grid.Column="1" Margin="75,5,5,5" Grid.ColumnSpan="2" MinWidth="300"/>
<RadioButton Name="GlobalScope" Content="{x:Static lclz:Strings.xaml_Global}" Grid.Column="1" Grid.Row="1" Margin="57,5,5,5" IsChecked="True"/>
<RadioButton Name="LocalScope" Content="{x:Static lclz:Strings.xaml_Local}" Grid.Column="2" Grid.Row="1" Margin="5"/>
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Grid.Row="3" Grid.ColumnSpan="6">
<Button Name="ButtonOK" Width="120" Content="确定" Margin="5" IsEnabled="{Binding ElementName=VariableName, Path=Text, Converter={StaticResource TextNotEmptyConverter}}" Click="OnConfirm"/>
<Button Name="ButtonCancel" Width="120" Content="取消" Margin="5" Click="OnCancel"/>
<Button Name="ButtonOK" Width="120" Content="{x:Static lclz:Strings.btnOK}" Margin="5" IsEnabled="{Binding ElementName=VariableName, Path=Text, Converter={StaticResource TextNotEmptyConverter}}" Click="OnConfirm"/>
<Button Name="ButtonCancel" Width="120" Content="{x:Static lclz:Strings.btnCancel}" Margin="5" Click="OnCancel"/>
</StackPanel>
</Grid>
</Window>
Loading

0 comments on commit b3056ca

Please sign in to comment.