Skip to content

Commit

Permalink
Merge pull request #219 from jwallet/german
Browse files Browse the repository at this point in the history
Updated i18n strings and added German
  • Loading branch information
jwallet authored Apr 29, 2020
2 parents 4f3c38a + d19a733 commit bf50195
Show file tree
Hide file tree
Showing 17 changed files with 1,124 additions and 86 deletions.
26 changes: 25 additions & 1 deletion EspionSpotify.Tests/TranslationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace EspionSpotify.Tests
public class TranslationTests
{
private readonly Type _en;
private readonly Type _de;
private readonly Type _fr;
private readonly Type _nl;
private static ResourceManager RM;
Expand All @@ -19,17 +20,22 @@ public class TranslationTests
public TranslationTests()
{
_en = Translations.Languages.getResourcesManagerLanguageType(Enums.LanguageType.en);

_de = Translations.Languages.getResourcesManagerLanguageType(Enums.LanguageType.de);
_fr = Translations.Languages.getResourcesManagerLanguageType(Enums.LanguageType.fr);
_nl = Translations.Languages.getResourcesManagerLanguageType(Enums.LanguageType.nl);

_keysCount = Enum.GetNames(typeof(Enums.TranslationKeys)).Count();
}

[Fact]
internal void TranslationSetup_ShouldBeReady()
{
Assert.NotNull(_en);

Assert.NotNull(_de);
Assert.NotNull(_fr);
//Assert.NotNull(_nl);
Assert.NotNull(_nl);
}

[Fact]
Expand All @@ -50,6 +56,24 @@ internal void English_ShouldGetTranslations()
Assert.Equal(count, _keysCount);
}

[Fact]
internal void German_ShouldGetTranslations()
{
RM = new ResourceManager(_de);
var resourceSet = RM.GetResourceSet(CultureInfo.InvariantCulture, true, true);
var count = 0;

foreach (DictionaryEntry o in resourceSet)
{
count++;
var actual = (string)o.Key;
var expected = actual.ToEnum<Enums.TranslationKeys>(ignoreCase: false)?.ToString();
Assert.Equal(expected, actual);
}

Assert.Equal(count, _keysCount);
}

[Fact]
internal void French_ShouldGetTranslations()
{
Expand Down
2 changes: 2 additions & 0 deletions EspionSpotify/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@
</setting>
<setting name="SpotifyAPISecretId" serializeAs="String">
<value>
ced9c679a66641f484e6740fff479e14
</value>
</setting>
<setting name="SpotifyAPIClientId" serializeAs="String">
<value>
412ea2302d86443e854740ba35e869cb
</value>
</setting>
</EspionSpotify.Properties.Settings>
Expand Down
7 changes: 4 additions & 3 deletions EspionSpotify/Enums/LanguageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
{
public enum LanguageType
{
en = 0,
fr,
nl
en = 0,
de, // German
fr, // French
nl // Dutch
}
}
1 change: 0 additions & 1 deletion EspionSpotify/Enums/TranslationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public enum TranslationKeys
msgNewVersionContent,
msgNewVersionTitle,
msgTitleCantQuit,
msgTitleDriverInstallationFailed,
msgTitlePathNotFound,
tabAdvanced,
tabRecord,
Expand Down
10 changes: 10 additions & 0 deletions EspionSpotify/EspionSpotify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@
<Compile Include="MediaTags\ILastFMAPI.cs" />
<Compile Include="MediaTags\ISpotifyAPI.cs" />
<Compile Include="Models\OutputFile.cs" />
<Compile Include="Translations\de.Designer.cs">
<DependentUpon>de.resx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Translations\I18nKeys.cs" />
<Compile Include="Translations\nl.Designer.cs">
<DependentUpon>nl.resx</DependentUpon>
Expand Down Expand Up @@ -264,6 +269,11 @@
</Compile>
<Compile Include="Translations\Languages.cs" />
<Compile Include="Watcher.cs" />
<EmbeddedResource Include="Translations\de.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>de.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Translations\nl.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>nl.Designer.cs</LastGenOutput>
Expand Down
1 change: 0 additions & 1 deletion EspionSpotify/Translations/I18nKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public static class I18nKeys
public static TranslationKeys MsgNewVersionContent { get => TranslationKeys.msgNewVersionContent; }
public static TranslationKeys MsgNewVersionTitle { get => TranslationKeys.msgNewVersionTitle; }
public static TranslationKeys MsgTitleCantQuit { get => TranslationKeys.msgTitleCantQuit; }
public static TranslationKeys MsgTitleDriverInstallationFailed { get => TranslationKeys.msgTitleDriverInstallationFailed; }
public static TranslationKeys MsgTitlePathNotFound { get => TranslationKeys.msgTitlePathNotFound; }

public static TranslationKeys TabAdvanced { get => TranslationKeys.tabAdvanced; }
Expand Down
6 changes: 4 additions & 2 deletions EspionSpotify/Translations/Languages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class Languages
{
public static readonly Dictionary<LanguageType, Type> availableResourcesManager = new Dictionary<LanguageType, Type>
{
{ LanguageType.de, typeof(de) },
{ LanguageType.en, typeof(en) },
{ LanguageType.fr, typeof(fr) },
{ LanguageType.nl, typeof(nl) }
Expand All @@ -22,8 +23,9 @@ public static Type getResourcesManagerLanguageType(LanguageType languageType)
internal static readonly Dictionary<LanguageType, string> dropdownListValues = new Dictionary<LanguageType, string>
{
{ LanguageType.en, "English" },
{ LanguageType.fr, "Français" },
{ LanguageType.nl, "Nederlands" }
{ LanguageType.de, "Deutsch" }, // German
{ LanguageType.fr, "Français" }, // French
{ LanguageType.nl, "Nederlands" }, // Dutch
};
}
}
Loading

0 comments on commit bf50195

Please sign in to comment.