패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소Chinmay-KB/translations_cleaner

translations_cleaner

ARB 파일에서 사용되지 않는 번역을 제거하는 Dart 패키지입니다.

translations_cleaner 프로젝트 이미지
스타
6
포크
12
최근 푸시(UTC)
2026. 6. 16.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

translations_cleaner

Dart package to search and delete unused translations from .arb files, for all languages, all in one go.

NOTE : This package has been developed keeping flutter_localizations package in mind, which uses .arb files for all translations.

Package in action

Usage

# Add translations_cleaner as a dev dependency
dart pub add --dev translations_cleaner

dart run translations_cleaner <command> [arguments]
# OR
flutter pub run translations_cleaner <command> [arguments]

Commands Available
  • clean-translations - Search all the translations listed in arb files and delete the unused translations
  • list-unused-terms - Search all the translations listed in arb files and print/save a list of unused translations.
  • sort-translations - Sorts all the translations in arb files alphabetically.
Options Available

Available only for list-unused-terms

  • -a, --[no-]abort-on-unused - Abort execution if unused translations are found. This can be helpful in CI, if you don't want to proceed if a build should fail.

Available for clean-translations and list-unused-terms

  • -h, --help - Print this usage information.
  • -o, --output-path - Path for saving exported file, defaults to root path of the folder
  • -e, --[no-]export - Save unused keys as a .txt file in the path provided
  • -s, --include-subpackages - Include arb files from subpackages (directories with their own pubspec.yaml). By default, subpackages are excluded to avoid false positives in monorepo setups.

Why 🤔

Translations can be a very time consuming process when the app starts to scale and there are lots of translations. It is a good practice to clean out translations that are not being used. Checking for unused translations is tedious, hence this package.

How 🤖

  • translations_cleaner looks for all the .arb files located in the directory, and fetches all the translations, from all the languages.
  • Then it looks for all the .dart files.
  • It parses Dart files with AST and detects key usage from localization-style member access and matching top-level functions.
  • The translations not found in the dart files are removed from the corresponding .arb files, including any attributes as well
Detection: regex → AST

Unused keys used to be detected by scanning Dart files as raw text with word-boundary regex. That often marked keys as "used" when they only appeared in comments, string literals, or generated code (e.g. AppLocalizations getters). Detection is now AST-based: we parse each Dart file and only count a key as used when it appears as a member on a localization-like target (e.g. context.l10n.someKey, AppLocalizations.of(context).someKey) or as a top-level function call with the same name. That reduces false positives and aligns results with actual usage.

Performance
  • Regex (old): Single pass over file contents with precompiled patterns; very fast but prone to false positives.
  • AST (current): Each Dart file is parsed once; more work per file but only lib/**/*.dart is scanned. On large projects you may notice a few extra seconds; list-unused-terms prints timing so you can compare.

Limitations 😔

  • This package currently works only for l10n achieved via flutter_localizations, which uses .arb files.
  • There are other l10n packages which use .json and .yaml for saving translations. These are not supported currently

Bugs / issues

If you run into bugs or unexpected behavior, please open an issue: github.com/Chinmay-KB/translations_cleaner/issues

Chinmay Kabi GitHub avatar
GitHub 작성자

Chinmay Kabi ↗

SDE @blendto | Flutter Developer | Master Tinkerer

@blendtoBengaluru
언어Dart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 6 개

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗