class PersistenceDescriptorValidationMessageTranslator implements ValidationMessageTranslator {

    @Override
    public ValidationMessage translate( ValidationMessage checkMessage ) {
        PersistenceDescriptorValidationMessage pdValidationMessage = ( PersistenceDescriptorValidationMessage ) checkMessage;
        ValidationMessage result = new ValidationMessage( );
        result.setId( checkMessage.getId( ) );
        result.setLevel( checkMessage.getLevel( ) );
        String translationKey = createTranslationKey( pdValidationMessage.getId( ) );

        if ( translationService.getTranslation( translationKey ) != null ) {
            if ( pdValidationMessage.getParams( ) != null && !pdValidationMessage.getParams( ).isEmpty( ) ) {
                pdValidationMessage.getParams().toArray( new String[ pdValidationMessage.getParams().size() ] );
                result.setText( translationService.format( translationKey, pdValidationMessage.getParams().toArray() ) );
            } else {
                result.setText( translationService.getTranslation( translationKey ) );
            }
        } else {
            result.setText( checkMessage.getText( ) );
        }
        return result;
    }

    @Inject public  PersistenceDescriptorValidationMessageTranslator( TranslationService translationService );

}