PluralityTransformation class
A transformation to convert the plural form of an input String.
This transformation attempts to convert the input String such that its plural form is modified to
targetPlurality. If it is known that inputs do not have the target plurality, setting
inputMayAlreadyHaveTargetPlurality to false
will improve performance. Leaving it as true
(the default value)
will ensure that transforming a word already of the target plurality will simply return that same word.
final transformation = PluralityTransformation(targetPlurality: Plurality.plural);
// 'dogs'
transformation.transform('dog', 'en_US');
// 'dogs'
transformation.transform('dogs', 'en_US');
// 'foxes'
transformation.transform('fox', 'en_US');
// 'oxen'
transformation.transform('ox', 'en_US');
- Inheritance
-
- Object
- Transformation<
String, String> - PluralityTransformation
- Available Extensions
Constructors
- PluralityTransformation({required Plurality targetPlurality, bool inputMayAlreadyHaveTargetPlurality = true})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- inputMayAlreadyHaveTargetPlurality → bool
-
If
true
, serves as an indicator that the plurality of the input may already match the target plurality. In scenarios where the input plurality is known to differ, set this tofalse
to optimize the transformation process.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- targetPlurality → Plurality
-
The desired plurality for transformed inputs.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transform(
String input, String locale) → String -
Transforms
input
into an instance ofU
using the providedlocale
.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited