68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using System.Globalization;
|
|
using Jellyfin.Plugin.Multilang.Configuration;
|
|
using Jellyfin.Plugin.Multilang.Services.Injection;
|
|
using MediaBrowser.Common.Configuration;
|
|
using MediaBrowser.Common.Plugins;
|
|
using MediaBrowser.Model.Plugins;
|
|
using MediaBrowser.Model.Serialization;
|
|
|
|
namespace Jellyfin.Plugin.Multilang;
|
|
|
|
public sealed class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|
{
|
|
public static Plugin? Instance { get; private set; }
|
|
|
|
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
|
|
: base(applicationPaths, xmlSerializer)
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
public override string Name => "Multilang";
|
|
|
|
public override Guid Id => Guid.Parse("9d7c61a5-7a1b-4d1e-9b79-4c8c6d2e8a2a");
|
|
|
|
public override void OnUninstalling()
|
|
{
|
|
WebScriptInjector.RemoveInjected(ApplicationPaths.WebPath);
|
|
|
|
if (Configuration.CleanupDataOnUninstall)
|
|
{
|
|
var dataDir = Path.Combine(ApplicationPaths.DataPath, "multilang");
|
|
if (Directory.Exists(dataDir))
|
|
Directory.Delete(dataDir, recursive: true);
|
|
|
|
if (File.Exists(ConfigurationFilePath))
|
|
File.Delete(ConfigurationFilePath);
|
|
}
|
|
|
|
base.OnUninstalling();
|
|
}
|
|
|
|
public IEnumerable<PluginPageInfo> GetPages()
|
|
{
|
|
yield return new PluginPageInfo
|
|
{
|
|
Name = "Multilang",
|
|
DisplayName = "Multilang",
|
|
EmbeddedResourcePath = string.Format(
|
|
CultureInfo.InvariantCulture,
|
|
"{0}.Configuration.configPage.html",
|
|
GetType().Namespace),
|
|
EnableInMainMenu = true,
|
|
MenuSection = "plugins",
|
|
MenuIcon = "translate"
|
|
};
|
|
|
|
yield return new PluginPageInfo
|
|
{
|
|
Name = "MultilangUser",
|
|
DisplayName = "Multilang User Rules",
|
|
EmbeddedResourcePath = string.Format(
|
|
CultureInfo.InvariantCulture,
|
|
"{0}.Configuration.userRulesPage.html",
|
|
GetType().Namespace)
|
|
};
|
|
}
|
|
}
|