Home › Forums › Calendar Products › Events Calendar PRO › Having trouble changing text strings
- This topic has 14 replies, 4 voices, and was last updated 7 years, 9 months ago by tobak.
-
AuthorPosts
-
June 27, 2016 at 4:41 am #1132212tobakParticipant
So I want to change some of the text strings in ECP, specifically I want to remove the string “Event Category”. I tried using this: https://theeventscalendar.com/knowledgebase/change-the-wording-of-any-bit-of-text-or-string, but had no success. Not only can I not change the string, the function also appears to reset the language of the details box to English.
I noticed $translations is called at the start of the script but not used otherwise. Is this inentional? Is this function even supposed to interact with translation at all?
June 27, 2016 at 9:14 am #1132390CliffMemberHi Tobak.
The code snippet at the article you linked to only targets “the-events-” text domains.
Event Tickets (ET) and ET+ have a text domain like “event-tickets”
If you swap that out in the snippet, it may work as you desire.
How to Override Plugin Language Files may be of interest to you as well.
Let me know how things go.
June 29, 2016 at 5:17 am #1133355tobakParticipantHi!
How do I determine what text domain a string of text belongs to?
The string in question is part of the “Details” box shown on single event pages. I tried altering one of the existing domains to “event-tickets” but that didn’t help either.Alternatively, is there a simple way to just remove this string? I originally intended to simply replace “Event Category” with nothing (blank), but it’s proving more difficult than I first thought.
- This reply was modified 7 years, 10 months ago by tobak.
June 29, 2016 at 7:48 am #1133413CliffMemberJust to confirm (because another user did the same thing), are you using the code snippet all the way at the bottom of that help article and not the ones in the middle of the text paragraphs?
June 30, 2016 at 3:28 am #1133865tobakParticipantYes, I’m using the code from the bottom of the page. It works for the standard examples included in the code, but I can’t get it to work on that specific string.
June 30, 2016 at 5:46 am #1133894CliffMemberCould you please provide me your full code snippet and specify where you put it?
Please also make sure all your Modern Tribe plugins (and WordPress core) are at their latest versions:
July 1, 2016 at 1:13 am #1134378tobakParticipant<?php
function tribe_custom_theme_text ( $translations, $text, $domain ) {
$custom_text = array(
‘Event Category’ => ‘test’,
);if( (strpos($domain, ‘tribe-‘) === 0 || strpos($domain, ‘the-events-‘) === 0 || strpos($domain, ‘event-‘) === 0) && array_key_exists($text, $custom_text) ) {
$text = $custom_text[$text];
}return $text;
}
add_filter(‘gettext’, ‘tribe_custom_theme_text’, 20, 3);I have tried with a bunch of other strings like Date, Time, Cost etc. Nothing seems to work except the default values in the example.
July 4, 2016 at 10:21 am #1135134CliffMemberTobak, Where are you placing this code?
If placing in your active theme’s functions.php file, you can remove the opening PHP tag.
If you use the code snippet as-is from the bottom of https://theeventscalendar.com/knowledgebase/change-the-wording-of-any-bit-of-text-or-string/ (but removing the opening PHP tag), does the word Venue change to Location on your site?
Once you get that part working, then you can try to customize things further for your needs.
July 5, 2016 at 1:59 am #1135361tobakParticipantYes, I place it in functions.php in my child theme. Like I said, the default examples appear to work. Can’t get it to work with any other strings.
It also removes any language customizations and reverts the text in the details box to English. Not sure if this is part of the deal or some other error I can’t identify. I’m also not sure if this is related to the first problem. I have tried calling the strings in both English and Danish but neither works.
July 5, 2016 at 2:02 am #1135362tobakParticipantThis reply is private.
July 5, 2016 at 2:40 pm #1135729CliffMemberI see the issue.
You’re trying to change the string “Event Category”, but that’s not a string that gets translated.
If you want to see all the strings that get translated, you can look at the plugin’s .pot file. You’ll see “Event Category” isn’t a full string there (even though it seems like it would be from what you can see on your site).
I hope this helps.
If you need further assistance, please list all the items you’re actually trying to customize and I may be able to provide additional guidance.
July 6, 2016 at 2:30 am #1135890tobakParticipantAt this point, I would be happy if I could simply hide (or otherwise get rid of) the string “Event Category”. Am I right in assuming that this is actually two strings? I can set “Event” to a different value, but “category” isn’t responding to my attempts.
And I still don’t understand why the entire Details box reverts to English because I’m trying to change a single string. Is it simply an effect of the code snippet I’m using or is something else going on?
July 6, 2016 at 2:35 pm #1136270CliffMemberSorry this is proving difficult for you. Yes, those are 2 separate strings.
You might want to try using that same function but on the ngettext_with_context hook instead (it’s worth a shot anyway).
Or you might enjoy using a plugin like Say What.
I hope this helps. Sorry this stuff isn’t more straight-forward.
If you end up not being able to figure it out, please provide the URLs at which you’re wanting the text changed and what you want it changed to.
July 21, 2016 at 9:35 am #1142501Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Having trouble changing text strings’ is closed to new replies.