Localization extension
String extension which allows you to add plural modifiers to a string.
For example:
static var _t = Translations.byText("en_us") +
{
"en_us": "You clicked the button %d times"
.zero("You haven't clicked the button")
.one("You clicked it once")
.two("You clicked a couple times")
.many("You clicked %d times")
.times(12, "You clicked a dozen times"),
"pt_br": "Você clicou o botão %d vezes"
.zero("Você não clicou no botão")
.one("Você clicou uma única vez")
.two("Você clicou um par de vezes")
.many("Você clicou %d vezes")
.times(12, "Você clicou uma dúzia de vezes"),
};
String plural(value) => localizePlural(value, this, _t);
This extension is visible from both i18_exception
and i18_exception_core
packages.
- on
Methods
-
five(
String text) → String - Plural modifier for 5 elements.
-
four(
String text) → String - Plural modifier for 4 elements.
-
many(
String text) → String - Plural modifier for any number of elements, except 1. Note: many includes 0 elements, but it's less specific than zero and zeroOne.
-
modifier(
Object identifier, String text) → String -
Creates a modifier for the given
identifier
andtext
. -
one(
String text) → String - Plural modifier for 1 element.
-
oneOrMore(
String text) → String - Plural modifier for 1 or more elements. In other words, it includes any number of elements except zero.
-
six(
String text) → String - Plural modifier for 6 elements.
-
ten(
String text) → String - Plural modifier for 10 elements.
-
three(
String text) → String - Plural modifier for 3 elements.
-
times(
int numberOfTimes, String text) → String - Plural modifier for any number of elements, except 0, 1 and 2.
-
two(
String text) → String - Plural modifier for 2 elements.
-
twoThreeFour(
String text) → String - Plural modifier for 2, 3 or 4 elements (especially for Czech language).
-
zero(
String text) → String - Plural modifier for zero elements.
-
zeroOne(
String text) → String - Plural modifier for 0 or 1 elements.