Skip to content

Commit

Permalink
Merge pull request #71 from fmmmlee/68-add-localization-support-for-k…
Browse files Browse the repository at this point in the history
…r-cn-and-fr-players

68 add localization support for kr cn and fr players
  • Loading branch information
fmmmlee committed Nov 1, 2020
2 parents c5ade6e + 964e785 commit 59425f9
Show file tree
Hide file tree
Showing 14 changed files with 707 additions and 10 deletions.
6 changes: 6 additions & 0 deletions application/GW2 Addon Manager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application", "GW2 Addon Ma
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationTests", "ApplicationTests\ApplicationTests.csproj", "{170F11FB-4005-4A31-A746-32B46814F463}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Localization", "Localization\Localization.csproj", "{5B139D74-6A36-4F8F-833F-4D0DE41FF019}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{170F11FB-4005-4A31-A746-32B46814F463}.Debug|Any CPU.Build.0 = Debug|Any CPU
{170F11FB-4005-4A31-A746-32B46814F463}.Release|Any CPU.ActiveCfg = Release|Any CPU
{170F11FB-4005-4A31-A746-32B46814F463}.Release|Any CPU.Build.0 = Release|Any CPU
{5B139D74-6A36-4F8F-833F-4D0DE41FF019}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B139D74-6A36-4F8F-833F-4D0DE41FF019}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B139D74-6A36-4F8F-833F-4D0DE41FF019}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B139D74-6A36-4F8F-833F-4D0DE41FF019}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Localization;
using System;

namespace GW2_Addon_Manager.App.Configuration.Model
{
Expand All @@ -15,6 +16,8 @@ public class UserConfig

public string ExeName { get; set; }

public string Culture { get; set; } = CultureConstants.English;

public AddonsList AddonsList { get; set; } = new AddonsList();
}
}
7 changes: 6 additions & 1 deletion application/GW2 Addon Manager/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\Localization\Localization.csproj">
<Project>{5b139d74-6a36-4f8f-833f-4d0de41ff019}</Project>
<Name>Localization</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>mkdir "$(TargetDir)resources\plugins"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ public void SetGamePath(string path)
DetermineSystemType();
}

/// <summary>
/// <c>SetCulture</c> both sets the culture for the current application session to <paramref name="culture"/> and records it in the configuration file.
/// </summary>
/// <param name="culture"></param>
public void SetCulture(string culture)
{
Application.Current.Properties["culture"] = culture;
_configurationManager.UserConfig.Culture = culture;
_configurationManager.SaveConfiguration();
RestartApplication();
}

/// <summary>
/// Restarts the application.
/// </summary>
private void RestartApplication()
{
System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
Application.Current.Shutdown();
}

/// <summary>
/// Checks if there is a new version of the application available.
/// </summary>
Expand Down
55 changes: 47 additions & 8 deletions application/GW2 Addon Manager/UI/OpeningPage/OpeningView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:l="clr-namespace:Localization;assembly=Localization"
xmlns:viewModel ="clr-namespace:GW2_Addon_Manager"
x:Class="GW2_Addon_Manager.OpeningView"
mc:Ignorable="d"
Expand Down Expand Up @@ -41,7 +42,7 @@
</TextBlock>

<TextBlock
Margin="110, 0, 0, -10"
Margin="170, 0, 0, -10"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Background="Transparent"
Expand Down Expand Up @@ -93,10 +94,48 @@
Style="{StaticResource AddonMenuItemStyle}"
/>
</MenuItem>
<MenuItem Header="{x:Static l:StaticText.Language}" HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Center"
Height="30"
Padding="5,2,5,5"
Template="{StaticResource AddonMenuItemControlTemplate}"
Style="{StaticResource AddonMenuItemStyle}"
Background="Transparent"
Foreground="DimGray"
>
<MenuItem
Header="{x:Static l:StaticText.English}"
Command="{Binding Path=ChangeLanguage}"
CommandParameter="{x:Static l:CultureConstants.English}"
Template="{StaticResource AddonMenuItemControlTemplate}"
Style="{StaticResource AddonMenuItemStyle}"
/>
<MenuItem
Header="{x:Static l:StaticText.French}"
Command="{Binding Path=ChangeLanguage}"
CommandParameter="{x:Static l:CultureConstants.French}"
Template="{StaticResource AddonMenuItemControlTemplate}"
Style="{StaticResource AddonMenuItemStyle}"
/>
<MenuItem
Header="{x:Static l:StaticText.Chinese}"
Command="{Binding Path=ChangeLanguage}"
CommandParameter="{x:Static l:CultureConstants.Chinese}"
Template="{StaticResource AddonMenuItemControlTemplate}"
Style="{StaticResource AddonMenuItemStyle}"
/>
<MenuItem
Header="{x:Static l:StaticText.Korean}"
Command="{Binding Path=ChangeLanguage}"
CommandParameter="{x:Static l:CultureConstants.Korean}"
Template="{StaticResource AddonMenuItemControlTemplate}"
Style="{StaticResource AddonMenuItemStyle}"
/>
</MenuItem>
</Menu>
<TextBlock Text="{Binding UpdateAvailable}"
Grid.Row="1"
Margin="320,-6,0,0"
Margin="380,-6,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
FontFamily="Microsoft YaHei UI Light"
Expand All @@ -108,7 +147,7 @@
/>
<TextBlock Text="{Binding UpdateAvailable}"
Grid.Row="1"
Margin="320,-6,0,0"
Margin="380,-6,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
FontFamily="Microsoft YaHei UI Light"
Expand All @@ -120,7 +159,7 @@
/>
<ProgressBar
Grid.Row = "1"
Margin="435,-6,0,0"
Margin="495,-6,0,0"
Width="125"
Height="12"
HorizontalAlignment="Left"
Expand All @@ -131,7 +170,7 @@
/>
<Button
Grid.Row = "1"
Margin="415,-10,0,0"
Margin="475,-10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="50"
Expand All @@ -149,7 +188,7 @@
<Button Name="SelectDirectoryBtn"
Click="SelectDirectoryBtn_OnClick"
Grid.Row="2"
Margin="725,0,0,9"
Margin="785,0,0,9"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="Select Directory"
Expand All @@ -164,7 +203,7 @@
/>
<TextBox Text="{Binding GamePath}"
Grid.Row="2"
Margin="320,0,0,10"
Margin="380,0,0,10"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Width="400"
Expand Down Expand Up @@ -211,7 +250,7 @@
</StackPanel>
</Border>

<Border Grid.Row="2" Width="450" Height="280" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="320,20,0,0" BorderThickness="1" BorderBrush="DimGray" Background="WhiteSmoke">
<Border Grid.Row="2" Width="450" Height="280" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="380,20,0,0" BorderThickness="1" BorderBrush="DimGray" Background="WhiteSmoke">
<Grid>
<DockPanel Width="450" Height="280" HorizontalAlignment="Left">
<Label FontSize="13"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using GW2_Addon_Manager.App.Configuration;
using Application = System.Windows.Application;
using MessageBox = System.Windows.MessageBox;
using System.Threading;
using System.Globalization;

namespace GW2_Addon_Manager
{
Expand All @@ -33,6 +35,7 @@ public OpeningView()
DataContext = OpeningViewModel.GetInstance;

_configurationManager = new ConfigurationManager();
Thread.CurrentThread.CurrentUICulture = new CultureInfo(_configurationManager.UserConfig.Culture);
var configuration = new Configuration(_configurationManager);
configuration.CheckSelfUpdates();
configuration.DetermineSystemType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ public ICommand CleanInstall
{
get => new RelayCommand<object>(param => _pluginManagement.DeleteAll(), true);
}
/// <summary>
/// Handles the Change Language buttons.
/// </summary>
public ICommand ChangeLanguage
{
get => new RelayCommand<string>(param => _configuration.SetCulture(param), true);
}

/******************************************/

Expand Down
12 changes: 12 additions & 0 deletions application/Localization/CultureConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Data;

namespace Localization
{
public static class CultureConstants
{
public const string Chinese = "zh-CN";
public const string English = "en-US";
public const string French = "fr-CA";
public const string Korean = "ko-KR";
}
}
22 changes: 22 additions & 0 deletions application/Localization/Localization.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Update="StaticText.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>StaticText.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="StaticText.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>StaticText.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
108 changes: 108 additions & 0 deletions application/Localization/StaticText.Designer.cs

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

Loading

0 comments on commit 59425f9

Please sign in to comment.