diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs
index 9ea96a45c..93de4c64d 100644
--- a/Dalamud/Dalamud.cs
+++ b/Dalamud/Dalamud.cs
@@ -65,7 +65,12 @@ internal sealed class Dalamud : IServiceType
true, new FileInfo(Path.Combine(cacheDir.FullName, $"{this.StartInfo.GameVersion}.json")));
}
- ServiceManager.InitializeProvidedServices(this, fs, configuration, scanner);
+ ServiceManager.InitializeProvidedServices(
+ this,
+ fs,
+ configuration,
+ scanner,
+ Localization.FromAssets(info.AssetDirectory!, configuration.LanguageOverride));
// Set up FFXIVClientStructs
this.SetupClientStructsResolver(cacheDir);
diff --git a/Dalamud/Localization.cs b/Dalamud/Localization.cs
index 3ed2ad519..84e8437b3 100644
--- a/Dalamud/Localization.cs
+++ b/Dalamud/Localization.cs
@@ -4,7 +4,6 @@ using System.Linq;
using System.Reflection;
using CheapLoc;
-using Dalamud.Configuration.Internal;
using Serilog;
@@ -13,7 +12,7 @@ namespace Dalamud;
///
/// Class handling localization.
///
-[ServiceManager.EarlyLoadedService]
+[ServiceManager.ProvidedService]
public class Localization : IServiceType
{
///
@@ -43,16 +42,6 @@ public class Localization : IServiceType
this.assembly = Assembly.GetCallingAssembly();
}
- [ServiceManager.ServiceConstructor]
- private Localization(Dalamud dalamud, DalamudConfiguration configuration)
- : this(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_")
- {
- if (!string.IsNullOrEmpty(configuration.LanguageOverride))
- this.SetupWithLangCode(configuration.LanguageOverride);
- else
- this.SetupWithUiCulture();
- }
-
///
/// Delegate for the event that occurs when the language is changed.
///
@@ -167,6 +156,22 @@ public class Localization : IServiceType
Loc.ExportLocalizableForAssembly(this.assembly, ignoreInvalidFunctions);
}
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// Path to Dalamud assets.
+ /// Optional language override.
+ /// A new instance.
+ internal static Localization FromAssets(string assetDirectory, string? languageOverride)
+ {
+ var t = new Localization(Path.Combine(assetDirectory, "UIRes", "loc", "dalamud"), "dalamud_");
+ if (!string.IsNullOrEmpty(languageOverride))
+ t.SetupWithLangCode(languageOverride);
+ else
+ t.SetupWithUiCulture();
+ return t;
+ }
+
private string ReadLocData(string langCode)
{
if (this.useEmbedded)
diff --git a/Dalamud/Service/ServiceManager.cs b/Dalamud/Service/ServiceManager.cs
index 7483b0a27..3f8a55614 100644
--- a/Dalamud/Service/ServiceManager.cs
+++ b/Dalamud/Service/ServiceManager.cs
@@ -126,7 +126,13 @@ internal static class ServiceManager
/// Instance of .
/// Instance of .
/// Instance of .
- public static void InitializeProvidedServices(Dalamud dalamud, ReliableFileStorage fs, DalamudConfiguration configuration, TargetSigScanner scanner)
+ /// Instance of .
+ public static void InitializeProvidedServices(
+ Dalamud dalamud,
+ ReliableFileStorage fs,
+ DalamudConfiguration configuration,
+ TargetSigScanner scanner,
+ Localization localization)
{
#if DEBUG
lock (LoadedServices)
@@ -136,6 +142,7 @@ internal static class ServiceManager
ProvideService(configuration);
ProvideService(new ServiceContainer());
ProvideService(scanner);
+ ProvideService(localization);
}
return;
@@ -152,6 +159,7 @@ internal static class ServiceManager
ProvideService(configuration);
ProvideService(new ServiceContainer());
ProvideService(scanner);
+ ProvideService(localization);
return;
void ProvideService(T service) where T : IServiceType => Service.Provide(service);