Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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));
}
18 changes: 18 additions & 0 deletions src/Humanizer.Tests/Localisation/pt-BR/TimeUnitToSymbolTests.cs
Original file line number Diff line number Diff line change
@@ -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());
}
Original file line number Diff line number Diff line change
@@ -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));
}
18 changes: 18 additions & 0 deletions src/Humanizer.Tests/Localisation/pt/TimeUnitToSymbolTests.cs
Original file line number Diff line number Diff line change
@@ -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());
}
80 changes: 80 additions & 0 deletions src/Humanizer/Properties/Resources.pt-BR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,54 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="DataUnit_Bit" xml:space="preserve">
<value>bit</value>
<comment>Unidade de dados: bit</comment>
</data>
<data name="DataUnit_BitSymbol" xml:space="preserve">
<value>bit</value>
<comment>Símbolo da unidade de dados: bit</comment>
</data>
<data name="DataUnit_Byte" xml:space="preserve">
<value>byte</value>
<comment>Unidade de dados: byte</comment>
</data>
<data name="DataUnit_ByteSymbol" xml:space="preserve">
<value>B</value>
<comment>Símbolo da unidade de dados: byte</comment>
</data>
<data name="DataUnit_Gigabyte" xml:space="preserve">
<value>gigabyte</value>
<comment>Unidade de dados: gigabyte</comment>
</data>
<data name="DataUnit_GigabyteSymbol" xml:space="preserve">
<value>GB</value>
<comment>Símbolo da unidade de dados: gigabyte</comment>
</data>
<data name="DataUnit_Kilobyte" xml:space="preserve">
<value>kilobyte</value>
<comment>Unidade de dados: kilobyte</comment>
</data>
<data name="DataUnit_KilobyteSymbol" xml:space="preserve">
<value>KB</value>
<comment>Símbolo da unidade de dados: kilobyte</comment>
</data>
<data name="DataUnit_Megabyte" xml:space="preserve">
<value>megabyte</value>
<comment>Unidade de dados: megabyte</comment>
</data>
<data name="DataUnit_MegabyteSymbol" xml:space="preserve">
<value>MB</value>
<comment>Símbolo da unidade de dados: megabyte</comment>
</data>
<data name="DataUnit_Terabyte" xml:space="preserve">
<value>terabyte</value>
<comment>Unidade de dados: terabyte</comment>
</data>
<data name="DataUnit_TerabyteSymbol" xml:space="preserve">
<value>TB</value>
<comment>Símbolo da unidade de dados: terabyte</comment>
</data>
<data name="DateHumanize_MultipleDaysAgo" xml:space="preserve">
<value>{0} dias atrás</value>
</data>
Expand Down Expand Up @@ -582,6 +630,38 @@
<data name="TimeSpanHumanize_Zero" xml:space="preserve">
<value>sem horário</value>
</data>
<data name="TimeUnit_Day" xml:space="preserve">
<value>d</value>
<comment>Unidade de tempo: dia</comment>
</data>
<data name="TimeUnit_Hour" xml:space="preserve">
<value>h</value>
<comment>Unidade de tempo: hora</comment>
</data>
<data name="TimeUnit_Millisecond" xml:space="preserve">
<value>ms</value>
<comment>Unidade de tempo: milisegundo</comment>
</data>
<data name="TimeUnit_Minute" xml:space="preserve">
<value>min</value>
<comment>Unidade de tempo: minuto</comment>
</data>
<data name="TimeUnit_Month" xml:space="preserve">
<value>m</value>
<comment>Unidade de tempo: mês</comment>
</data>
<data name="TimeUnit_Second" xml:space="preserve">
<value>s</value>
<comment>Unidade de tempo: segundo</comment>
</data>
<data name="TimeUnit_Week" xml:space="preserve">
<value>semana</value>
<comment>Unidade de tempo: semana</comment>
</data>
<data name="TimeUnit_Year" xml:space="preserve">
<value>a</value>
<comment>Unidade de tempo: ano</comment>
</data>
<data name="W" xml:space="preserve">
<value>oeste</value>
</data>
Expand Down
80 changes: 80 additions & 0 deletions src/Humanizer/Properties/Resources.pt.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,54 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="DataUnit_Bit" xml:space="preserve">
<value>bit</value>
<comment>Unidade de dados: bit</comment>
</data>
<data name="DataUnit_BitSymbol" xml:space="preserve">
<value>bit</value>
<comment>Símbolo da unidade de dados: bit</comment>
</data>
<data name="DataUnit_Byte" xml:space="preserve">
<value>byte</value>
<comment>Unidade de dados: byte</comment>
</data>
<data name="DataUnit_ByteSymbol" xml:space="preserve">
<value>B</value>
<comment>Símbolo da unidade de dados: byte</comment>
</data>
<data name="DataUnit_Gigabyte" xml:space="preserve">
<value>gigabyte</value>
<comment>Unidade de dados: gigabyte</comment>
</data>
<data name="DataUnit_GigabyteSymbol" xml:space="preserve">
<value>GB</value>
<comment>Símbolo da unidade de dados: gigabyte</comment>
</data>
<data name="DataUnit_Kilobyte" xml:space="preserve">
<value>kilobyte</value>
<comment>Unidade de dados: kilobyte</comment>
</data>
<data name="DataUnit_KilobyteSymbol" xml:space="preserve">
<value>KB</value>
<comment>Símbolo da unidade de dados: kilobyte</comment>
</data>
<data name="DataUnit_Megabyte" xml:space="preserve">
<value>megabyte</value>
<comment>Unidade de dados: megabyte</comment>
</data>
<data name="DataUnit_MegabyteSymbol" xml:space="preserve">
<value>MB</value>
<comment>Símbolo da unidade de dados: megabyte</comment>
</data>
<data name="DataUnit_Terabyte" xml:space="preserve">
<value>terabyte</value>
<comment>Unidade de dados: terabyte</comment>
</data>
<data name="DataUnit_TerabyteSymbol" xml:space="preserve">
<value>TB</value>
<comment>Símbolo da unidade de dados: terabyte</comment>
</data>
<data name="DateHumanize_MultipleDaysAgo" xml:space="preserve">
<value>há {0} dias</value>
</data>
Expand Down Expand Up @@ -582,6 +630,38 @@
<data name="TimeSpanHumanize_Zero" xml:space="preserve">
<value>sem horário</value>
</data>
<data name="TimeUnit_Day" xml:space="preserve">
<value>d</value>
<comment>Unidade de tempo: dia</comment>
</data>
<data name="TimeUnit_Hour" xml:space="preserve">
<value>h</value>
<comment>Unidade de tempo: hora</comment>
</data>
<data name="TimeUnit_Millisecond" xml:space="preserve">
<value>ms</value>
<comment>Unidade de tempo: milisegundo</comment>
</data>
<data name="TimeUnit_Minute" xml:space="preserve">
<value>min</value>
<comment>Unidade de tempo: minuto</comment>
</data>
<data name="TimeUnit_Month" xml:space="preserve">
<value>m</value>
<comment>Unidade de tempo: mês</comment>
</data>
<data name="TimeUnit_Second" xml:space="preserve">
<value>s</value>
<comment>Unidade de tempo: segundo</comment>
</data>
<data name="TimeUnit_Week" xml:space="preserve">
<value>semana</value>
<comment>Unidade de tempo: semana</comment>
</data>
<data name="TimeUnit_Year" xml:space="preserve">
<value>a</value>
<comment>Unidade de tempo: ano</comment>
</data>
<data name="W" xml:space="preserve">
<value>oeste</value>
</data>
Expand Down
Loading