WordPress.org

Support

Support » Plugins and Hacks » Paid Memberships Pro » Change language with pmpro_levels

Change language with pmpro_levels

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author messica

    @jessica-o

    You can change the text by using the pmpro_level_cost_text filter. An example can be found here: https://gist.github.com/strangerstudios/8150762#file-nicer_pmpro_level_cost_text-php-L4-L15

    Hope that helps!

    Hello Jessica,

    Basically, have the same question.

    These lines are from pmpro_getLevelCost(). All are in .po file, but they are not translatable, at least these 3 lines, which includes “The price for membership is…” – changes in .po have no effect in the front-end.

    Do you mean that this text cannot be translated from .po, what the point of adding it?

    thanks!

    I added the “Nicer level costs example” code to my theme’s functions.php file as directed, but it didn’t affect the text output at all … it still reads “The price for membership is $3.95 now. Membership expires after 1 month.”

    Very strange that it had no effect – the code looks pretty straightforward.

    Plugin Author Great H-master

    @great-h-master

    Hello.

    @james
    Has the wp-config.php file been updated to support the language? Also, have you compiled the .mo file? PMPro reads the .mo for to do the translations.

    @marvmckay66
    Very odd, try adding die("here"); to the code to see if it is actually getting to your code. Another bit of code could be undoing the changes. In which case try changing the priority of the filter.

    Hope this helps.

    Here’s something odd – I had already tried testing by commenting out the $text line and adding my own, which you’ll see below. Then I added your die(“here”); line above – this is what the code looks like, but scroll down to see what actually happened:

    function nicer_pmpro_level_cost_text($text, $level)
    {
    global $pmpro_currency_symbol;

    if(pmpro_isLevelFree($level))
    $text = “Membership is free.”;
    elseif($level->initial_payment == $level->billing_amount)
    die(“here”);
    //$text = $pmpro_currency_symbol . $level->initial_payment . “/” . $level->cycle_period;
    $text = “hello”;
    return $text;
    }
    add_filter(“pmpro_level_cost_text”, “nicer_pmpro_level_cost_text”, 15, 2);

    When I uploaded this, it skipped over “die” and you’ll see the next line is commented out, but then it output the “hello.” So then I got rid of “hello” and “die” and uncommented the original text line, and it still said “The price for membership is $3.95 now. Membership expires after 1 Month.”

    Here’s something weird – the “die” line seems to help the next line; I just tried using this:

    elseif($level->initial_payment == $level->billing_amount)
    die(“here”);
    $text = $pmpro_currency_symbol . $level->initial_payment . “/” . $level->cycle_period;
    return $text;

    And it outputs “$3.95/ “

    So the die is helping, but not all the way, it’s not recognizing the cycle period.

    hi! it’s not about .mo + other strings work fine.

    Probably, issue is that you are using _x, which is not working well with all editors. Had to read multiple threads, add additional translation keywords, but I still cannot get these lines working from Poedit.

    Maybe you could try to test some translation yourself. As a whole, it looks like these _x are not necessary at all. Idea is to comment 100% equal lines, but in Pmpro functions.php, where I see all these _x, most lines are different and you are using _x as a simple comment option – this is just my opinion of course.

    thanks!

    Plugin Author messica

    @jessica-o

    You need to remove the die('here'); for the code to continue running. It should like this:

    function nicer_pmpro_level_cost_text($text, $level)
    {
        global $pmpro_currency_symbol;
    
        if(pmpro_isLevelFree($level))
            $text = "Membership is free.";
        elseif($level->initial_payment == $level->billing_amount)
            $text = $pmpro_currency_symbol . $level->initial_payment . "/" . $level->cycle_period;
        return $text;
    }
    add_filter("pmpro_level_cost_text", "nicer_pmpro_level_cost_text", 15, 2);

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Change language with pmpro_levels’ is closed to new replies.
Skip to toolbar