Skip to content

Commit

Permalink
File scoped namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
hazzik committed Feb 24, 2024
1 parent 8481475 commit 62e88e5
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions src/Humanizer/Localisation/Formatters/RomanianFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
namespace Humanizer
namespace Humanizer;

class RomanianFormatter() :
DefaultFormatter("ro")
{
class RomanianFormatter() :
DefaultFormatter("ro")
{
const int PrepositionIndicatingDecimals = 2;
const int MaxNumeralWithNoPreposition = 19;
const int MinNumeralWithNoPreposition = 1;
const string UnitPreposition = " de";
const int PrepositionIndicatingDecimals = 2;
const int MaxNumeralWithNoPreposition = 19;
const int MinNumeralWithNoPreposition = 1;
const string UnitPreposition = " de";

static readonly double Divider = Math.Pow(10, PrepositionIndicatingDecimals);
static readonly double Divider = Math.Pow(10, PrepositionIndicatingDecimals);

protected override string Format(TimeUnit unit, string resourceKey, int number, bool toWords = false)
{
var format = Resources.GetResource(GetResourceKey(resourceKey, number), Culture);
var preposition = ShouldUsePreposition(number)
? UnitPreposition
: string.Empty;
protected override string Format(TimeUnit unit, string resourceKey, int number, bool toWords = false)
{
var format = Resources.GetResource(GetResourceKey(resourceKey, number), Culture);
var preposition = ShouldUsePreposition(number)
? UnitPreposition
: string.Empty;

return string.Format(format, number, preposition);
}
return string.Format(format, number, preposition);
}

static bool ShouldUsePreposition(int number)
{
var prepositionIndicatingNumeral = Math.Abs(number % Divider);
return prepositionIndicatingNumeral is < MinNumeralWithNoPreposition or > MaxNumeralWithNoPreposition;
}
static bool ShouldUsePreposition(int number)
{
var prepositionIndicatingNumeral = Math.Abs(number % Divider);
return prepositionIndicatingNumeral is < MinNumeralWithNoPreposition or > MaxNumeralWithNoPreposition;
}
}
}

0 comments on commit 62e88e5

Please sign in to comment.