Skip to content

Commit

Permalink
add localization support and french language 🥖
Browse files Browse the repository at this point in the history
  • Loading branch information
xorus committed Oct 1, 2021
1 parent 1936725 commit 84daeaf
Show file tree
Hide file tree
Showing 8 changed files with 972 additions and 88 deletions.
10 changes: 10 additions & 0 deletions EngageTimer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Remove="Doc\icon - Copy.png" />
<EmbeddedResource Update="Resources\strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Compile Update="Resources\strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>strings.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<PackageReference Include="CheapLoc" Version="1.1.6" />
<PackageReference Include="DalamudPackager" Version="2.1.2" />
<PackageReference Include="EmbedIO" Version="3.4.3" />
<PackageReference Include="NAudio" Version="2.0.1" />
Expand Down
18 changes: 0 additions & 18 deletions EngageTimer.json

This file was deleted.

17 changes: 17 additions & 0 deletions EngageTimer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: EngageTimer
author: Xorus
punchline: Combat countdown with all numbers, stopwatch and OBS support
description: |-
Combat Timer for OBS and ingame overlay with some benefits like a big nice countdown in the middle of the screen in the style of the original one.
Please consult the repository link for OBS setup instructions.
tags:
- countdown
- stopwatch
- OBS
- streaming
- combat
repo_url: https://github.com/xorus/EngageTimer
icon_url: https://github.com/goatcorp/DalamudPlugins/blob/api4/plugins/EngageTimer/images/icon.png
image_urls:
- https://github.com/goatcorp/DalamudPlugins/blob/api4/plugins/EngageTimer/images/image1.png
- https://github.com/goatcorp/DalamudPlugins/blob/api4/plugins/EngageTimer/images/image2.png
19 changes: 19 additions & 0 deletions Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using Dalamud;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Plugin;
using EngageTimer.Attributes;
using EngageTimer.Properties;
using EngageTimer.Web;

/*
Expand All @@ -24,6 +27,7 @@ public class Plugin : IDalamudPlugin
private readonly StopWatchHook _stopWatchHook;
private readonly PluginUi _ui;
private readonly ClientState _clientState;
private readonly Localization _localization;

// ReSharper disable once UnusedAutoPropertyAccessor.Global
public string AssemblyLocation { get; set; }
Expand Down Expand Up @@ -53,6 +57,8 @@ public Plugin(
localPath = Path.GetDirectoryName(AssemblyLocation);
}

this._localization = new Localization(_pluginInterface.GetPluginLocDirectory());

_configuration = (Configuration)_pluginInterface.GetPluginConfig() ?? new Configuration();
_configuration.Initialize(_pluginInterface);
_configuration.Migrate();
Expand All @@ -67,12 +73,25 @@ public Plugin(
_pluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;

_server = new WebServer(_configuration, localPath, state);
_pluginInterface.LanguageChanged += ConfigureLanguage;
ConfigureLanguage();
}

private void ConfigureLanguage(string? langCode = null)
{
var lang = (langCode ?? this._pluginInterface.UiLanguage) switch
{
"fr" => "fr",
_ => "en"
};
Resources.Culture = new CultureInfo(lang ?? "en");
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
_pluginInterface.LanguageChanged -= ConfigureLanguage;
}

private void DrawUi()
Expand Down
Loading

0 comments on commit 84daeaf

Please sign in to comment.