For the text in the theme to be able to be translated, the text should be passed as an argument through the localization functions __()
, _e()
.
echo __( ‘Sample text to display’, ‘theme-textdomain’ );
_e( ‘Sample text to display’, ‘theme-textdomain’ );
More functions and details you can find here
In your case it could look like this:
© <?php
echo date("Y");
$page_id = 'ID_of_privacy_policy_page';
if ( function_exists('pll_get_post') )
$page_id = pll_get_post( $page_id );
$p_link = get_the_permalink($page_id);
$p_title = get_post_field('post_title', $page_id);
printf(' "https://wordpress.stackexchange.com/questions/312590/%s" %s | <a href="https://wordpress.stackexchange.com/questions/312590/%s">%s</a>',
'Company name',
__('All rights reserved', 'some_textdomain'),
esc_url($p_link),
esc_html($p_title)
);
$page_id
can be hardcoded or set with $page_id = get_page_by_path('privacy-policy')->ID;
.
$page_id = pll_get_post( $page_id );
The obove line will get ID of “Privacy policy” page in current language.
The next step is to prepare a files with the translation de_DE.po
, de_DE.mo
and for 2 other languages. Edit existing files in your theme or create new ones if needed. A list of sample tools is available on the codex website, among others Loco Translate, Poedit.