Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Luxembourgish localisation #1256

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
26 changes: 26 additions & 0 deletions NuSpecs/Humanizer.Core.lb.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata minClientVersion="2.12">
<id>Humanizer.Core.lb</id>
<version>$version$</version>
<title>Humanizer Locale (lb)</title>
<authors>Mehdi Khalili, Claire Novotny</authors>
<projectUrl>https://github.com/Humanizr/Humanizer</projectUrl>
<icon>logo.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Humanizer Locale Luxembourgish (lb)</description>
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
<license type="expression">MIT</license>
<repository type="$RepositoryType$" url="$RepositoryUrl$" commit="$RepositoryCommit$" />
<language>lb</language>
<dependencies>
<dependency id="Humanizer.Core" version="[$version$]" />
</dependencies>
</metadata>
<files>
<file src="Humanizer\bin\Release\netstandard1.0\lb\*.*" target="lib\netstandard1.0\lb" />
<file src="Humanizer\bin\Release\netstandard2.0\lb\*.*" target="lib\netstandard2.0\lb" />
<file src="Humanizer\bin\Release\net6.0\lb\*.*" target="lib\net6.0\lb" />
<file src="..\logo.png" target="logo.png" />
</files>
</package>
1 change: 1 addition & 0 deletions NuSpecs/Humanizer.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<dependency id="Humanizer.Core.ja" version="$version$" />
<dependency id="Humanizer.Core.ko-KR" version="$version$" />
<dependency id="Humanizer.Core.ku" version="$version$" />
<dependency id="Humanizer.Core.lb" version="$version$" />
<dependency id="Humanizer.Core.lv" version="$version$" />
<dependency id="Humanizer.Core.ms-MY" version="$version$" />
<dependency id="Humanizer.Core.mt" version="$version$" />
Expand Down
1 change: 1 addition & 0 deletions src/Humanizer.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuSpecs", "NuSpecs", "{AA44
..\NuSpecs\Humanizer.Core.id.nuspec = ..\NuSpecs\Humanizer.Core.id.nuspec
..\NuSpecs\Humanizer.Core.it.nuspec = ..\NuSpecs\Humanizer.Core.it.nuspec
..\NuSpecs\Humanizer.Core.ja.nuspec = ..\NuSpecs\Humanizer.Core.ja.nuspec
..\NuSpecs\Humanizer.Core.lb.nuspec = ..\NuSpecs\Humanizer.Core.lb.nuspec
..\NuSpecs\Humanizer.Core.lv.nuspec = ..\NuSpecs\Humanizer.Core.lv.nuspec
..\NuSpecs\Humanizer.Core.nb-NO.nuspec = ..\NuSpecs\Humanizer.Core.nb-NO.nuspec
..\NuSpecs\Humanizer.Core.nb.nuspec = ..\NuSpecs\Humanizer.Core.nb.nuspec
Expand Down
12 changes: 12 additions & 0 deletions src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
<Compile Include="$(MSBuildThisFileDirectory)Localisation\is\ResourcesTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\is\TimeOnlyHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\is\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\Bytes\ByteRateTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\Bytes\ByteSizeExtensionsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\Bytes\ToFullWordsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\Bytes\ToStringTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\DateHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\TimeOnlyHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\OrdinalizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\DateToOrdinalWordsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\CollectionFormatterTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\NumberToWordsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\lb\TimeToClockNotationTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\pt-BR\TimeToClockNotationTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TimeOnlyHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DateTimeHumanizePrecisionStrategyTests.cs" />
Expand Down
79 changes: 79 additions & 0 deletions src/Humanizer.Tests.Shared/Localisation/lb/Bytes/ByteRateTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;

using Humanizer.Bytes;
using Humanizer.Localisation;

using Xunit;

namespace Humanizer.Tests.Localisation.lb.Bytes;

[UseCulture("lb-LU")]
public class ByteRateTests
{
[Theory]
[InlineData(400, 1, "400 B/s")]
[InlineData(4 * 1024, 1, "4 KB/s")]
[InlineData(4 * 1024 * 1024, 1, "4 MB/s")]
[InlineData(4 * 2 * 1024 * 1024, 2, "4 MB/s")]
[InlineData(4 * 1024, 0.1, "40 KB/s")]
[InlineData(15 * 60 * 1024 * 1024, 60, "15 MB/s")]
public void HumanizesRates(long inputBytes, double perSeconds, string expectedValue)
{
var size = new ByteSize(inputBytes);
var interval = TimeSpan.FromSeconds(perSeconds);

var rate = size.Per(interval).Humanize();

Assert.Equal(expectedValue, rate);
}

[Theory]
[InlineData(1, 1, TimeUnit.Second, "1 MB/s")]
[InlineData(1, 60, TimeUnit.Minute, "1 MB/min")]
[InlineData(1, 60 * 60, TimeUnit.Hour, "1 MB/h")]
[InlineData(10, 1, TimeUnit.Second, "10 MB/s")]
[InlineData(10, 60, TimeUnit.Minute, "10 MB/min")]
[InlineData(10, 60 * 60, TimeUnit.Hour, "10 MB/h")]
[InlineData(1, 10 * 1, TimeUnit.Second, "102,4 KB/s")]
[InlineData(1, 10 * 60, TimeUnit.Minute, "102,4 KB/min")]
[InlineData(1, 10 * 60 * 60, TimeUnit.Hour, "102,4 KB/h")]
public void TimeUnitTests(long megabytes, double measurementIntervalSeconds, TimeUnit displayInterval, string expectedValue)
{
var size = ByteSize.FromMegabytes(megabytes);
var measurementInterval = TimeSpan.FromSeconds(measurementIntervalSeconds);

var rate = size.Per(measurementInterval);
var text = rate.Humanize(displayInterval);

Assert.Equal(expectedValue, text);
}

[Theory]
[InlineData(19854651984, 1, TimeUnit.Second, null, "18,49 GB/s")]
[InlineData(19854651984, 1, TimeUnit.Second, "#.##", "18,49 GB/s")]
public void FormattedTimeUnitTests(long bytes, int measurementIntervalSeconds, TimeUnit displayInterval, string format, string expectedValue)
{
var size = ByteSize.FromBytes(bytes);
var measurementInterval = TimeSpan.FromSeconds(measurementIntervalSeconds);
var rate = size.Per(measurementInterval);
var text = rate.Humanize(format, displayInterval);

Assert.Equal(expectedValue, text);
}

[Theory]
[InlineData(TimeUnit.Millisecond)]
[InlineData(TimeUnit.Day)]
[InlineData(TimeUnit.Month)]
[InlineData(TimeUnit.Week)]
[InlineData(TimeUnit.Year)]
public void ThrowsOnUnsupportedData(TimeUnit units)
{
var dummyRate = ByteSize.FromBits(1).Per(TimeSpan.FromSeconds(1));

Assert.Throws<NotSupportedException>(() =>
{
dummyRate.Humanize(units);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Xunit;

namespace Humanizer.Tests.Localisation.lb.Bytes;

[UseCulture("lb-LU")]
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));
}

#if NET6_0_OR_GREATER // the lb/lb-LU locales apparently don't have the correct group separator pre .NET 6
[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)
{
Assert.Equal(expectedValue, input.Bytes().Humanize(format));
}
#endif

[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));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using Humanizer.Bytes;

using Xunit;

namespace Humanizer.Tests.Localisation.lb.Bytes;

[UseCulture("lb-LU")]
public class ToFullWordsTests
{
[Fact]
public void ReturnsSingularBit()
{
Assert.Equal("1 Bit", ByteSize.FromBits(1).ToFullWords());
}

[Fact]
public void ReturnsPluralBits()
{
Assert.Equal("2 Bit", ByteSize.FromBits(2).ToFullWords());
}

[Fact]
public void ReturnsSingularByte()
{
Assert.Equal("1 Byte", ByteSize.FromBytes(1).ToFullWords());
}

[Fact]
public void ReturnsPluralBytes()
{
Assert.Equal("10 Byte", ByteSize.FromBytes(10).ToFullWords());
}

[Fact]
public void ReturnsSingularKiloByte()
{
Assert.Equal("1 Kilobyte", ByteSize.FromKilobytes(1).ToFullWords());
}

[Fact]
public void ReturnsPluralKilobytes()
{
Assert.Equal("10 Kilobyte", ByteSize.FromKilobytes(10).ToFullWords());
}

[Fact]
public void ReturnsSingularMegabyte()
{
Assert.Equal("1 Megabyte", ByteSize.FromMegabytes(1).ToFullWords());
}

[Fact]
public void ReturnsPluralMegabytes()
{
Assert.Equal("10 Megabyte", ByteSize.FromMegabytes(10).ToFullWords());
}

[Fact]
public void ReturnsSingularGigabyte()
{
Assert.Equal("1 Gigabyte", ByteSize.FromGigabytes(1).ToFullWords());
}

[Fact]
public void ReturnsPluralGigabytes()
{
Assert.Equal("10 Gigabyte", ByteSize.FromGigabytes(10).ToFullWords());
}

[Fact]
public void ReturnsSingularTerabyte()
{
Assert.Equal("1 Terabyte", ByteSize.FromTerabytes(1).ToFullWords());
}

[Fact]
public void ReturnsPluralTerabytes()
{
Assert.Equal("10 Terabyte", ByteSize.FromTerabytes(10).ToFullWords());
}

[Theory]
[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));
}
}
87 changes: 87 additions & 0 deletions src/Humanizer.Tests.Shared/Localisation/lb/Bytes/ToStringTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using Humanizer.Bytes;

using Xunit;

namespace Humanizer.Tests.Localisation.lb.Bytes;

[UseCulture("lb-LU")]
public class ToStringTests
{
[Fact]
public void ReturnsLargestMetricSuffix()
{
Assert.Equal("10,5 KB", ByteSize.FromKilobytes(10.5).ToString());
}

[Fact]
public void ReturnsDefaultNumberFormat()
{
Assert.Equal("10,5 KB", ByteSize.FromKilobytes(10.5).ToString("KB"));
}

[Fact]
public void ReturnsProvidedNumberFormat()
{
Assert.Equal("10,1234 KB", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB"));
}

[Fact]
public void ReturnsBits()
{
Assert.Equal("10 bit", ByteSize.FromBits(10).ToString("##.#### b"));
}

[Fact]
public void ReturnsBytes()
{
Assert.Equal("10 B", ByteSize.FromBytes(10).ToString("##.#### B"));
}

[Fact]
public void ReturnsKilobytes()
{
Assert.Equal("10 KB", ByteSize.FromKilobytes(10).ToString("##.#### KB"));
}

[Fact]
public void ReturnsMegabytes()
{
Assert.Equal("10 MB", ByteSize.FromMegabytes(10).ToString("##.#### MB"));
}

[Fact]
public void ReturnsGigabytes()
{
Assert.Equal("10 GB", ByteSize.FromGigabytes(10).ToString("##.#### GB"));
}

[Fact]
public void ReturnsTerabytes()
{
Assert.Equal("10 TB", ByteSize.FromTerabytes(10).ToString("##.#### TB"));
}

[Fact]
public void ReturnsSelectedFormat()
{
Assert.Equal("10,0 TB", ByteSize.FromTerabytes(10).ToString("0.0 TB"));
}

[Fact]
public void ReturnsLargestMetricPrefixLargerThanZero()
{
Assert.Equal("512 KB", ByteSize.FromMegabytes(.5).ToString("#.#"));
}

[Fact]
public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues()
{
Assert.Equal("-512 KB", ByteSize.FromMegabytes(-.5).ToString("#.#"));
}

[Fact]
public void ReturnsBytesViaGeneralFormat()
{
Assert.Equal("10 B", $"{ByteSize.FromBytes(10)}");
}
}
Loading