Replacing a word/string with filter resets the translation from DE to EN

Home Forums Calendar Products Events Calendar PRO Replacing a word/string with filter resets the translation from DE to EN

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1062499
    Michael
    Participant

    Hi there,

    As described in the title: When I try to replace a string (as described here: https://theeventscalendar.com/knowledgebase/change-the-wording-of-any-bit-of-text-or-string/ ), the translations of TEC are reset to english.

    I tried it on a fresh WordPress installation with the Twenty Sixteen Theme and only The Events Calendar plugin (& Event Tickets, but the problem also occured with the Event Tickets plugin deactivated).

    Any idea how the code snippet needs to be fixed?

    FYI: I have a license for TEC PRO, but this happens with the free plugin installed. And I know the translations for free and premium plugins are done differently…

    Thanks and best regards,
    Michael

    #1062602
    George
    Participant

    Hey Michael,

    Sorry to hear about this – I’m afraid to admit that this may be an insurmountable bug that arises from using the gettext filters in this way. But to test and confirm this, can you share your exact rendition of that code with me?

    The way to do this is to copy and paste all of your custom code into a Gist at http://gist.github.com

    Then, share a link to that Gist here with me and I’ll check it out.

    Also, out of curiosity, what is the language you have translated your site into other than English? This could be relevant here; perhaps there’s an issue with that language’s .mo or .po files that is a factor in this.

    Thank you!
    George

    #1062865
    Michael
    Participant

    Hi George,

    Sure, here you go (it’s nearly identical with the code snippet in the article):
    https://gist.github.com/anonymous/3094fb5f0c2680b936f4

    My used language is german.

    Just an additional note: I used on line 8 the text domain “event-“, because I wanted to translate something in the “Event Tickets” plugin (as I found out here: https://theeventscalendar.com/support/forums/topic/replacing-the-word-tickets-into-admit-card/ ).

    But the problem also appears when I use only the “tribe-” text domain. Furthermore, in this case I’m not even able to change the text anymore (doesn’t matter if I try to change the english or german text, for example “Veranstaltungsort” or “Venue” to something else).

    Btw: The test site is here (“RSVP” translated to “Platz reservieren”): http://wp-dev.snack-it.ch/event/mein-test-event-1/

    Thanks and best regards,
    Michael

    #1063238
    George
    Participant

    Hey Michael,

    Thanks for sharing this. I have confirmed that I, too, get the same bug here.

    I was able to get string replacement working fine with a simpler version of the code as follows:


    function tribe_custom_theme_text( $translations, $text, $domain ) {

    if ( 'RSVP' == $translations ) {
    $translations = 'Platz reservieren';
    }

    return $translations;
    }

    add_filter( 'gettext', 'tribe_custom_theme_text', 999, 3 );

    This will change all cases of the word ‘RSVP’ to ‘Platz reservieren’.

    Try this out and let me know if it helps!

    — George

    #1063786
    Michael
    Participant

    Hi George,

    So far it looks like it works perfectly 🙂

    Thank you very much for the solution!

    Best regards,
    Michael

    #1064476
    George
    Participant

    Nice! Glad to help – I’ll close up this thread for now but please come back and open a new one any time if other issues arise 🙂

    Cheers,
    George

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Replacing a word/string with filter resets the translation from DE to EN’ is closed to new replies.