Skip to content

Commit

Permalink
Implement localization
Browse files Browse the repository at this point in the history
  • Loading branch information
haefele committed Nov 21, 2023
1 parent 59aa506 commit 36fa35d
Show file tree
Hide file tree
Showing 14 changed files with 1,123 additions and 88 deletions.
15 changes: 13 additions & 2 deletions src/ChatPrisma/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Threading;
using ChatPrisma.Host;
using ChatPrisma.HostedServices;
using ChatPrisma.Options;
using ChatPrisma.Resources;
using ChatPrisma.Services.AutoStart;
using ChatPrisma.Services.ChatBot;
using ChatPrisma.Services.Dialogs;
Expand All @@ -29,6 +31,14 @@ public partial class App : ISingleInstance
{
private IHost? _host;

public App()
{
// Setup culture
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag)));
}

private async void App_OnStartup(object sender, StartupEventArgs e)
{
try
Expand All @@ -40,6 +50,7 @@ private async void App_OnStartup(object sender, StartupEventArgs e)
return;
}

// Create and start host
this._host = this.CreateHostBuilder(e.Args).Build();
await this._host.StartAsync();

Expand Down Expand Up @@ -99,7 +110,7 @@ private IHostBuilder CreateHostBuilder(string[] args) => Microsoft.Extensions.Ho
o.MouseDoubleClickAction = WindowsTray.HandleDoubleClick;
o.ContextMenuFactory = WindowsTray.CreateContextMenu;
o.AppShutdownEnabled = true;
o.AppShutdownHeader = "Beenden";
o.AppShutdownHeader = Strings.Shutdown;
});
services.AddOptions<OpenAIOptions>()
.BindConfiguration(OpenAIOptions.Section)
Expand Down
21 changes: 21 additions & 0 deletions src/ChatPrisma/ChatPrisma.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,26 @@
<ItemGroup Label="Images">
<Resource Include="Themes\Images\*" />
</ItemGroup>

<ItemGroup Label="Localization">
<EmbeddedResource Update="Resources\Strings.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Compile Update="Resources\Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<EmbeddedResource Update="Resources\Strings.de.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.de.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Compile Update="Resources\Strings.de.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Strings.de.resx</DependentUpon>
</Compile>
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/ChatPrisma/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System.Resources;
using System.Windows;

[assembly: NeutralResourcesLanguage("en")]

[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
Loading

0 comments on commit 36fa35d

Please sign in to comment.