multi language – Set adjacent publication in alphabetical order for custom publication type in multilingual site

To apply the chronological order with the publications and the alphabetical order with a certain type of personalized publication, let's say "animals", which is shown through a template of single-animals.php, I found this fragment that works well:

/ *
*
* Sort links from previous / previous publications alphabetically for personalized publications "animals" and chronologically for publications of rest
*
* /
filter_next_post_sort ($ sort) {function
if (get_post_type ($ post) == & # 39; animals & # 39;) {
$ sort = "ORDER BY p.post_title ASC LIMIT 1";
}
plus{
$ sort = "OR DER BY p.post_date ASC LIMIT 1";
}
returns $ sort;
}
filter_next_post_where ($ where) {function
global $ post, $ wpdb;
if (get_post_type ($ post) == & # 39; animals & # 39;) {
return $ wpdb-> prepare ("WHERE p.post_title> & # 39;% s & # 39; AND p.post_type = & # 39;". get_post_type ($ post). "& # 39; AND p.post_status = & # 39; publish & # 39; ", $ post-> post_title);
}
plus{
return $ wpdb-> prepare ("WHERE p.post_date> & # 39;% s & # 39; AND p.post_type = & # 39;". get_post_type ($ post). "& # 39; AND p.post_status = & # 39; publish & # 39; ", $ post-> post_date, $ post-> post_type);
}
}
function filter_previous_post_sort ($ sort) {
if (get_post_type ($ post) == & # 39; animals & # 39;) {
$ sort = "ORDER BY p.post_title DESC LIMIT 1";
}
plus{
$ sort = "ORDER BY p.post_date DESC LIMIT 1";
}
returns $ sort;
}

filter_previous_post_where ($ where) {function
global $ post, $ wpdb;
if (get_post_type ($ post) == & # 39; animals & # 39;) {
returns $ wpdb-> prepare ("WHERE p.post_title < '%s' AND p.post_type = '". get_post_type($post)."' AND p.post_status = 'publish'",$post->entry title);
}
plus{
returns $ wpdb-> prepare ("WHERE p.post_date < '%s' AND p.post_type = '". get_post_type($post)."' AND p.post_status = 'publish'", $post->post_date, $ post-> post_type);
}
}

add_filter (& # 39; get_next_post_sort & # 39 ;, & # 39; filter_next_post_sort & # 39;);
add_filter (& # 39; get_next_post_where & # 39 ;, & # 39; filter_next_post_where & # 39;);
add_filter (& # 39; get_previous_post_sort & # 39 ;, & # 39; filter_previous_post_sort & # 39;);
add_filter (& # 39; get_previous_post_where & # 39 ;, & # 39; filter_previous_post_where & # 39;);

Now, when I use this piece of code in a multilingual site with WP 5.1.1 and the Polylang plugin, I get the following / previous links for all the elements of the "animal" custom publication type, regardless of their language or current language. the publication. .

Therefore, when using, for example, English, German and Spanish, as the site's languages, the result in template single-animals.php is an ordered sequence of previus / next links that mixes all the elements of the publication type Custom "animals" in all languages, like this:

"Adler, eagle, cat, eagle, Haifisch, cat, Katze, lion, lion, Löwe, shark, shark".

There is this Polylang plugin function that returns the current language: pll_current_language (& # 39; slug & # 39;) but, given my minimal knowledge of PHP, I still can not understand how to use it to add a conditional to the previous code that shows the sequence correct of following / previous links for each language:

FROM: "Adler, Haifisch, Katze, Löwe".
EN: "cat, eagle, lion, shark".
EN: "eagle, cat, lion, shark".

Any help would be greatly appreciated. Thank you!