public class TranslationCheck extends AbstractFileSetCheck
The TranslationCheck class helps to ensure the correct translation of code by checking property files for consistency regarding their keys. Two property files describing one and the same context are consistent if they contain the same keys.
An example of how to configure the check is:
<module name="Translation"/>Check has the following properties:
basenameSeparator which allows setting separator in file names, default value is '_'.
E.g.:
messages_test.properties //separator is '_'
app-dev.properties //separator is '-'
requiredTranslations which allows to specify language codes of
required translations which must exist in project. The check looks only for
messages bundles which names contain the word 'messages'.
Language code is composed of the lowercase, two-letter codes as defined by
ISO 639-1.
Default value is empty String Set which means that only the existence of
default translation is checked.
Note, if you specify language codes (or just one language code) of required translations
the check will also check for existence of default translation files in project.
Modifier and Type | Field and Description |
---|---|
static String |
MSG_KEY
A key is pointing to the warning message text for missing key
in "messages.properties" file.
|
static String |
MSG_KEY_MISSING_TRANSLATION_FILE
A key is pointing to the warning message text for missing translation file
in "messages.properties" file.
|
Constructor and Description |
---|
TranslationCheck()
Creates a new
TranslationCheck instance. |
Modifier and Type | Method and Description |
---|---|
void |
beginProcessing(String charset)
Called when about to be called to process a set of files.
|
void |
finishProcessing()
Called when all the files have been processed.
|
protected void |
processFiltered(File file,
List<String> lines)
Called to process a file that matches the specified file extensions.
|
void |
setBasenameSeparator(String basenameSeparator)
Sets the separator used to determine the basename of a property file.
|
void |
setRequiredTranslations(String translationCodes)
Sets language codes of required translations for the check.
|
destroy, fireErrors, getFileExtensions, getMessageCollector, getMessageDispatcher, init, log, log, process, setFileExtensions, setMessageDispatcher
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
configure
contextualize
public static final String MSG_KEY
public static final String MSG_KEY_MISSING_TRANSLATION_FILE
public TranslationCheck()
TranslationCheck
instance.public void setRequiredTranslations(String translationCodes)
translationCodes
- a comma separated list of language codes.public void beginProcessing(String charset)
FileSetCheck
beginProcessing
in interface FileSetCheck
beginProcessing
in class AbstractFileSetCheck
charset
- the character set used to read the files.protected void processFiltered(File file, List<String> lines)
AbstractFileSetCheck
processFiltered
in class AbstractFileSetCheck
file
- the file to be processedlines
- an immutable list of the contents of the file.public void finishProcessing()
FileSetCheck
finishProcessing
in interface FileSetCheck
finishProcessing
in class AbstractFileSetCheck
public final void setBasenameSeparator(String basenameSeparator)
basenameSeparator
- the basename separatorCopyright © 2001–2016. All rights reserved.