Package slash.navigation.converter.tools
Class ResourceBundleCompletenessReport
java.lang.Object
slash.navigation.converter.tools.ResourceBundleCompletenessReport
Computes, per locale, how many of a base locale's resource bundle keys
a translated bundle carries, and flags regressions against a previous
measurement.
This class is pure: it never reads or writes files itself, so its logic
can be unit-tested against in-memory key sets.
analyzeDirectory(java.io.File, java.lang.String, java.lang.String)
is the only method that touches the file system.- Author:
- Christian Pesch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionComputes completeness of every locale inlocaleKeysagainstbaseKeys.analyzeDirectory(File directory, String prefix, String baseLocale) Loads every<prefix>_<locale>.propertiesfile indirectoryand reports its completeness against<prefix>_<baseLocale>.properties.findRegressions(Map<String, Double> previousPercentByLocale, Map<String, ResourceBundleCompletenessReport.LocaleCompleteness> current, double threshold) Returns the locales that regressed: they were previously at or abovethresholdand are now below it.loadBaseline(File file) Loads alocale=percentproperties file, as written by a previous run of this report.static voidCommand line entry point for the release-preparation workflow: prints a per-locale completeness report and exits non-zero only when a locale that was previously at or aboveDEFAULT_REGRESSION_THRESHOLDhas dropped below it since the baseline file was last written.
-
Field Details
-
DEFAULT_REGRESSION_THRESHOLD
public static final double DEFAULT_REGRESSION_THRESHOLD- See Also:
-
-
Constructor Details
-
ResourceBundleCompletenessReport
public ResourceBundleCompletenessReport()
-
-
Method Details
-
analyze
public Map<String,ResourceBundleCompletenessReport.LocaleCompleteness> analyze(Map<String, Set<String>> localeKeys, Set<String> baseKeys) Computes completeness of every locale inlocaleKeysagainstbaseKeys. A locale not present inbaseKeysat all still gets a result: 0 keys, all missing, 0 percent. -
findRegressions
public List<String> findRegressions(Map<String, Double> previousPercentByLocale, Map<String, ResourceBundleCompletenessReport.LocaleCompleteness> current, double threshold) Returns the locales that regressed: they were previously at or abovethresholdand are now below it. A locale with no previous measurement (a first sighting, or a brand-new locale) never counts as a regression, however low its current percentage is. -
analyzeDirectory
public Map<String,ResourceBundleCompletenessReport.LocaleCompleteness> analyzeDirectory(File directory, String prefix, String baseLocale) throws IOException Loads every<prefix>_<locale>.propertiesfile indirectoryand reports its completeness against<prefix>_<baseLocale>.properties.- Throws:
IOException
-
loadBaseline
Loads alocale=percentproperties file, as written by a previous run of this report. Used as the "previous measurement" input tofindRegressions(java.util.Map<java.lang.String, java.lang.Double>, java.util.Map<java.lang.String, slash.navigation.converter.tools.ResourceBundleCompletenessReport.LocaleCompleteness>, double). Returns an empty map iffileis null or does not exist, so a first run never has anything to regress against.- Throws:
IOException
-
main
Command line entry point for the release-preparation workflow: prints a per-locale completeness report and exits non-zero only when a locale that was previously at or aboveDEFAULT_REGRESSION_THRESHOLDhas dropped below it since the baseline file was last written. A locale absent from the baseline (a first sighting, or a brand-new locale, e.g. sr today) never fails the run, however low its percentage is.- Throws:
IOException
-