diff --git a/ZuneModdingHelper/App.cs b/ZuneModdingHelper/App.cs index cdf6cd9..11e2a65 100644 --- a/ZuneModdingHelper/App.cs +++ b/ZuneModdingHelper/App.cs @@ -1,10 +1,12 @@ using System; using CommunityToolkit.Mvvm.DependencyInjection; using IrisShell; -using IrisShell.UI; using Microsoft.AppCenter; using Microsoft.AppCenter.Analytics; using Microsoft.AppCenter.Crashes; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using ZuneModdingHelper.Services; namespace ZuneModdingHelper; @@ -34,8 +36,6 @@ public class App : IrisAppBase { ConfigureAppCenter(); - _ = new Shell(); - App app = new(); return app.Run(args); } @@ -60,6 +60,12 @@ public class App : IrisAppBase #endif } + protected override IServiceCollection ConfigureServices(IServiceCollection services) + { + return base.ConfigureServices(services) + .AddSingleton(new LocalizationService()); + } + private void OnServiceProviderReady(object sender, IServiceProvider serviceProvider) { ServiceProviderReady -= OnServiceProviderReady; diff --git a/ZuneModdingHelper/Assets/Strings.Designer.cs b/ZuneModdingHelper/Assets/Strings.Designer.cs new file mode 100644 index 0000000..93741dd --- /dev/null +++ b/ZuneModdingHelper/Assets/Strings.Designer.cs @@ -0,0 +1,99 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ZuneModdingHelper.Assets { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Strings { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Strings() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ZuneModdingHelper.Assets.Strings", typeof(Strings).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Back. + /// + internal static string IDS_NAVIGATE_BACK { + get { + return ResourceManager.GetString("IDS_NAVIGATE_BACK", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Do you want to switch the tendering backend to DirectX? This enabled more advanced animations, but may cause compatibility issues.. + /// + internal static string IDS_RENDER_PROMPT_AFTER_D3D_SWITCH { + get { + return ResourceManager.GetString("IDS_RENDER_PROMPT_AFTER_D3D_SWITCH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Information. + /// + internal static string IDS_RENDER_PROMPT_CAPTION { + get { + return ResourceManager.GetString("IDS_RENDER_PROMPT_CAPTION", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to SETTINGS. + /// + internal static string IDS_SETTINGS_LAND_HEADER { + get { + return ResourceManager.GetString("IDS_SETTINGS_LAND_HEADER", resourceCulture); + } + } + } +} diff --git a/ZuneModdingHelper/Assets/Strings.resx b/ZuneModdingHelper/Assets/Strings.resx new file mode 100644 index 0000000..9e84da0 --- /dev/null +++ b/ZuneModdingHelper/Assets/Strings.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Back + + + Do you want to switch the tendering backend to DirectX? This enabled more advanced animations, but may cause compatibility issues. + + + Information + + + SETTINGS + + \ No newline at end of file diff --git a/ZuneModdingHelper/Home.uix b/ZuneModdingHelper/Home.uix index bf523fd..67182f4 100644 --- a/ZuneModdingHelper/Home.uix +++ b/ZuneModdingHelper/Home.uix @@ -271,7 +271,7 @@ + Margins="{istyles:Styles.FrameMargins}" LayoutInput="{DockLayoutInput.Client}"> diff --git a/ZuneModdingHelper/Services/LocalizationService.cs b/ZuneModdingHelper/Services/LocalizationService.cs new file mode 100644 index 0000000..2e62a7b --- /dev/null +++ b/ZuneModdingHelper/Services/LocalizationService.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.Localization; +using System; +using System.Collections.Generic; +using ZuneModdingHelper.Assets; + +namespace ZuneModdingHelper.Services; + +internal class LocalizationService : IStringLocalizer +{ + public LocalizedString this[string name] + { + get + { + var value = Strings.ResourceManager.GetString(name); + return value is null + ? new(name, name, true) + : new(name, value); + } + } + + public LocalizedString this[string name, params object[] arguments] => this[name]; + + public IEnumerable GetAllStrings(bool includeParentCultures) + { + throw new NotImplementedException(); + } +} diff --git a/ZuneModdingHelper/ZuneModdingHelper.csproj b/ZuneModdingHelper/ZuneModdingHelper.csproj index 8386c07..2c24281 100644 --- a/ZuneModdingHelper/ZuneModdingHelper.csproj +++ b/ZuneModdingHelper/ZuneModdingHelper.csproj @@ -32,10 +32,25 @@ - + PreserveNewest + + + True + True + Strings.resx + + + + + + ResXFileCodeGenerator + Strings.Designer.cs + + +