Home › Forums › Calendar Products › Events Calendar PRO › Replacing a word/string with filter resets the translation from DE to EN
- This topic has 5 replies, 2 voices, and was last updated 8 years, 3 months ago by George.
-
AuthorPosts
-
January 26, 2016 at 7:04 am #1062499MichaelParticipant
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,
MichaelJanuary 26, 2016 at 9:02 am #1062602GeorgeParticipantHey 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!
GeorgeJanuary 27, 2016 at 1:53 am #1062865MichaelParticipantHi George,
Sure, here you go (it’s nearly identical with the code snippet in the article):
https://gist.github.com/anonymous/3094fb5f0c2680b936f4My 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,
MichaelJanuary 27, 2016 at 9:42 am #1063238GeorgeParticipantHey 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
January 28, 2016 at 6:12 am #1063786MichaelParticipantHi George,
So far it looks like it works perfectly 🙂
Thank you very much for the solution!
Best regards,
MichaelJanuary 29, 2016 at 7:15 am #1064476GeorgeParticipantNice! 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 -
AuthorPosts
- The topic ‘Replacing a word/string with filter resets the translation from DE to EN’ is closed to new replies.