diff --git a/src/Humanizer.Tests/Localisation/pt-BR/Bytes/ByteSizeExtensionsTests.cs b/src/Humanizer.Tests/Localisation/pt-BR/Bytes/ByteSizeExtensionsTests.cs new file mode 100644 index 000000000..815c9e527 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/pt-BR/Bytes/ByteSizeExtensionsTests.cs @@ -0,0 +1,69 @@ +namespace pt_BR.Bytes; + +[UseCulture("pt-BR")] +public class ByteSizeExtensionsTests +{ + [Theory] + [InlineData(2, null, "2 TB")] + [InlineData(2, "GB", "2048 GB")] + [InlineData(2.123, "#.#", "2,1 TB")] + public void HumanizesTerabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Terabytes().Humanize(format)); + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "GB", "0 GB")] + [InlineData(2, null, "2 GB")] + [InlineData(2, "MB", "2048 MB")] + [InlineData(2.123, "#.##", "2,12 GB")] + public void HumanizesGigabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Gigabytes().Humanize(format)); + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "MB", "0 MB")] + [InlineData(2, null, "2 MB")] + [InlineData(2, "KB", "2048 KB")] + [InlineData(2.123, "#", "2 MB")] + public void HumanizesMegabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Megabytes().Humanize(format)); + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "KB", "0 KB")] + [InlineData(2, null, "2 KB")] + [InlineData(2, "B", "2048 B")] + [InlineData(2.123, "#.####", "2,123 KB")] + public void HumanizesKilobytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Kilobytes().Humanize(format)); + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "#.##", "0 bit")] + [InlineData(0, "#.## B", "0 B")] + [InlineData(0, "B", "0 B")] + [InlineData(2, null, "2 B")] + [InlineData(2000, "KB", "1,95 KB")] + [InlineData(2123, "#.##", "2,07 KB")] + [InlineData(10000000, "KB", "9765,63 KB")] + [InlineData(10000000, "#,##0 KB", "9.766 KB")] + [InlineData(10000000, "#,##0.# KB", "9.765,6 KB")] + public void HumanizesBytes(double input, string? format, string expectedValue) + { + expectedValue = expectedValue.Replace(".", NumberFormatInfo.CurrentInfo.NumberGroupSeparator); + Assert.Equal( + expectedValue, + input + .Bytes() + .Humanize(format)); + } + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "b", "0 bit")] + [InlineData(2, null, "2 bit")] + [InlineData(12, "B", "1,5 B")] + [InlineData(10000, "#.# KB", "1,2 KB")] + public void HumanizesBits(long input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Bits().Humanize(format)); +} diff --git a/src/Humanizer.Tests/Localisation/pt-BR/TimeUnitToSymbolTests.cs b/src/Humanizer.Tests/Localisation/pt-BR/TimeUnitToSymbolTests.cs new file mode 100644 index 000000000..afe8ed7f4 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/pt-BR/TimeUnitToSymbolTests.cs @@ -0,0 +1,18 @@ +namespace pt_BR; + +[UseCulture("pt-BR")] +public class TimeUnitToSymbolTests +{ + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(TimeUnit.Millisecond, "ms")] + [InlineData(TimeUnit.Second, "s")] + [InlineData(TimeUnit.Minute, "min")] + [InlineData(TimeUnit.Hour, "h")] + [InlineData(TimeUnit.Day, "d")] + [InlineData(TimeUnit.Week, "semana")] + [InlineData(TimeUnit.Month, "m")] + [InlineData(TimeUnit.Year, "a")] + public void ToSymbol(TimeUnit unit, string expected) => + Assert.Equal(expected, unit.ToSymbol()); +} diff --git a/src/Humanizer.Tests/Localisation/pt/Bytes/ByteSizeExtensionsTests.cs b/src/Humanizer.Tests/Localisation/pt/Bytes/ByteSizeExtensionsTests.cs new file mode 100644 index 000000000..9fce42792 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/pt/Bytes/ByteSizeExtensionsTests.cs @@ -0,0 +1,69 @@ +namespace pt.Bytes; + +[UseCulture("pt")] +public class ByteSizeExtensionsTests +{ + [Theory] + [InlineData(2, null, "2 TB")] + [InlineData(2, "GB", "2048 GB")] + [InlineData(2.123, "#.#", "2,1 TB")] + public void HumanizesTerabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Terabytes().Humanize(format)); + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "GB", "0 GB")] + [InlineData(2, null, "2 GB")] + [InlineData(2, "MB", "2048 MB")] + [InlineData(2.123, "#.##", "2,12 GB")] + public void HumanizesGigabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Gigabytes().Humanize(format)); + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "MB", "0 MB")] + [InlineData(2, null, "2 MB")] + [InlineData(2, "KB", "2048 KB")] + [InlineData(2.123, "#", "2 MB")] + public void HumanizesMegabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Megabytes().Humanize(format)); + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "KB", "0 KB")] + [InlineData(2, null, "2 KB")] + [InlineData(2, "B", "2048 B")] + [InlineData(2.123, "#.####", "2,123 KB")] + public void HumanizesKilobytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Kilobytes().Humanize(format)); + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "#.##", "0 bit")] + [InlineData(0, "#.## B", "0 B")] + [InlineData(0, "B", "0 B")] + [InlineData(2, null, "2 B")] + [InlineData(2000, "KB", "1,95 KB")] + [InlineData(2123, "#.##", "2,07 KB")] + [InlineData(10000000, "KB", "9765,63 KB")] + [InlineData(10000000, "#,##0 KB", "9.766 KB")] + [InlineData(10000000, "#,##0.# KB", "9.765,6 KB")] + public void HumanizesBytes(double input, string? format, string expectedValue) + { + expectedValue = expectedValue.Replace(".", NumberFormatInfo.CurrentInfo.NumberGroupSeparator); + Assert.Equal( + expectedValue, + input + .Bytes() + .Humanize(format)); + } + + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "b", "0 bit")] + [InlineData(2, null, "2 bit")] + [InlineData(12, "B", "1,5 B")] + [InlineData(10000, "#.# KB", "1,2 KB")] + public void HumanizesBits(long input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Bits().Humanize(format)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pt/TimeUnitToSymbolTests.cs b/src/Humanizer.Tests/Localisation/pt/TimeUnitToSymbolTests.cs new file mode 100644 index 000000000..557c96f33 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/pt/TimeUnitToSymbolTests.cs @@ -0,0 +1,18 @@ +namespace pt; + +[UseCulture("pt")] +public class TimeUnitToSymbolTests +{ + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(TimeUnit.Millisecond, "ms")] + [InlineData(TimeUnit.Second, "s")] + [InlineData(TimeUnit.Minute, "min")] + [InlineData(TimeUnit.Hour, "h")] + [InlineData(TimeUnit.Day, "d")] + [InlineData(TimeUnit.Week, "semana")] + [InlineData(TimeUnit.Month, "m")] + [InlineData(TimeUnit.Year, "a")] + public void ToSymbol(TimeUnit unit, string expected) => + Assert.Equal(expected, unit.ToSymbol()); +} \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.pt-BR.resx b/src/Humanizer/Properties/Resources.pt-BR.resx index 3435af70a..89add7dd6 100644 --- a/src/Humanizer/Properties/Resources.pt-BR.resx +++ b/src/Humanizer/Properties/Resources.pt-BR.resx @@ -117,6 +117,54 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + bit + Unidade de dados: bit + + + bit + Símbolo da unidade de dados: bit + + + byte + Unidade de dados: byte + + + B + Símbolo da unidade de dados: byte + + + gigabyte + Unidade de dados: gigabyte + + + GB + Símbolo da unidade de dados: gigabyte + + + kilobyte + Unidade de dados: kilobyte + + + KB + Símbolo da unidade de dados: kilobyte + + + megabyte + Unidade de dados: megabyte + + + MB + Símbolo da unidade de dados: megabyte + + + terabyte + Unidade de dados: terabyte + + + TB + Símbolo da unidade de dados: terabyte + {0} dias atrás @@ -582,6 +630,38 @@ sem horário + + d + Unidade de tempo: dia + + + h + Unidade de tempo: hora + + + ms + Unidade de tempo: milisegundo + + + min + Unidade de tempo: minuto + + + m + Unidade de tempo: mês + + + s + Unidade de tempo: segundo + + + semana + Unidade de tempo: semana + + + a + Unidade de tempo: ano + oeste diff --git a/src/Humanizer/Properties/Resources.pt.resx b/src/Humanizer/Properties/Resources.pt.resx index a08424910..c264d3633 100644 --- a/src/Humanizer/Properties/Resources.pt.resx +++ b/src/Humanizer/Properties/Resources.pt.resx @@ -117,6 +117,54 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + bit + Unidade de dados: bit + + + bit + Símbolo da unidade de dados: bit + + + byte + Unidade de dados: byte + + + B + Símbolo da unidade de dados: byte + + + gigabyte + Unidade de dados: gigabyte + + + GB + Símbolo da unidade de dados: gigabyte + + + kilobyte + Unidade de dados: kilobyte + + + KB + Símbolo da unidade de dados: kilobyte + + + megabyte + Unidade de dados: megabyte + + + MB + Símbolo da unidade de dados: megabyte + + + terabyte + Unidade de dados: terabyte + + + TB + Símbolo da unidade de dados: terabyte + há {0} dias @@ -582,6 +630,38 @@ sem horário + + d + Unidade de tempo: dia + + + h + Unidade de tempo: hora + + + ms + Unidade de tempo: milisegundo + + + min + Unidade de tempo: minuto + + + m + Unidade de tempo: mês + + + s + Unidade de tempo: segundo + + + semana + Unidade de tempo: semana + + + a + Unidade de tempo: ano + oeste