Skip to content

Commit fc3aea1

Browse files
committed
feat: localization, with Chinese language added
1 parent c4e5c2c commit fc3aea1

89 files changed

Lines changed: 11832 additions & 1892 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,4 @@ Test/Test - Backup.csproj
333333
UndertaleModLib/UndertaleModLib - Backup.csproj
334334
UndertaleModTests/UndertaleModTests - Backup.csproj
335335
UndertaleModLib/gitversion.txt
336+
/UndertaleModTool/Localization/Strings.Designer.cs

UndertaleModTool/Controls/AudioFileReference.xaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
<UserControl x:Class="UndertaleModTool.AudioFileReference"
1+
<UserControl x:Class="UndertaleModTool.AudioFileReference"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:UndertaleModTool"
7-
mc:Ignorable="d"
7+
xmlns:loc="clr-namespace:UndertaleModTool.Localization"
8+
mc:Ignorable="d"
89
d:DesignHeight="20" d:DesignWidth="300">
910
<UserControl.Resources>
1011
<local:ContextMenuDark x:Key="contextMenu">
11-
<local:MenuItemDark Header="Open in new tab" Click="OpenInNewTabItem_Click"/>
12+
<local:MenuItemDark Header="{loc:Loc Common_OpenInNewTab}" Click="OpenInNewTabItem_Click"/>
1213
</local:ContextMenuDark>
1314
</UserControl.Resources>
1415
<Grid>
@@ -32,7 +33,7 @@
3233
</TextBox.Style>
3334
</local:TextBoxDark>
3435
<local:TextBoxDark Grid.Column="1" x:Name="ObjectText" IsReadOnly="True" Cursor="Arrow" AllowDrop="True"
35-
ToolTip="This is an object reference. Drag and drop an object of matching type from the tree on the left to change it!"
36+
ToolTip="{loc:Loc Ctrl_ObjRefToolTip}"
3637
ToolTipService.InitialShowDelay="250"
3738
PreviewDragOver="TextBox_DragOver" PreviewDrop="TextBox_Drop" PreviewMouseDoubleClick="TextBox_MouseDoubleClick" PreviewMouseDown="Details_MouseDown">
3839
<TextBox.Style>
@@ -60,14 +61,14 @@
6061
</DataTrigger>
6162
<DataTrigger Binding="{Binding AudioID, RelativeSource={RelativeSource AncestorType=UserControl}}" Value="-1">
6263
<DataTrigger.Setters>
63-
<Setter Property="Text" Value="(null)"/>
64+
<Setter Property="Text" Value="{loc:Loc Common_Null}"/>
6465
</DataTrigger.Setters>
6566
</DataTrigger>
6667
</Style.Triggers>
6768
</Style>
6869
</TextBox.Style>
6970
</local:TextBoxDark>
70-
<local:ButtonDark Grid.Column="2" Click="Details_Click" MouseDown="Details_MouseDown" Content=" ... " ToolTip="Open referenced object">
71+
<local:ButtonDark Grid.Column="2" Click="Details_Click" MouseDown="Details_MouseDown" Content=" ... " ToolTip="{loc:Loc Ctrl_OpenReferencedObject}">
7172
<Button.Style>
7273
<Style TargetType="{x:Type Button}">
7374
<Style.Triggers>
@@ -78,7 +79,7 @@
7879
</Style>
7980
</Button.Style>
8081
</local:ButtonDark>
81-
<local:ButtonDark Grid.Column="3" Click="Remove_Click" Content=" X " ToolTip="Remove reference">
82+
<local:ButtonDark Grid.Column="3" Click="Remove_Click" Content=" X " ToolTip="{loc:Loc Ctrl_RemoveReference}">
8283
<Button.Style>
8384
<Style TargetType="{x:Type Button}">
8485
<Style.Triggers>
@@ -92,4 +93,4 @@
9293
</Button.Style>
9394
</local:ButtonDark>
9495
</Grid>
95-
</UserControl>
96+
</UserControl>

UndertaleModTool/Controls/ColorPicker.xaml.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.Globalization;
@@ -14,6 +14,7 @@
1414
using System.Windows.Media.Imaging;
1515
using System.Windows.Navigation;
1616
using System.Windows.Shapes;
17+
using UndertaleModTool.Localization;
1718

1819
namespace UndertaleModTool
1920
{
@@ -59,7 +60,7 @@ public ColorPicker()
5960
ColorText.SetBinding(TextBox.TextProperty, binding);
6061

6162
ColorText.MaxLength = HasAlpha ? 9 : 7;
62-
ColorText.ToolTip = $"#{(HasAlpha ? "AA" : "")}BBGGRR";
63+
ColorText.ToolTip = string.Format(LocalizationSource.GetString("Msg_ColorFormatHint"), HasAlpha ? "AA" : "");
6364
ToolTipService.SetInitialShowDelay(ColorText, 250);
6465
}
6566

@@ -78,7 +79,7 @@ private static void OnHasAlphaChanged(DependencyObject dependencyObject, Depende
7879
colorPicker.ColorText.SetBinding(TextBox.TextProperty, binding);
7980

8081
colorPicker.ColorText.MaxLength = hasAlpha ? 9 : 7;
81-
colorPicker.ColorText.ToolTip = $"#{(hasAlpha ? "AA" : "")}BBGGRR";
82+
colorPicker.ColorText.ToolTip = string.Format(LocalizationSource.GetString("Msg_ColorFormatHint"), hasAlpha ? "AA" : "");
8283
}
8384
}
8485

@@ -123,11 +124,11 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
123124
bool hasAlpha = bool.Parse((string)parameter);
124125

125126
if (val[0] != '#')
126-
return new ValidationResult(false, "Invalid color string");
127+
return new ValidationResult(false, LocalizationSource.GetString("Msg_InvalidColorString"));
127128

128129
val = val[1..];
129130
if (val.Length != (hasAlpha ? 8 : 6))
130-
return new ValidationResult(false, "Invalid color string");
131+
return new ValidationResult(false, LocalizationSource.GetString("Msg_InvalidColorString"));
131132

132133
if (!hasAlpha)
133134
val = "FF" + val; // add alpha (255)

UndertaleModTool/Controls/FlagsBox.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<UserControl x:Class="UndertaleModTool.FlagsBox"
1+
<UserControl x:Class="UndertaleModTool.FlagsBox"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:UndertaleModTool"
7+
xmlns:loc="clr-namespace:UndertaleModTool.Localization"
78
mc:Ignorable="d"
89
d:DesignHeight="450" d:DesignWidth="800"
910
x:Name="flagsBox">
@@ -12,7 +13,7 @@
1213
</UserControl.Resources>
1314
<StackPanel>
1415
<TextBox Text="{Binding Value, ElementName=flagsBox}" />
15-
<Expander Header="Flags">
16+
<Expander Header="{loc:Loc Common_Flags}">
1617
<ItemsControl ItemsSource="{Binding Value, ElementName=flagsBox, Converter={StaticResource enumToValuesConverter}}">
1718
<ItemsControl.ItemTemplate>
1819
<DataTemplate>
@@ -35,4 +36,4 @@
3536
</ItemsControl>
3637
</Expander>
3738
</StackPanel>
38-
</UserControl>
39+
</UserControl>

UndertaleModTool/Controls/ResourceListTreeViewItem.xaml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
<TreeViewItem x:Class="UndertaleModTool.ResourceListTreeViewItem"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:UndertaleModTool"
77
xmlns:undertalelib="clr-namespace:UndertaleModLib;assembly=UndertaleModLib"
8+
xmlns:loc="clr-namespace:UndertaleModTool.Localization"
89
mc:Ignorable="d">
910

1011
<TreeViewItem.Resources>
1112
<DataTemplate x:Key="DefaultNullItemTemplate">
12-
<TextBlock Text="(null)"/>
13+
<TextBlock Text="{loc:Loc Common_Null}"/>
1314
</DataTemplate>
1415

1516
<local:ImplementsInterfaceConverter x:Key="ImplementsInterfaceConverter"/>
1617

1718
<local:ContextMenuDark x:Key="UndertaleResourceMenu" Opened="MenuItem_ContextMenuOpened">
18-
<MenuItem Header="Open in new tab" Click="MenuItem_OpenInNewTab_Click"/>
19-
<MenuItem Header="Find all references" Click="MenuItem_FindAllReferences_Click" Name="FindAllReferences"/>
20-
<MenuItem Header="Copy name to clipboard" Click="MenuItem_CopyName_Click"/>
21-
<MenuItem Header="Delete" Click="MenuItem_Delete_Click"/>
19+
<MenuItem Header="{loc:Loc Common_OpenInNewTab}" Click="MenuItem_OpenInNewTab_Click"/>
20+
<MenuItem Header="{loc:Loc FindRef_FindAllReferences}" Click="MenuItem_FindAllReferences_Click" Name="FindAllReferences"/>
21+
<MenuItem Header="{loc:Loc FindRef_CopyNameToClipboard}" Click="MenuItem_CopyName_Click"/>
22+
<MenuItem Header="{loc:Loc Common_Delete}" Click="MenuItem_Delete_Click"/>
2223
</local:ContextMenuDark>
2324

24-
<!-- TODO: Would need some way to know the ID, IndexOf won't be reliable -->
2525
<local:ContextMenuDark x:Key="NullItemReplaceMenu" Opened="MenuItem_NullDataContext_ContextMenuOpened">
26-
<!--<MenuItem IsEnabled="False" Header="ID: " Name="ObjectIdLabel" />
27-
<Separator />-->
28-
<MenuItem IsEnabled="False" Header="Add in place (unimplemented)" />
26+
<MenuItem IsEnabled="False" Header="{loc:Loc Ctrl_AddInPlaceUnimplemented}" />
2927
</local:ContextMenuDark>
3028

3129
<Style x:Key="UndertaleModTool.ResourceListTreeViewItem.ItemContainerStyle" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource {x:Type TreeViewItem}}">

UndertaleModTool/Controls/ResourceListTreeViewItem.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Windows;
44
using System.Windows.Controls;
55
using UndertaleModLib;
6+
using UndertaleModTool.Localization;
67
using UndertaleModTool.Windows;
78
using System.Linq;
89

@@ -96,7 +97,7 @@ private void MenuItem_FindAllReferences_Click(object sender, RoutedEventArgs e)
9697
{
9798
if ((sender as FrameworkElement)?.DataContext is not UndertaleResource obj)
9899
{
99-
mainWindow.ShowError("The selected object is not an \"UndertaleResource\".");
100+
mainWindow.ShowError(LocalizationSource.GetString("Msg_SelectedObjectNotUndertaleResource"));
100101
return;
101102
}
102103

@@ -108,8 +109,7 @@ private void MenuItem_FindAllReferences_Click(object sender, RoutedEventArgs e)
108109
}
109110
catch (Exception ex)
110111
{
111-
mainWindow.ShowError("An error occured in the object references related window.\n" +
112-
$"Please report this on GitHub.\n\n{ex}");
112+
mainWindow.ShowError(string.Format(LocalizationSource.GetString("Msg_ObjectReferencesWindowError"), ex));
113113
}
114114
finally
115115
{

UndertaleModTool/Controls/UndertaleObjectReference.xaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
<UserControl x:Class="UndertaleModTool.UndertaleObjectReference"
1+
<UserControl x:Class="UndertaleModTool.UndertaleObjectReference"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:UndertaleModTool"
77
xmlns:undertale="clr-namespace:UndertaleModLib.Models;assembly=UndertaleModLib"
8-
mc:Ignorable="d"
8+
xmlns:loc="clr-namespace:UndertaleModTool.Localization"
9+
mc:Ignorable="d"
910
d:DesignHeight="20" d:DesignWidth="300"
1011
Name="objectReference">
1112
<UserControl.Resources>
1213
<local:ContextMenuDark x:Key="contextMenu" Opened="MenuItem_ContextMenuOpened">
13-
<MenuItem Header="Open in new tab" Click="OpenInNewTabItem_Click"/>
14-
<MenuItem Header="Find all references" Click="FindAllReferencesItem_Click"/>
14+
<MenuItem Header="{loc:Loc Common_OpenInNewTab}" Click="OpenInNewTabItem_Click"/>
15+
<MenuItem Header="{loc:Loc FindRef_FindAllReferences}" Click="FindAllReferencesItem_Click"/>
1516
</local:ContextMenuDark>
1617
<Label x:Key="emptyReferenceLabel" Foreground="Gray" FontStyle="Italic" />
1718
</UserControl.Resources>
@@ -28,7 +29,7 @@
2829
<Style TargetType="{x:Type TextBox}">
2930
<Style.Triggers>
3031
<DataTrigger Binding="{Binding CanChange, ElementName=objectReference}" Value="True">
31-
<Setter Property="ToolTip" Value="This is an object reference. Drag and drop an object of matching type from the tree on the left to change it!" />
32+
<Setter Property="ToolTip" Value="{loc:Loc Ctrl_ObjRefToolTip}" />
3233
<Setter Property="ToolTipService.InitialShowDelay" Value="250" />
3334
</DataTrigger>
3435
<DataTrigger Binding="{Binding ObjectReference, ElementName=objectReference}" Value="{x:Null}">
@@ -48,7 +49,7 @@
4849
<Button.Style>
4950
<Style TargetType="{x:Type Button}">
5051
<Setter Property="Content" Value=" ... " />
51-
<Setter Property="ToolTip" Value="Open referenced object" />
52+
<Setter Property="ToolTip" Value="{loc:Loc Ctrl_OpenReferencedObject}" />
5253
<Style.Triggers>
5354
<DataTrigger Binding="{Binding ObjectReference, ElementName=objectReference}" Value="{x:Null}">
5455
<Setter Property="IsEnabled" Value="False"/>
@@ -60,14 +61,14 @@
6061
<Condition Binding="{Binding ObjectReference, ElementName=objectReference}" Value="{x:Null}" />
6162
</MultiDataTrigger.Conditions>
6263
<Setter Property="Content" Value=" + "/>
63-
<Setter Property="ToolTip" Value="Create new code entry" />
64+
<Setter Property="ToolTip" Value="{loc:Loc Ctrl_CreateNewCode}" />
6465
<Setter Property="IsEnabled" Value="True"/>
6566
</MultiDataTrigger>
6667
</Style.Triggers>
6768
</Style>
6869
</Button.Style>
6970
</local:ButtonDark>
70-
<local:ButtonDark Grid.Column="2" x:Name="RemoveButton" Click="Remove_Click" Content=" X " ToolTip="Remove reference">
71+
<local:ButtonDark Grid.Column="2" x:Name="RemoveButton" Click="Remove_Click" Content=" X " ToolTip="{loc:Loc Ctrl_RemoveReference}">
7172
<Button.Style>
7273
<Style TargetType="{x:Type Button}">
7374
<Style.Triggers>
@@ -86,4 +87,4 @@
8687
</Button.Style>
8788
</local:ButtonDark>
8889
</Grid>
89-
</UserControl>
90+
</UserControl>

UndertaleModTool/Controls/UndertaleObjectReference.xaml.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.Diagnostics;
@@ -18,6 +18,7 @@
1818
using UndertaleModLib;
1919
using UndertaleModLib.Models;
2020
using UndertaleModLib.Scripting;
21+
using UndertaleModTool.Localization;
2122
using UndertaleModTool.Windows;
2223

2324
namespace UndertaleModTool
@@ -198,9 +199,9 @@ private void UndertaleObjectReference_Loaded(object sender, RoutedEventArgs e)
198199
n = "n";
199200

200201
if (CanChange)
201-
label.Content = $"(drag & drop a{n} {typeName})";
202+
label.Content = string.Format(LocalizationSource.GetString("Msg_DragDropAType"), n, typeName);
202203
else
203-
label.Content = $"(empty {typeName} reference)";
204+
label.Content = string.Format(LocalizationSource.GetString("Msg_EmptyTypeReference"), typeName);
204205
}
205206

206207
public void ClearRemoveClickHandler()
@@ -310,7 +311,7 @@ private void FindAllReferencesItem_Click(object sender, RoutedEventArgs e)
310311
var obj = (sender as FrameworkElement)?.DataContext;
311312
if (obj is not UndertaleResource res)
312313
{
313-
mainWindow.ShowError("The selected object is not an \"UndertaleResource\".");
314+
mainWindow.ShowError(LocalizationSource.GetString("Msg_SelectedObjectNotUndertaleResource"));
314315
return;
315316
}
316317

@@ -322,8 +323,7 @@ private void FindAllReferencesItem_Click(object sender, RoutedEventArgs e)
322323
}
323324
catch (Exception ex)
324325
{
325-
mainWindow.ShowError("An error occurred in the object references related window.\n" +
326-
$"Please report this on GitHub.\n\n{ex}");
326+
mainWindow.ShowError(string.Format(LocalizationSource.GetString("Msg_ObjectReferencesWindowError"), ex));
327327
}
328328
finally
329329
{

UndertaleModTool/Controls/UndertaleRoomRenderer.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.Globalization;
@@ -19,6 +19,7 @@
1919
using System.Windows.Threading;
2020
using UndertaleModLib.Models;
2121
using static UndertaleModLib.Models.UndertaleRoom;
22+
using UndertaleModTool.Localization;
2223

2324
namespace UndertaleModTool
2425
{
@@ -128,7 +129,7 @@ public class RoomCaptionConverter : IValueConverter
128129
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
129130
{
130131
UndertaleRoom room = value as UndertaleRoom;
131-
return room is not null ? $"{room.Name.Content}: {room.Width}x{room.Height}" : "null";
132+
return room is not null ? string.Format(LocalizationSource.GetString("Msg_RoomCaptionFormat"), room.Name.Content, room.Width, room.Height) : "null";
132133
}
133134
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
134135
{

0 commit comments

Comments
 (0)