पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv0.2.1

translations_cleaner

सभी अनुवादों में ARB फ़ाइलों में अनउपयोगी कुंजियों को हटाने के लिए पैकेज

macOSWindowsLinux
30-दिन डाउनलोड
18.2 हज़ार
लाइक
42
Pub अंक
150

पैकेज इंस्टॉल करें

flutter pub add translations_cleaner

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

एक फ्लटर/डार्ट पैकेज जो बहुभाषी स्थानीयकरण में अनप्रयुक्त अनुवाद कुंजियों को साफ करने के लिए डिज़ाइन किया गया है, जो ARB (App Resource Bundle) फ़ाइलों में उपलब्ध है। यह कोडबेस में अब नहीं उपयोग किए जाने वाले कुंजियों को पहचानकर हटाकर साफ और कुशल स्थानीयकरण प्रवाह बनाए रखने में मदद करता है। बड़े पैमाने पर अंतरराष्ट्रीय ऐप्स के प्रबंधन करने वाली टीमों के लिए आदर्श है, यह गड़बड़ी को कम करता है और अप्रचलित अनुवादों के बने रहने से बचाता है। इस उपकरण को कमांड-लाइन उपयोगिता के रूप में चलाया जा सकता है जो macOS, Windows और Linux के साथ संगत है।

उपयोग

  • अप्रासंगिक अनुवाद की मानकों को हटाएं
  • साफ ARB फ़ाइलों को बनाए रखना
  • स्थानीयकरण कार्य प्रवाह को सुगम बनाना
  • अनुवाद ब्लॉट को रोकना
  • CI/CD पाइपलाइन में स्वचालित सफाई करना

मुख्य विशेषताएँ

  • अनिर्दिष्ट कुंजियों के लिए सभी ARB फ़ाइलों का स्कैन करता है
  • बहुभाषी ARB फ़ाइलों का समर्थन करता है
  • कमांड-लाइन इंटरफेस
  • प्लेटफॉर्म के अनुकूलता
  • Flutter प्रोजेक्ट्स के साथ एकीकृत होता है

इनके लिए उपयुक्त

  • फ्लटर विकासकर्ता अनुवाद प्रबंधित कर रहे हैं
  • स्थानीयकरण टीमें
  • CI/CD पाइपलाइंस
  • अक्सर UI बदलाव वाले प्रोजेक्ट्स
  • अंतर्राष्ट्रीयकरण के लिए ARB का उपयोग करने वाली टीमें

विचार योग्य बातें

  • हटाए जाने से पहले हस्ताक्षर की आवश्यकता है
  • गतिशील कुंजियों का निपटारा नहीं करता है
  • कोई ग्राफिकल उपयोगकर्ता इंटरफेस नहीं
  • विकास या स्टेजिंग में सबसे अच्छा उपयोग किया जाता है
  • चलाने से पहले ARB फ़ाइलों का बैकअप लें

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

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

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 4 आइटम

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट