'Return a translation function `translate` for `self` on the given
records; the function call `translate(record_id, value)` translates the
field value to the language given by the environment of `records`.'

def get_trans_func(self, records):

    if callable(self.translate):
        rec_src_trans = records.env['ir.translation']._get_terms_translations(self, records)
        def translate(record_id, value):
            src_trans = rec_src_trans[record_id]
            return self.translate(src_trans.get, value)
    else:
        rec_trans = records.env['ir.translation']._get_ids(('%s,%s' % (self.model_name, self.name)), 'model', records.env.lang, records.ids)
        def translate(record_id, value):
            return (rec_trans.get(record_id) or value)
    return translate
