How do you translate comments_number function text in a theme?

You have to make these strings translatable by using __() function:

comments_number( __('Comments (0)'), __('Comments (1)'), __('Comments (%)') );

If you want to use the custom textdomain, e.g. 'test':

comments_number( __('Comments (0)', 'test'), __('Comments (1)', 'test'), __('Comments (%)', 'test') );

For more information see:

tech