Class TranslationCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable, FileSetCheck

    public class TranslationCheck
    extends AbstractFileSetCheck

    The TranslationCheck class helps to ensure the correct translation of code by checking locale-specific resource files for consistency regarding their keys. Two locale-specific resource files describing one and the same context are consistent if they contain the same keys. TranslationCheck also can check an existence of required translations which must exist in project, if 'requiredTranslations' option is used.

    An example of how to configure the check is:

     <module name="Translation"/>
     
    Check has the following options:

    baseName - a base name regexp for resource bundles which contain message resources. It helps the check to distinguish config and localization resources. Default value is ^messages.*$

    An example of how to configure the check to validate only bundles which base names start with "ButtonLabels":

     <module name="Translation">
         <property name="baseName" value="^ButtonLabels.*$"/>
     </module>
     

    To configure the check to check only files which have '.properties' and '.translations' extensions:

     <module name="Translation">
         <property name="fileExtensions" value="properties, translations"/>
     </module>
     

    requiredTranslations which allows to specify language codes of required translations which must exist in project. 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. ATTENTION: the check will perform the validation of ISO codes if the option is used. So, if you specify, for example, "mm" for language code, TranslationCheck will rise violation that the language code is incorrect.

    Author:
    Alexandra Bunge, lkuehne, Andrei Selkin