plural_lint 0.0.7 copy "plural_lint: ^0.0.7" to clipboard
plural_lint: ^0.0.7 copied to clipboard

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.

plural_lint #

Pub Version package publisher

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 to the Unicode CLDR plural rules.

Installing plural_lint #

plural_lint bases on custom_lint. To use it, you have 2 options. Either add the dependencies to your pubspec.yaml:

dev_dependencies:
  custom_lint:
  plural_lint:

Or install them from the command line:

flutter pub add --dev custom_lint plural_lint

Next, enable the custom_lint analyzer plugin in your analysis_options.yaml:

analyzer:
  plugins:
    - custom_lint

All the lints #

missing_quantity #

This lint detects missing plural quantities in your translations. For example in English (en), you need to provide translations for one and other quantities. In Polish (pl), you need one, few, many and other. 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)

unused_quantity #

This lint detects unused plural quantities in your translations. For example in English (en), few and many quantities will never be used. Note that zero, one and two are supported by dart's intl package in all languages. Even if they are not listed in CLDR rules. For example you can provide zero quantity in English despite that English doesn't distinguish a special case for zero. See intl implementation for 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)

Data source #

This package has embedded CLDR rules for plural forms in plurals.xml. That file is taken from the official Unicode CLDR repository.

Disabling specific rules #

By default all the lints are be enabled. You can disable specific rules by modifying the analysis_options.yaml file like this:

custom_lint:
  rules:
    - unused_quantity: false
    - missing_quantity: false

Running plural_lint from the terminal/CI #

Custom lint rules may not show-up in dart analyze. To fix this, invoke a custom_lint in the terminal:

dart run custom_lint
0
likes
0
pub points
0%
popularity

Publisher

verified publisherkoral.dev

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.

Repository (GitHub)
View/report issues

Topics

#lint #check #i18n #static-code-analysis

License

unknown (license)

Dependencies

analyzer, analyzer_plugin, custom_lint_builder, meta, path, petitparser, resource_portable, xml

More

Packages that depend on plural_lint