Allow the configuration of EPUBCheck’s Locale #911
Merged
+1,975
−1,008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR completes and replaces #650.
The locale used by EPUBCheck can now be configured:
--locale
option on the command linesetLocale(Locale locale)
method on theEpubCheck
classJVM Locale (i.e. EPUBCheck’s behavior doesn’t change)
This PR introduces the following changes:
com.adobe.epubcheck.util.Messages
:getInstance(…)
methods to get theMessages
instancefor the given (optional) locale and class name (used to resolve
the name of the underlying
ResourceBundle
).Messages
instances are cached in a table, keyed with localecodes and resource bundle names.
com.adobe.epubcheck.message
package:MessageDictionary
is now an interface; it's functionality is splitin several classes to handle default messages, loading of override
files, overridden messages, dumping message files, and severities.
org.idpf.epubcheck.util.css
package, to make itlocale-aware:
Locale
is given as an argument to theCSSParser
constructorMessages
class is removed, replaced by the maincom.adobe.epubcheck.util.Messages
LocalizedReport
interface, extending theReport
interface withlocale getter/setter methods, representing a localizable report.
Report
interface is kept unchanged, for backwardscompatibility
MasterReport
implements this newLocalizedReport
interfaceof
LocalizedReport
before setting a new locale.LocaleHolder
facility to statically store the "current" localein a thread-local variable. This is used by libraries that cannot be
configured dynamically with a new locale (like Jing).
Localizer
class to load Jing's resource bundlesfor the locale exposed in the
LocaleHolder
utility.ValidationContext
classLimitations:
static thread-local variable (in the
LocaleHolder
class). Any newimplementations of the
LocalizedReport
must make sure that the localestored in the
LocaleHolder
is updated when the locale is changed orinitialized.
not localized.
Thanks to @matthew-macgregor for the original PR contribution (#650)!
Closes #650
Fixes #498