Skip to content

Commit

Permalink
feature: 외국어 대응
Browse files Browse the repository at this point in the history
  • Loading branch information
ryu-xh committed May 28, 2022
1 parent a9d4981 commit b92e106
Show file tree
Hide file tree
Showing 10 changed files with 592 additions and 30 deletions.
1 change: 1 addition & 0 deletions suffixRemover/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ namespace suffixRemover
/// </summary>
public partial class App : Application
{

}
}
12 changes: 6 additions & 6 deletions suffixRemover/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:suffixRemover"
mc:Ignorable="d"
Title="SuffixRemover" Height="258" Width="783.6" Loaded="Main_Loaded">
Title="SuffixRemover" Height="258" Width="779.6" Loaded="Main_Loaded">
<Grid>
<Button x:Name="Button1" Content="아무 것도 안하기" HorizontalAlignment="Left" Margin="10,0,0,10" Width="145" Click="Button1_Click" Height="19" VerticalAlignment="Bottom" Panel.ZIndex="1"/>
<Button x:Name="Button1" Content="{x:Static local:Strings.DoNothing}" HorizontalAlignment="Left" Margin="10,0,0,10" Width="145" Click="Button1_Click" Height="19" VerticalAlignment="Bottom" Panel.ZIndex="1"/>
<TextBox x:Name="Case1" HorizontalAlignment="Left" Margin="10,10,0,34" TextWrapping="Wrap" Text="Case1" Width="145" VerticalScrollBarVisibility="Visible"/>
<Button x:Name="Button2" Content="이 동작을 적용하기" HorizontalAlignment="Left" Margin="160,0,0,10" VerticalAlignment="Bottom" Width="145" Click="Button2_Click" Panel.ZIndex="1"/>
<Button x:Name="Button2" Content="{x:Static local:Strings.Apply}" HorizontalAlignment="Left" Margin="160,0,0,10" VerticalAlignment="Bottom" Width="145" Click="Button2_Click" Panel.ZIndex="1"/>
<TextBox x:Name="Case2" HorizontalAlignment="Left" Margin="160,10,0,34" TextWrapping="Wrap" Text="Case2" Width="145" VerticalScrollBarVisibility="Visible"/>
<Button x:Name="Button3" Content="이 동작을 적용하기" HorizontalAlignment="Left" Margin="310,0,0,10" VerticalAlignment="Bottom" Width="145" Click="Button3_Click" Panel.ZIndex="1"/>
<Button x:Name="Button3" Content="{x:Static local:Strings.Apply}" HorizontalAlignment="Left" Margin="310,0,0,10" VerticalAlignment="Bottom" Width="145" Click="Button3_Click" Panel.ZIndex="1"/>
<TextBox x:Name="Case3" HorizontalAlignment="Left" Margin="310,9,0,35" TextWrapping="Wrap" Text="Case3" Width="145" VerticalScrollBarVisibility="Visible"/>
<Button x:Name="Button4" Content="{x:Static local:Strings.Apply}" HorizontalAlignment="Left" Margin="460,0,0,10" VerticalAlignment="Bottom" Width="145" Click="Button4_Click" Panel.ZIndex="1"/>
<TextBox x:Name="Case4" HorizontalAlignment="Left" Margin="460,10,0,34" TextWrapping="Wrap" Text="Case4" Width="145" VerticalScrollBarVisibility="Visible"/>
<Button x:Name="Button4" Content="이 동작을 적용하기" HorizontalAlignment="Left" Margin="460,0,0,10" VerticalAlignment="Bottom" Width="145" Click="Button4_Click" Panel.ZIndex="1"/>
<Button x:Name="Button5" Content="{x:Static local:Strings.Apply}" HorizontalAlignment="Left" Margin="610,0,0,10" VerticalAlignment="Bottom" Width="145" Click="Button5_Click" Panel.ZIndex="1"/>
<TextBox x:Name="Case5" HorizontalAlignment="Left" Margin="610,10,0,34" TextWrapping="Wrap" Text="Case5" Width="145" VerticalScrollBarVisibility="Visible"/>
<Button x:Name="Button5" Content="이 동작을 적용하기" HorizontalAlignment="Left" Margin="610,0,0,10" VerticalAlignment="Bottom" Width="145" Click="Button5_Click" Panel.ZIndex="1"/>

</Grid>
</Window>
57 changes: 33 additions & 24 deletions suffixRemover/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
Expand All @@ -26,6 +28,17 @@ public MainWindow()
InitializeComponent();
}

public string GetLocalizaionString(string key)
{
string uiString;

ResourceManager rm = new ResourceManager("suffixRemover.Strings", Assembly.GetExecutingAssembly());

uiString = rm.GetString(key);

return uiString;
}

string ustFile;
string filePath;

Expand All @@ -37,7 +50,7 @@ private void Main_Loaded(object sender, RoutedEventArgs e)
{
if (args.Length < 2)
{
throw new ArgumentException("읽을 수 있는 파일이 없었습니다.");
throw new ArgumentException(message: GetLocalizaionString("NoArgs"));
}
filePath = args[1];

Expand Down Expand Up @@ -88,23 +101,31 @@ private void Init()
string remainGrouptSecondLyric = remover.RemainOnlyGroupSecond(line);
string remainGrouptSecondFourthLyric = remover.RemainOnlyGroupSecondFourth(line);

Case1.Text = $"{Case1.Text}{originLyric} -> {originLyric}\n";
Case2.Text = $"{Case2.Text}{originLyric} -> {remainGroupFirstSecondLyric}\n";
Case3.Text = $"{Case3.Text}{originLyric} -> {remainGroupFirstSecondFourthLyric}\n";
Case4.Text = $"{Case4.Text}{originLyric} -> {remainGrouptSecondLyric}\n";
Case5.Text = $"{Case5.Text}{originLyric} -> {remainGrouptSecondFourthLyric}\n";
Case1.Text = $"{Case1.Text}{originLyric} {originLyric}\n";
Case2.Text = $"{Case2.Text}{originLyric} {remainGroupFirstSecondLyric}\n";
Case3.Text = $"{Case3.Text}{originLyric} {remainGroupFirstSecondFourthLyric}\n";
Case4.Text = $"{Case4.Text}{originLyric} {remainGrouptSecondLyric}\n";
Case5.Text = $"{Case5.Text}{originLyric} {remainGrouptSecondFourthLyric}\n";

}
}

}

private void Close()
private new void Open()
{
fs = new FileStream(filePath, FileMode.Create);
writer = new StreamWriter(fs, Encoding.GetEncoding("shift_jis"));

reader = new StringReader(ustFile);
}

private new void Close()
{
writer.Close();
fs.Dispose();

MessageBox.Show("적용 완료");
MessageBox.Show(GetLocalizaionString("ItWasApplied"));
}

private void Button1_Click(object sender, RoutedEventArgs e)
Expand All @@ -114,10 +135,7 @@ private void Button1_Click(object sender, RoutedEventArgs e)

private void Button2_Click(object sender, RoutedEventArgs e)
{
fs = new FileStream(filePath, FileMode.Create);
writer = new StreamWriter(fs, Encoding.GetEncoding("shift_jis"));

reader = new StringReader(ustFile);
Open();

string line;

Expand All @@ -139,10 +157,7 @@ private void Button2_Click(object sender, RoutedEventArgs e)

private void Button3_Click(object sender, RoutedEventArgs e)
{
fs = new FileStream(filePath, FileMode.Create);
writer = new StreamWriter(fs, Encoding.GetEncoding("shift_jis"));

reader = new StringReader(ustFile);
Open();

string line;

Expand All @@ -165,10 +180,7 @@ private void Button3_Click(object sender, RoutedEventArgs e)

private void Button4_Click(object sender, RoutedEventArgs e)
{
fs = new FileStream(filePath, FileMode.Create);
writer = new StreamWriter(fs, Encoding.GetEncoding("shift_jis"));

reader = new StringReader(ustFile);
Open();

string line;

Expand All @@ -191,10 +203,7 @@ private void Button4_Click(object sender, RoutedEventArgs e)

private void Button5_Click(object sender, RoutedEventArgs e)
{
fs = new FileStream(filePath, FileMode.Create);
writer = new StreamWriter(fs, Encoding.GetEncoding("shift_jis"));

reader = new StringReader(ustFile);
Open();

string line;

Expand Down
99 changes: 99 additions & 0 deletions suffixRemover/Strings.Designer.cs

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

Empty file.
132 changes: 132 additions & 0 deletions suffixRemover/Strings.ja-JP.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<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">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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" 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">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Apply" xml:space="preserve">
<value>適用</value>
</data>
<data name="DoNothing" xml:space="preserve">
<value>何もしない</value>
</data>
<data name="ItWasApplied" xml:space="preserve">
<value>適用されました。</value>
</data>
<data name="NoArgs" xml:space="preserve">
<value>読み取れるファイルがありませんでした。</value>
</data>
</root>
Empty file.
Loading

0 comments on commit b92e106

Please sign in to comment.