• Hello everybody!

    I use the vantage theme for my website.

    For the blog part of this one ( https://vitamine-design.fr/blog/ ) I wanted to translate the “Posted On” date by the french tradution “Posté le”.

    The only solution that I found what to modify directly the vantage/inc/template-tags.php

    I tried to do it in the vantage-child/inc/template-tags.php but it didn’t work.

    I tried to modify the vantage/languages/vantage.pot but it didn’t work as well…

    I reall y want to find a solution, because if I modify directly the template-tags.php in the “Vantage” folder, next update it will be lose…

    If you can help me!

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Curious to know what you changed it to?

    Thread Starter Fwe34000

    (@fwe34000)

    As I told, I change:

    function vantage_posted_on() {
    	$posted_on_parts = array(
    		'on' => __('<strong>Posted on</strong> <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', 'vantage'),
    		'by' => __( '<span class="byline"> by <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'vantage' ),
    	);

    by

    function vantage_posted_on() {
    	$posted_on_parts = array(
    		'on' => __('<strong>Posté le</strong> <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', 'vantage'),
    		'by' => __( '<span class="byline"> by <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'vantage' ),
    	);
    Thread Starter Fwe34000

    (@fwe34000)

    The solution, in the child folder, function.php file:

    <?php add_action('after_setup_theme','remove_fonction_parent');
    function remove_fonction_parent() {
       remove_action('hook','vantage_posted_on');
       add_action('hook','vantage_posted_on');
    }
    
    function vantage_posted_on() {
    	$posted_on_parts = array(
    		'on' => __('Posté le <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', 'vantage'),
    		'by' => __( '<span class="byline"> by <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'vantage' ),
    	);
    	$posted_on_parts = apply_filters('vantage_post_on_parts', $posted_on_parts);
    
    	$posted_on = sprintf( implode(' ', $posted_on_parts),
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		apply_filters('vantage_post_on_date', esc_html( get_the_date() )),
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'vantage' ), get_the_author() ) ),
    		get_the_author()
    	);
    	echo apply_filters('vantage_posted_on', $posted_on);
    }
    
    ?>
    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    You can also use a filter in your child theme.

    add_filter( 'vantage_post_on_parts', 'child_parts' );
    function child_parts(){
    	return array(
    		'<strong>Posté le</strong> <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    		'<span class="byline"> by <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>'
    		);
    }

    Not sure what translation tool you are using but in the most recent version ( 1.1.11 ) that phrase is in line 1468 of the POT file.

    That would be one way I can think of changing it without losing your edits. ??

    Thread Starter Fwe34000

    (@fwe34000)

    Hello Jose,

    So if I undo the solution I proposed in my child functions.php file and put yours it should work?

    Moreover, if I only copy the .pot file in my child folder and change “Posted on” by “Posté le” it should work directly without the modifications in the function file?

    Thanks for your answer!

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Yes, it should work. I tested it prior to posting it. Make sure that you are returning the array otherwise you will get an error.

    As for the POT file in the child theme I can’t say for sure; I’m not too familiar with how it is handled. I have an idea but I would feel bad if something went wrong.

    Thread Starter Fwe34000

    (@fwe34000)

    Hello Jose!

    I tried your solution and it worked well!

    But I tried to use the “POT File” solution:

    -I downloaded in “Parent theme>languages>vantage.pot”
    -Opened it in POEDIT, saved it in PO and MO files, did the translation in my PO file, saved him and uploaded both PO and MO files in my “Child Theme>languages>” folder: it didn’t work!

    BUT I uploaded them in my “Parent theme>languages>” folder and it worked!

    Is there a solution to open them from the Child folder? When my them will be uploaded will y transation be erase?

    Thx!

    Fred

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Part of the reason is when the language file is being loaded the function load_theme_textdomain is used and most parent themes will use: get_template_directory in favor of get_stylesheet_directory

    One solution would be calling load_theme_textdomain in your functions file and using the get_stylesheet_directory but then you may run into trouble with parent/child text domain issues. I’ve yet to experiment with that.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Parent / Child theme problem’ is closed to new replies.