UPDATE: In case anyone needs it, the following code will make certain Rank Math SEO options properly translateable via the Strings tab in Polylang.
/*
* Translate Rank Math SEO settings
*/
$my_theme_translateable_rank_math_options = [
'img_alt_format',
'img_title_format',
'breadcrumbs_separator',
'breadcrumbs_prefix',
'breadcrumbs_home_link',
'breadcrumbs_home_label',
'breadcrumbs_archive_format',
'breadcrumbs_search_format',
'breadcrumbs_404_label',
'rss_before_content',
'rss_after_content',
'title_separator',
'homepage_title',
'homepage_description',
'homepage_facebook_title',
'homepage_facebook_description',
'author_archive_title',
'author_archive_description',
'date_archive_title',
'date_archive_description',
'search_title',
'404_title',
];
add_filter('option_rank-math-options-titles', 'my_theme_translate_rank_math_seo_options', 10, 2);
add_filter('option_rank-math-options-general', 'my_theme_translate_rank_math_seo_options', 10, 2);
function my_theme_translate_rank_math_seo_options($arr, $name) {
global $my_theme_translateable_rank_math_options;
if(is_admin() or !function_exists('pll__')) {
return $arr;
}
foreach($my_theme_translateable_rank_math_options as $option) {
if(isset($arr[$option])) {
$arr[$option] = pll__($arr[$option]);
}
}
return $arr;
}
/*
* Reinitialize Rank Math SEO settings in order to translate them
*/
add_action('init', function() {
if(!is_admin() and function_exists('pll__')) {
rank_math()->settings->reset();
}
});