Translation not working

Home Forums Additional Help Translations Translation not working

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1140222
    Marlene Hassel
    Participant

    I followed the instructions and put the translation files in the lang folder, but it’s still in english.

    #1140237
    Nico
    Member

    Howdy Marlene,

    Welcome to our support forums and thanks for reaching out to us!

    Can you please let me know which language you are trying to use? Are you trying to override the default translation?

    In case you are just trying to switch the site language there’s no need to download and move the translation files, just setting the appropriate language in WP-Admin > Settings > General should do the trick.

    Best,
    Nico

    #1140240
    Marlene Hassel
    Participant

    I’m trying to change it to swedish.
    The wordpress site is set to swedish, but the ticket thing is in english.

    I also tried the “Change the wording of any bit of text or string” thing, but that didn’t do anything either.

    #1140254
    Nico
    Member

    Thanks for following up!

    Seems that some of those strings are untranslated in Swedish (Confirm RSVP for example). Just to be clear are you seeing a mix of translated and untranslated string? I see ‘E-mail’ is getting printed as ‘E-post’, no sure if that’s coming from the Swedish translation or if it’s a customization you made.

    The snippet in this article works for me, try pasting the code below in your theme (or child theme) functions.php file:

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

    $custom_text = array(
    'Confirm RSVP' => 'Book',
    );

    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);

    Best,
    Nico

    #1144546
    Marlene Hassel
    Participant

    I tried adding that code to my functions, but all it did was change the dashboard back to english.

    I have found that I can translate some things manually by changing the the-events-calendar-sv_SE.po and compiling a new .mo, but some things just won’t change.

    For example, I’m trying to change “Event Category” to “Kategori”.
    I can change the word “Event” but not “Category”

    #1144632
    Nico
    Member

    Thanks for the follow-up Marlene! Thanks for pointing out the issue with the snippet, we just fixed it in the original knowledge base article: Change the wording of any bit of text or string. It should work as expected now, try the following code:

    /* override translation strings */
    function tribe_custom_theme_text ( $translation, $text, $domain ) {

    /* sample spanish translations */
    $custom_text = array(
    'Event' => 'Evento',
    'Events' => 'Eventos',
    '%s Categories' => 'Categorias de %s',
    'Confirm RSVP' => 'Confirmar reserva',
    );

    // If this text domain starts with "tribe-", "the-events-", or "event-" and we have replacement text
    if( (strpos($domain, 'tribe-') === 0 || strpos($domain, 'the-events-') === 0 || strpos($domain, 'event-') === 0) && array_key_exists($translation, $custom_text) ) {
    $translation = $custom_text[$translation];
    }

    return $translation;
    }
    add_filter('gettext', 'tribe_custom_theme_text', 20, 3);

    Some translations like ‘Event Categories’ use a placeholder for the event part, so that string can be translated one time and be used in multiple places. Generally finding the part where the code outputs the strings helps to see this!

    Please give the code a try and let me know if it works for you,
    Best,
    Nico

    #1153164
    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 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Translation not working’ is closed to new replies.