- Notifications
You must be signed in to change notification settings - Fork0
plural_lint is a developer tool to check plural translations in your project. It detects both missing and unused plural quantities in the ARB files.
License
koral--/plural_lint
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
plural_lint is a developer tool to check plural translations in your project.It detects both missing and unused plural quantities in the ARB files for each locale according tothe Unicode CLDR plural rules.
plural_lint bases oncustom_lint. To use it, you have 2 options.Either add the dependencies to yourpubspec.yaml
:
dev_dependencies:custom_lint:plural_lint:
Or install them from the command line:
flutter pub add --dev custom_lint plural_lint
Next, enable thecustom_lint
analyzer plugin in youranalysis_options.yaml
:
analyzer:plugins: -custom_lint
This lint detects missing plural quantities in your translations. For example in English (en
),you need to provide translations forone
andother
quantities. In Polish (pl
),you needone
,few
,many
andother
.If you don't provide all the required quantities the lint will report that as a warning.
For instance, the following entry in English ARB file:
{"things" :"{count, plural, other{things}}" }
Will trigger a warning:
warning: These quantities: [one] are missing for locale: en (missing_quantity at [app] lib/l10n/intl_en.arb:3)
This lint detects unused plural quantities in your translations. For example in English (en
),few
andmany
quantities will never be used. Note thatzero
,one
andtwo
are supported by dart'sintl package in all languages. Even ifthey are not listed in CLDR rules.For example you can providezero
quantity in English despite that English doesn't distinguisha special case for zero. Seeintl implementationfor more details.
For instance, the following entry in English ARB file:
{"things2" :"{count, plural, one{thing} few{things} many{things} other{things}}" }
Will trigger a warning:
info: These quantities: [few, many] are not used in locale: en (unused_quantity at [app] lib/l10n/intl_en.arb:4)
This package has embedded CLDR rules for plural forms inplurals.xml.That file is taken from the officialUnicode CLDR repository.
By default all the lints are be enabled. You can disable specific rules by modifyingtheanalysis_options.yaml
file like this:
custom_lint:rules: -unused_quantity:false -missing_quantity:false
Custom lint rules may not show-up indart analyze
.To fix this, invoke acustom_lint
in the terminal:
dart run custom_lint
About
plural_lint is a developer tool to check plural translations in your project. It detects both missing and unused plural quantities in the ARB files.