mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-15 20:37:42 +01:00
Localization: change to a provided service
This commit is contained in:
parent
aa99be6ccb
commit
efaa346d5e
3 changed files with 32 additions and 14 deletions
|
|
@ -4,7 +4,6 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
|
||||
using CheapLoc;
|
||||
using Dalamud.Configuration.Internal;
|
||||
|
||||
using Serilog;
|
||||
|
||||
|
|
@ -13,7 +12,7 @@ namespace Dalamud;
|
|||
/// <summary>
|
||||
/// Class handling localization.
|
||||
/// </summary>
|
||||
[ServiceManager.EarlyLoadedService]
|
||||
[ServiceManager.ProvidedService]
|
||||
public class Localization : IServiceType
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the <see cref="Localization.LocalizationChanged"/> event that occurs when the language is changed.
|
||||
/// </summary>
|
||||
|
|
@ -167,6 +156,22 @@ public class Localization : IServiceType
|
|||
Loc.ExportLocalizableForAssembly(this.assembly, ignoreInvalidFunctions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Localization"/> class.
|
||||
/// </summary>
|
||||
/// <param name="assetDirectory">Path to Dalamud assets.</param>
|
||||
/// <param name="languageOverride">Optional language override.</param>
|
||||
/// <returns>A new instance.</returns>
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue