diff --git a/src/Humanizer.Tests.Shared/Localisation/de/Bytes/ToFullWordsTests.cs b/src/Humanizer.Tests.Shared/Localisation/de/Bytes/ToFullWordsTests.cs index ce063fbd6..3270575d4 100644 --- a/src/Humanizer.Tests.Shared/Localisation/de/Bytes/ToFullWordsTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/de/Bytes/ToFullWordsTests.cs @@ -16,7 +16,7 @@ public void ReturnsSingularBit() [Fact] public void ReturnsPluralBits() { - Assert.Equal("2 Bits", ByteSize.FromBits(2).ToFullWords()); + Assert.Equal("2 Bit", ByteSize.FromBits(2).ToFullWords()); } [Fact] @@ -28,7 +28,7 @@ public void ReturnsSingularByte() [Fact] public void ReturnsPluralBytes() { - Assert.Equal("10 Bytes", ByteSize.FromBytes(10).ToFullWords()); + Assert.Equal("10 Byte", ByteSize.FromBytes(10).ToFullWords()); } [Fact] @@ -40,7 +40,7 @@ public void ReturnsSingularKiloByte() [Fact] public void ReturnsPluralKilobytes() { - Assert.Equal("10 Kilobytes", ByteSize.FromKilobytes(10).ToFullWords()); + Assert.Equal("10 Kilobyte", ByteSize.FromKilobytes(10).ToFullWords()); } [Fact] @@ -52,7 +52,7 @@ public void ReturnsSingularMegabyte() [Fact] public void ReturnsPluralMegabytes() { - Assert.Equal("10 Megabytes", ByteSize.FromMegabytes(10).ToFullWords()); + Assert.Equal("10 Megabyte", ByteSize.FromMegabytes(10).ToFullWords()); } [Fact] @@ -64,7 +64,7 @@ public void ReturnsSingularGigabyte() [Fact] public void ReturnsPluralGigabytes() { - Assert.Equal("10 Gigabytes", ByteSize.FromGigabytes(10).ToFullWords()); + Assert.Equal("10 Gigabyte", ByteSize.FromGigabytes(10).ToFullWords()); } [Fact] @@ -76,12 +76,12 @@ public void ReturnsSingularTerabyte() [Fact] public void ReturnsPluralTerabytes() { - Assert.Equal("10 Terabytes", ByteSize.FromTerabytes(10).ToFullWords()); + Assert.Equal("10 Terabyte", ByteSize.FromTerabytes(10).ToFullWords()); } [Theory] - [InlineData(229376, "B", "229376 Bytes")] - [InlineData(229376, "# KB", "224 Kilobytes")] + [InlineData(229376, "B", "229376 Byte")] + [InlineData(229376, "# KB", "224 Kilobyte")] public void ToFullWordsFormatted(double input, string format, string expectedValue) { Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); diff --git a/src/Humanizer/Configuration/FormatterRegistry.cs b/src/Humanizer/Configuration/FormatterRegistry.cs index 9970c6a21..0ea449d98 100644 --- a/src/Humanizer/Configuration/FormatterRegistry.cs +++ b/src/Humanizer/Configuration/FormatterRegistry.cs @@ -9,6 +9,7 @@ internal class FormatterRegistry : LocaliserRegistry public FormatterRegistry() : base(new DefaultFormatter("en-US")) { Register("ar", new ArabicFormatter()); + Register("de", new GermanFormatter()); Register("he", new HebrewFormatter()); Register("ro", new RomanianFormatter()); Register("ru", new RussianFormatter()); @@ -32,7 +33,6 @@ public FormatterRegistry() : base(new DefaultFormatter("en-US")) RegisterDefaultFormatter("af"); RegisterDefaultFormatter("az"); RegisterDefaultFormatter("da"); - RegisterDefaultFormatter("de"); RegisterDefaultFormatter("el"); RegisterDefaultFormatter("es"); RegisterDefaultFormatter("fa"); diff --git a/src/Humanizer/Localisation/Formatters/GermanFormatter.cs b/src/Humanizer/Localisation/Formatters/GermanFormatter.cs new file mode 100644 index 000000000..3e09e92ab --- /dev/null +++ b/src/Humanizer/Localisation/Formatters/GermanFormatter.cs @@ -0,0 +1,16 @@ +namespace Humanizer.Localisation.Formatters +{ + internal class GermanFormatter : DefaultFormatter + { + public GermanFormatter() + : base("de") + { + } + + /// + public override string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true) + { + return base.DataUnitHumanize(dataUnit, count, toSymbol)?.TrimEnd('s'); + } + } +}