diff --git a/src/Humanizer.Tests.Shared/OrdinalizeTests.cs b/src/Humanizer.Tests.Shared/OrdinalizeTests.cs
index 99638bf9d..fa5abc136 100644
--- a/src/Humanizer.Tests.Shared/OrdinalizeTests.cs
+++ b/src/Humanizer.Tests.Shared/OrdinalizeTests.cs
@@ -1,4 +1,5 @@
-using Xunit;
+using System.Globalization;
+using Xunit;
namespace Humanizer.Tests
{
@@ -95,5 +96,13 @@ public void OrdinalizeStringGenderIsImmaterial(string number)
var feminineOrdinalized = number.Ordinalize(GrammaticalGender.Feminine);
Assert.Equal(masculineOrdinalized, feminineOrdinalized);
}
+
+ [Theory]
+ [InlineData("en-US", 1, "1st")]
+ [InlineData("nl-NL", 1, "1e")]
+ public void OrdinalizeWithCultureOverridesCurrentCulture(CultureInfo culture, int number, string ordinalized)
+ {
+ Assert.Equal(number.Ordinalize(culture), ordinalized);
+ }
}
}
diff --git a/src/Humanizer/OrdinalizeExtensions.cs b/src/Humanizer/OrdinalizeExtensions.cs
index b689804b0..069a3052c 100644
--- a/src/Humanizer/OrdinalizeExtensions.cs
+++ b/src/Humanizer/OrdinalizeExtensions.cs
@@ -42,6 +42,17 @@ public static string Ordinalize(this int number)
return Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture));
}
+ ///
+ /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
+ ///
+ /// The number to be ordinalized
+ /// Culture to use. If null, current thread's UI culture is used.
+ ///
+ public static string Ordinalize(this int number, CultureInfo culture)
+ {
+ return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture));
+ }
+
///
/// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
/// Gender for Brazilian Portuguese locale