Skip to content

Commit 6e0f6ec

Browse files
committed
Localize Part 4
1 parent d6c5523 commit 6e0f6ec

File tree

6 files changed

+47
-3
lines changed

6 files changed

+47
-3
lines changed

EncodingConverter.VisualStudio.V2/ChooseEncodingControl.xaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
xmlns:local="clr-namespace:EncodingConverter.VisualStudio"
77
mc:Ignorable="d"
88
Height="75" Width="250">
9+
<UserControl.Resources>
10+
<local:WpfLocalizer x:Key="Loc" />
11+
</UserControl.Resources>
912
<Grid>
10-
<TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="Choose Encoding:" VerticalAlignment="Top"/>
13+
<TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="{Binding [ChooseEncoding], Source={StaticResource Loc}}" VerticalAlignment="Top"/>
1114
<ComboBox x:Name="encodingsCombo" HorizontalAlignment="Center" Margin="0,31,0,0" VerticalAlignment="Top" Width="230"/>
1215
</Grid>
1316
</UserControl>

EncodingConverter.VisualStudio.V2/ConvertCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public sealed override async Task ExecuteCommandAsync(IClientContext context, Ca
1717

1818
ChooseEncodingControl control = new();
1919

20-
if (await Extensibility.Shell().ShowDialogAsync((WpfControlWrapper)control, Resources.ChooseEncoding, DialogOption.OKCancel, cancellationToken) == DialogResult.OK) {
20+
if (await Extensibility.Shell().ShowDialogAsync((WpfControlWrapper)control, Resources.ChooseEncodingTitle, DialogOption.OKCancel, cancellationToken) == DialogResult.OK) {
2121
var items = await GetItemsAsync(cancellationToken);
2222
var array = items.ToArray();
2323
var statusbar = await statusbarProvider.GetServiceAsync();

EncodingConverter.VisualStudio.V2/Properties/Resources.Designer.cs

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EncodingConverter.VisualStudio.V2/Properties/Resources.ko.resx

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="ChooseEncoding" xml:space="preserve">
121+
<value>인코딩 선택:</value>
122+
</data>
123+
<data name="ChooseEncodingTitle" xml:space="preserve">
121124
<value>인코딩 선택</value>
122125
</data>
123126
<data name="OutputText" xml:space="preserve">

EncodingConverter.VisualStudio.V2/Properties/Resources.resx

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="ChooseEncoding" xml:space="preserve">
121+
<value>Choose Encoding:</value>
122+
</data>
123+
<data name="ChooseEncodingTitle" xml:space="preserve">
121124
<value>Choose Encoding</value>
122125
</data>
123126
<data name="OutputText" xml:space="preserve">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using EncodingConverter.VisualStudio.Properties;
2+
using System.Resources;
3+
4+
namespace EncodingConverter.VisualStudio;
5+
6+
public sealed class WpfLocalizer {
7+
private static readonly ResourceManager _resourceManager = Resources.ResourceManager;
8+
9+
public string? this[string id] {
10+
get {
11+
if (string.IsNullOrWhiteSpace(id)) {
12+
return null;
13+
}
14+
15+
//1. 리소스에서 값 조회
16+
var str = _resourceManager.GetString(id, Resources.Culture);
17+
18+
//2. 없으면 키 반환
19+
if (string.IsNullOrWhiteSpace(str)) {
20+
str = id;
21+
}
22+
23+
return str;
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)