Filter language in Polylang for custom taxonomy

Nevermind, I finally found. This is not documented, but going through Polylang code I found a way.

First retrieve the languages with their taxonomy id with

$lang = get_terms('term_language', ['hide_empty' => false])

which gives an object that can be called as
$lang->name
and
$lang->term_id.

Then, the wp_query should look like this:

                $args = array(
                    'post_type'      => ['post', 'page'],
                    'post_status'    => 'publish',
                    'numberposts' => -1,
                    'nopaging'    => true,
                    'tax_query' => array(
                        'relation' => 'AND',
                        array(
                            'taxonomy' => $taxonomy_custom_category,
                            'field'    => 'name',
                            'terms'    => $taxonomy_term,
                        ),
                        array(
                            'taxonomy' => 'language',
                            'field'    => 'term_taxonomy_id',
                            'terms'    => $lang->term_id,
                        ),
                    ),
                );

From there, it’s easy to build a form or whatever you want your plugin to do.

I know this is a bit off topic, but this information is unavailable anywhere. I nevertheless found that many plugin developers are getting stuck as I was.

tech