Skip to content

Commit

Permalink
Merge pull request #762 from rubenmamo/features/Maltese
Browse files Browse the repository at this point in the history
Added support for the Maltese Language
  • Loading branch information
Oren Novotny authored Nov 22, 2018
2 parents 54166bb + 1a541ae commit fc0324b
Show file tree
Hide file tree
Showing 12 changed files with 1,490 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Currently Humanizer supports quite a few localisations for `DateTime.Humanize`,
Humanizer could definitely do with more translations.
To add a translation for `DateTime.Humanize` and `TimeSpan.Humanize`,
fork the repository if you haven't done yet, duplicate the [resources.resx](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer/Properties/Resources.resx) file, add your target [locale code](http://msdn.microsoft.com/en-us/library/hh441729.aspx)
to the end (e.g. resources.ru.resx for Russian), translate the values to your language, write unit tests for the translation, commit, and send a pull request for it. Thanks.
to the end (e.g. resources.ru.resx for Russian), translate the values to your language, register your formatter in [FormatterRegistry.cs](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer/Configuration/FormatterRegistry.cs), write unit tests for the translation, commit, and send a pull request for it. Thanks.

Some languages have complex rules when it comes to dealing with numbers; for example, in Romanian "5 days" is "5 zile", while "24 days" is "24 de zile" and in Arabic "2 days" is "يومان" not "2 يوم".
Obviously a normal resource file doesn't cut it in these cases as a more complex mapping is required.
Expand Down
24 changes: 24 additions & 0 deletions NuSpecs/Humanizer.Core.mt.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata minClientVersion="2.12">
<id>Humanizer.Core.mt</id>
<version>$version$</version>
<title>Humanizer Locale (mt)</title>
<authors>Mehdi Khalili, Oren Novotny</authors>
<projectUrl>https://github.com/Humanizr/Humanizer</projectUrl>
<iconUrl>https://raw.github.com/Humanizr/Humanizer/master/logo.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Humanizer Locale (mt)</description>
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
<licenseUrl>https://raw.githubusercontent.com/Humanizr/Humanizer/master/LICENSE</licenseUrl>
<repository type="$RepositoryType$" url="$RepositoryUrl$" commit="$RepositoryCommit$" />
<language>mt</language>
<dependencies>
<dependency id="Humanizer.Core" version="[$version$]" />
</dependencies>
</metadata>
<files>
<file src="Humanizer\bin\Release\netstandard1.0\mt\*.*" target="lib\netstandard1.0\mt" />
<file src="Humanizer\bin\Release\netstandard2.0\mt\*.*" target="lib\netstandard2.0\mt" />
</files>
</package>
3 changes: 3 additions & 0 deletions src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Localisation\it\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\ja\DateHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\ja\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\mt\DateHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\mt\NumberToWordsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\mt\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\nb-NO\DateHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\nb\DateHumanizeTests.cs" />
Expand Down
124 changes: 124 additions & 0 deletions src/Humanizer.Tests.Shared/Localisation/mt/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using Humanizer.Localisation;
using Xunit;

namespace Humanizer.Tests.Localisation.mt
{

[UseCulture("mt")]
public class DateHumanizeTests
{

[Theory]
[InlineData(-3, "3 jiem ilu")]
[InlineData(-2, "jumejn ilu")]
[InlineData(-1, "il-bieraħ")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(3, "3 jiem oħra")]
[InlineData(2, "pitgħada")]
[InlineData(1, "għada")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(-3, "3 siegħat ilu")]
[InlineData(-2, "sagħtejn ilu")]
[InlineData(-1, "siegħa ilu")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(3, "3 siegħat oħra")]
[InlineData(2, "sagħtejn oħra")]
[InlineData(1, "siegħa oħra")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(-3, "3 minuti ilu")]
[InlineData(-2, "2 minuti ilu")]
[InlineData(-1, "minuta ilu")]
[InlineData(60, "siegħa ilu")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(2, "2 minuti oħra")]
[InlineData(1, "minuta oħra")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(-3, "3 xhur ilu")]
[InlineData(-2, "xahrejn ilu")]
[InlineData(-1, "xahar ilu")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(3, "3 xhur oħra")]
[InlineData(2, "xahrejn oħra")]
[InlineData(1, "xahar ieħor")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(-2, "2 sekondi ilu")]
[InlineData(-1, "sekonda ilu")]
public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(2, "2 sekondi oħra")]
[InlineData(1, "sekonda oħra")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(-3, "3 snin ilu")]
[InlineData(-2, "sentejn ilu")]
[InlineData(-1, "sena ilu")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(3, "3 snin oħra")]
[InlineData(2, "sentejn oħra")]
[InlineData(1, "sena oħra")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

[Theory]
[InlineData(0, "issa")]
public void Now(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
}
}
Loading

0 comments on commit fc0324b

Please sign in to comment.