RM variables output language

  • Hello,
    what is determining language displayed when using for example %currentmonth% variable in titles?

    I’m getting month name displayed in English, how do I force it to show month name in another prefferable language?

    Thank you in advance!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Hi,

    We are using date_i18n() function to show the current month. This function shows the current month in the site language.

    You can change it by using replacement filter:

    Rank Math SEO Filters and Hooks for Developers

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hello,
    thank you for your answer but it doesn’t solve the problem.

    My site lang is set to Norwegian but variable output is printed in English, screenshot follows

    Screenshot

    Can you please advise?

    Hello,

    Thank you for contacting Rank Math today.

    I have been able to reproduce this problem on my end and this has been reported to our dev team. For now, you can override this variable by adding the following code to your theme’s functions.php file:

    /**
     * Filter to modify currentmonth variable
     */
    add_filter( 'rank_math/vars/replacements', function( $vars ) {
    	$vars['currentmonth'] = array(
    			'name'    => esc_html__( 'Current Month', 'rank-math' ),
    			'desc'    => esc_html__( 'Current server month', 'rank-math' ),
    			'example' => date_i18n( 'F',  strtotime( get_the_time( "Y-m-d" ) ) ),
    		);
    	return $vars;
    });

    I hope this info helps. Thank you.

    ​​​​​​

    Thank you Michael, the hack works fine.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?rate=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

    Hello, Michael Davis.

    I had the same problem and use this code that works very well. I want the first letter of the month to be capitalized.
    What would you have to modify?

    Apologies for the translation I speak Spanish.

    Hi there,

    Thanks for the follow up.

    The code should automatically convert the first letter to uppercase but if this is not working on your end. You can modify the code to the following:

    
    /**
     * Filter to modify current month variable
     */
    add_filter( 'rank_math/vars/replacements', function( $vars ) {
        
        $vars['currentmonth']['example'] = ucfirst(date_i18n( 'F',  strtotime( get_the_time( "Y-m-d" ) ) ));
        return $vars;
    });

    I hope this info helps. Thank you.

    Edit your WP spanish translation in order to get month names capitalized.

    Hello Michael,

    the last snippet you provided does capitalize first letter but the result is printed in English and not Norwegian on my side.

    I need to correct myself.

    Case 1. Site lang set to Norwegian and lang for my admin user set to English resultet in English print of variables.

    Case 2. Site lang set to Norwegian and lang for my admin user set to Norwegian resultet in Norwegian print of variables and capitalized month name using last snippet provided.

    Thanks again

    It did not work
    The language of the site and administrator is set to Spanish. WordPress is in Spanish.

    Hi @johny,

    Could you please open a new ticket and include your site logins in the sensitive data section so we can check?

    Please see this video: https://i.rankmath.com/fDTlH9

    As you can see, the month changes to the selected language automatically when we try it.

    We look forward to helping you.

    Hello, Todd

    Thank you very much for the patience and dedication in helping me.
    The video is very explicit and everything is fine.

    I’m going to open a ticket but with another concern I have about the Google PageMaps.

    Warm greetings are a great Team and my change to this fantastic plugin was a great decision that gladly took it.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?rate=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 14 replies - 1 through 14 (of 14 total)

The ticket ‘RM variables output language’ is closed to new replies.