Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #343099
    Rockpix
    Participant

    Hi there,

    I have translated  my site rockpix(dot)se with Polylang and have some problems with missed strings for Featured content and some other stuff on my frontpage because I am using child theme.I found out that you recommends WPML but I have already translated the whole site with Polylang before I saw that.

    I use, and missing strings to translate for:

    • Header Media Title
    • Site Header Text
    • Header Media URL
    • Header Media URL Text
    • Excerpt options: Read more text
    • Featured Content
    • Promotion Headline
    • Events

    I found this for another theme of yours here in the support forum, but I need some help to adapt the codes for the Bold Photography Pro Child theme.

    Thanks in advance,

    ROCKPIX

    #343100
    Rockpix
    Participant

    Also… Missing strings to translate for Footer Editor Options: Footer Content.

    / ROCKPIX

    #343101
    Sakin
    Keymaster

    Hi Rickpix,

    Please add the following function in our child theme’s functions.php file

    function bold_photography_register_polylang_strings() {
    	if ( ! function_exists( 'pll_register_string' ) ) {
    		return;
    	}
    
    	$mods = get_theme_mods();
    
    	foreach ( $mods as $key => $value ) {
    
    		// Only register clean strings
    		if ( is_string( $value ) && strlen( trim( $value ) ) > 0 ) {
    
    			pll_register_string(
    				$key,
    				$value,
    				'Bold Photography'
    			);
    		}
    	}
    }
    add_action( 'after_setup_theme', 'bold_photography_register_polylang_strings', 20 );

    After you add this code. You need to go to “Appearance => Customize” and change the content which you want to translate.
    For example, if you want to change Header Media Title and Site Header Text, then go to “Appearance => Customize => Header Media” and change Header Media Title and Site Header Text and click on publish. After you make the changes, it will show those strings Polylang at “Languages => Transalations”

    Regards,
    Sakin

    #343103
    Rockpix
    Participant

    Hi there Sakin,

    I have follow all steps but it doesn´t work.

    The strings shows up in Polylang at “Languages => Transalations” but they doesn´t translate the site when I translate the strings.

    I also tried to changing all “bold_photography” in the child themes functions.php file to “bold_photography_pro_child_theme” but that didn´t work eather. So now I have changed it back to “bold_photography” in the child themes functions.php file.

    Cheers,

    ROCKPIX

    #343104
    Sakin
    Keymaster

    So, we need ot check your child theme and website. I will contact you.

    #343139
    Sakin
    Keymaster

    Here goes the function that you need to add to the child theme to make your child theme compatible with the Polylang plugin.

    /**
     * Use parent theme mods in child theme.
     *
     * This keeps Polylang/WPML translations working
     * because translated strings remain attached
     * to the parent theme Customizer settings.
     */
    function bold_photography_child_theme_mods( $mods ) {
    
    	$parent_theme = get_template();
    
    	$parent_mods = get_option( 'theme_mods_' . $parent_theme );
    
    	if ( is_array( $parent_mods ) ) {
    		return $parent_mods;
    	}
    
    	return $mods;
    }
    
    add_filter(
    	'pre_option_theme_mods_' . get_stylesheet(),
    	'bold_photography_child_theme_mods'
    );
    
    #343155
    Rockpix
    Participant

    Hi again,

    AWESOME!!!

    You´re the best… Thank you Sakin!

    Kindly Regards,

    ROCKPIX

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.