Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

NotificationsYou must be signed in to change notification settings

koral--/plural_lint

Repository files navigation

Pub Versionpackage 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 tothe Unicode CLDR plural rules.

Installing plural_lint

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

All the lints

missing_quantity

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)

unused_quantity

This lint detects unused plural quantities in your translations. For example in English (en),few andmany quantities will never be used. Note thatzero,one andtwoare 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)

Data source

This package has embedded CLDR rules for plural forms inplurals.xml.That file is taken from the officialUnicode CLDR repository.

Disabling specific rules

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

Running plural_lint from the terminal/CI

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp