Having trouble changing text strings

Home Forums Calendar Products Events Calendar PRO Having trouble changing text strings

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1132212
    tobak
    Participant

    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?

    #1132390
    Cliff
    Member

    Hi 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.

    #1133355
    tobak
    Participant

    Hi!

    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.
    #1133413
    Cliff
    Member

    Just 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?

    #1133865
    tobak
    Participant

    Yes, 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.

    #1133894
    Cliff
    Member

    Could 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:

    #1134378
    tobak
    Participant

    <?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.

    #1135134
    Cliff
    Member

    Tobak, 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.

    #1135361
    tobak
    Participant

    Yes, 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.

    #1135362
    tobak
    Participant

    This reply is private.

    #1135729
    Cliff
    Member

    I 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.

    #1135890
    tobak
    Participant

    At 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?

    #1136270
    Cliff
    Member

    Sorry 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.

    #1142501
    Support Droid
    Keymaster

    This 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.

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Having trouble changing text strings’ is closed to new replies.