Skip to content

Commit

Permalink
rename Resources.resx to Strings.resx
Browse files Browse the repository at this point in the history
  • Loading branch information
xorus committed Feb 5, 2024
1 parent 46b67d7 commit 3892327
Show file tree
Hide file tree
Showing 21 changed files with 389 additions and 236 deletions.
13 changes: 7 additions & 6 deletions Plugin/Commands/MainCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System;
using Dalamud.Game.Command;
using EngageTimer.Localization;
using EngageTimer.Properties;

namespace EngageTimer.Commands;

Expand All @@ -42,13 +43,13 @@ private void Register()
{
HelpMessage = "\n" +
Tab + Command + " c|countdown [on|off] → " +
$"{Translator.Tr("MainCommand_Help_Countdown")}\n" +
$"{Strings.MainCommand_Help_Countdown}\n" +
Tab + Command + " fw [on|off] → " +
$"{Translator.Tr("MainCommand_Help_FW")}\n" +
$"{Strings.MainCommand_Help_FW}\n" +
Tab + Command + " dtr [on|off] → " +
$"{Translator.Tr("MainCommand_Help_Dtr")}\n" +
$"{Strings.MainCommand_Help_Dtr}\n" +
Tab + Command + " s|settings → " +
$"{Translator.Tr("MainCommand_Help_Settings")}\n"
$"{Strings.MainCommand_Help_Settings}\n"
});
}

Expand All @@ -68,9 +69,9 @@ private static bool ToStatus(string input, bool current)
};
}

private string StatusStr(bool value)
private static string StatusStr(bool value)
{
return Translator.Tr(value ? "MainCommand_Status_On" : "MainCommand_Status_Off");
return value ? Strings.MainCommand_Status_On : Strings.MainCommand_Status_Off;
}

private void OnCommand(string command, string args)
Expand Down
5 changes: 2 additions & 3 deletions Plugin/Commands/SettingsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

using System;
using Dalamud.Game.Command;
using EngageTimer.Localization;
using EngageTimer.Ui;
using EngageTimer.Properties;

namespace EngageTimer.Commands;

Expand All @@ -26,7 +25,7 @@ public SettingsCommand()
{
Plugin.Commands.AddHandler("/egsettings", new CommandInfo(OpenSettingsCommand)
{
HelpMessage = Translator.Tr("MainCommand_Help_Settings")
HelpMessage = Strings.MainCommand_Help_Settings
});
}

Expand Down
21 changes: 18 additions & 3 deletions Plugin/EngageTimer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
<None Update="Data\numbers\wow\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Update="Properties\Strings.de.resx">
<DependentUpon>Strings.resx</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Strings.fr.resx">
<DependentUpon>Strings.resx</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Strings.ja.resx">
<DependentUpon>Strings.resx</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Strings.ko.resx">
<DependentUpon>Strings.resx</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Strings.zh.resx">
<DependentUpon>Strings.resx</DependentUpon>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand All @@ -59,15 +74,15 @@
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<Compile Update="Properties\Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<EmbeddedResource Update="Properties\Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
Expand Down
16 changes: 10 additions & 6 deletions Plugin/Localization/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,21 @@ public static void Unregister()

public static string TrId(string id)
{
return $"{Resources.ResourceManager.GetString(id, Resources.Culture) ?? id}###EngageTimer_{id}";
return $"{Strings.ResourceManager.GetString(id, Strings.Culture) ?? id}###EngageTimer_{id}";
}

public static string TrId(string id, string fallback)
{
return $"{Resources.ResourceManager.GetString(id, Resources.Culture) ?? fallback}###EngageTimer_{id}";
return $"{Strings.ResourceManager.GetString(id, Strings.Culture) ?? fallback}###EngageTimer_{id}";
}

public static string Tr(string id)
{
return Resources.ResourceManager.GetString(id, Resources.Culture) ?? id;
return Strings.ResourceManager.GetString(id, Strings.Culture) ?? id;
}

public static string Tr(string id, params string[] replacements)
public static string Re(string str, params string[] replacements)
{
var str = Tr(id);
for (var index = 0; index < replacements.Length; index++)
{
var value = replacements[index];
Expand All @@ -61,6 +60,11 @@ public static string Tr(string id, params string[] replacements)
return str;
}

public static string Tr(string id, params string[] replacements)
{
return Re(id, replacements);
}

private static void ConfigureLanguage(string? langCode = null)
{
var lang = (langCode ?? Plugin.PluginInterface.UiLanguage) switch
Expand All @@ -71,7 +75,7 @@ private static void ConfigureLanguage(string? langCode = null)
"zh" => "zh",
_ => "en"
};
Resources.Culture = new CultureInfo(lang ?? "en");
Strings.Culture = new CultureInfo(lang ?? "en");
LocaleChanged?.Invoke(null, EventArgs.Empty);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Loading

0 comments on commit 3892327

Please sign in to comment.