-
Notifications
You must be signed in to change notification settings - Fork 965
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,362 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.lt</id> | ||
<version>$version$</version> | ||
<title>Humanizer Locale (lt)</title> | ||
<authors>Mehdi Khalili, Claire Novotny</authors> | ||
<projectUrl>https://github.com/Humanizr/Humanizer</projectUrl> | ||
<icon>logo.png</icon> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>Humanizer Locale Lithuanian (lt)</description> | ||
<copyright>Copyright (c) .NET Foundation and Contributors</copyright> | ||
<license type="expression">MIT</license> | ||
<repository type="$RepositoryType$" url="$RepositoryUrl$" commit="$RepositoryCommit$" /> | ||
<language>lv</language> | ||
This comment has been minimized.
Sorry, something went wrong. |
||
<dependencies> | ||
<dependency id="Humanizer.Core" version="[$version$]" /> | ||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="Humanizer\bin\Release\netstandard1.0\lt\*.*" target="lib\netstandard1.0\lt" /> | ||
<file src="Humanizer\bin\Release\netstandard2.0\lt\*.*" target="lib\netstandard2.0\lt" /> | ||
<file src="Humanizer\bin\Release\net6.0\lt\*.*" target="lib\net6.0\lt" /> | ||
<file src="..\logo.png" target="logo.png" /> | ||
</files> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Humanizer.Tests.Shared/Localisation/lt/DateToOrdinalWordsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace Humanizer.Tests.Localisation.lt | ||
{ | ||
[UseCulture("lt")] | ||
public class DateToOrdinalWordsTests | ||
{ | ||
[Fact] | ||
public void OrdinalizeString() | ||
{ | ||
Assert.Equal("2015 m. sausio 1 d.", new DateTime(2015, 1, 1).ToOrdinalWords()); | ||
} | ||
|
||
#if NET6_0_OR_GREATER | ||
[Fact] | ||
public void OrdinalizeDateOnlyString() | ||
{ | ||
Assert.Equal("2015 m. sausio 1 d.", new DateOnly(2015, 1, 1).ToOrdinalWords()); | ||
} | ||
#endif | ||
} | ||
} |
556 changes: 556 additions & 0 deletions
556
src/Humanizer.Tests.Shared/Localisation/lt/NumberToWordsTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
src/Humanizer.Tests.Shared/Localisation/lt/TimeSpanHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using System; | ||
using Humanizer.Localisation; | ||
using Xunit; | ||
|
||
namespace Humanizer.Tests.Localisation.lt | ||
{ | ||
[UseCulture("lt")] | ||
public class TimeSpanHumanizeTests | ||
{ | ||
[Theory] | ||
[Trait("Translation", "Native speaker")] | ||
[InlineData(366, "1 metai")] | ||
[InlineData(731, "2 metai")] | ||
[InlineData(1096, "3 metai")] | ||
[InlineData(4018, "11 metų")] | ||
public void Years(int days, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); | ||
} | ||
|
||
[Theory] | ||
[Trait("Translation", "Native speaker")] | ||
[InlineData(31, "1 mėnuo")] | ||
[InlineData(61, "2 mėnesiai")] | ||
[InlineData(280, "9 mėnesiai")] | ||
[InlineData(330, "10 mėnesių")] | ||
public void Months(int days, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); | ||
} | ||
|
||
[Theory] | ||
[InlineData(7, "1 savaitė")] | ||
[InlineData(14, "2 savaitės")] | ||
[InlineData(21, "3 savaitės")] | ||
[InlineData(77, "11 savaičių")] | ||
[InlineData(147, "21 savaitė")] | ||
public void Weeks(int days, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "1 diena")] | ||
[InlineData(2, "2 dienos")] | ||
[InlineData(9, "9 dienos")] | ||
[InlineData(10, "10 dienų")] | ||
[InlineData(17, "17 dienų")] | ||
[InlineData(21, "21 diena")] | ||
public void Days(int days, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Day)); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "1 valanda")] | ||
[InlineData(2, "2 valandos")] | ||
[InlineData(3, "3 valandos")] | ||
[InlineData(9, "9 valandos")] | ||
[InlineData(10, "10 valandų")] | ||
[InlineData(19, "19 valandų")] | ||
[InlineData(21, "21 valanda")] | ||
public void Hours(int hours, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "1 minutė")] | ||
[InlineData(2, "2 minutės")] | ||
[InlineData(3, "3 minutės")] | ||
[InlineData(9, "9 minutės")] | ||
[InlineData(10, "10 minučių")] | ||
[InlineData(19, "19 minučių")] | ||
[InlineData(21, "21 minutė")] | ||
public void Minutes(int minutes, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "1 sekundė")] | ||
[InlineData(2, "2 sekundės")] | ||
[InlineData(3, "3 sekundės")] | ||
[InlineData(9, "9 sekundės")] | ||
[InlineData(10, "10 sekundžių")] | ||
[InlineData(19, "19 sekundžių")] | ||
[InlineData(21, "21 sekundė")] | ||
public void Seconds(int seconds, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "1 milisekundė")] | ||
[InlineData(2, "2 milisekundės")] | ||
[InlineData(3, "3 milisekundės")] | ||
[InlineData(9, "9 milisekundės")] | ||
[InlineData(10, "10 milisekundžių")] | ||
[InlineData(19, "19 milisekundžių")] | ||
[InlineData(21, "21 milisekundė")] | ||
public void Milliseconds(int milliseconds, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void NoTime() | ||
{ | ||
Assert.Equal("0 milisekundžių", TimeSpan.Zero.Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void NoTimeToWords() | ||
{ | ||
Assert.Equal("nėra laiko", TimeSpan.Zero.Humanize(toWords: true)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Humanizer/Localisation/DateToOrdinalWords/LtDateOnlyToOrdinalWordsConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#if NET6_0_OR_GREATER | ||
using System; | ||
|
||
namespace Humanizer.Localisation.DateToOrdinalWords | ||
{ | ||
internal class LtDateOnlyToOrdinalWordsConverter : IDateOnlyToOrdinalWordConverter | ||
{ | ||
public string Convert(DateOnly date) | ||
{ | ||
return date.ToString("yyyy 'm.' MMMM d 'd.'"); | ||
} | ||
|
||
public string Convert(DateOnly date, GrammaticalCase grammaticalCase) | ||
{ | ||
return Convert(date); | ||
} | ||
} | ||
} | ||
#endif |
17 changes: 17 additions & 0 deletions
17
src/Humanizer/Localisation/DateToOrdinalWords/LtDateToOrdinalWordsConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace Humanizer.Localisation.DateToOrdinalWords | ||
{ | ||
internal class LtDateToOrdinalWordsConverter : IDateToOrdinalWordConverter | ||
{ | ||
public string Convert(DateTime date) | ||
{ | ||
return date.ToString("yyyy 'm.' MMMM d 'd.'"); | ||
} | ||
|
||
public string Convert(DateTime date, GrammaticalCase grammaticalCase) | ||
{ | ||
return Convert(date); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Humanizer/Localisation/Formatters/LithuanianFormatter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Humanizer.Localisation.GrammaticalNumber; | ||
|
||
namespace Humanizer.Localisation.Formatters | ||
{ | ||
internal class LithuanianFormatter : DefaultFormatter | ||
{ | ||
public LithuanianFormatter() | ||
: base("lt") | ||
{ | ||
} | ||
|
||
protected override string GetResourceKey(string resourceKey, int number) | ||
{ | ||
if (resourceKey == "TimeSpanHumanize_Zero") | ||
{ | ||
return resourceKey; | ||
} | ||
|
||
var grammaticalNumber = LithuanianNumberFormDetector.Detect(number); | ||
var suffix = GetSuffix(grammaticalNumber); | ||
return resourceKey + suffix; | ||
} | ||
|
||
private static string GetSuffix(LithuanianNumberForm form) | ||
{ | ||
if (form == LithuanianNumberForm.Singular) | ||
{ | ||
return "_Singular"; | ||
} | ||
|
||
if (form == LithuanianNumberForm.GenitivePlural) | ||
{ | ||
return "_Plural"; | ||
} | ||
|
||
return ""; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberForm.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Humanizer.Localisation.GrammaticalNumber | ||
{ | ||
internal enum LithuanianNumberForm | ||
{ | ||
Singular, | ||
Plural, | ||
GenitivePlural | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberFormDetector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Humanizer.Localisation.GrammaticalNumber | ||
{ | ||
internal static class LithuanianNumberFormDetector | ||
{ | ||
public static LithuanianNumberForm Detect(long number) | ||
{ | ||
var tens = number % 100 / 10; | ||
var units = number % 10; | ||
|
||
if (tens == 1 || units == 0) // 10-19, 20, 30, 40 ... 100, 110 .. | ||
{ | ||
return LithuanianNumberForm.GenitivePlural; | ||
} | ||
|
||
if (units == 1) // 1, 21, 31, 41 ... 91, 101, 121 ... | ||
{ | ||
return LithuanianNumberForm.Singular; | ||
} | ||
|
||
// 2-9, 22-29, 32 ... | ||
return LithuanianNumberForm.Plural; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Shouldn't this be
lt
rather thanlv
?