Home › Forums › Additional Help › Translations › Translation not working
- This topic has 6 replies, 3 voices, and was last updated 7 years, 8 months ago by Support Droid.
-
AuthorPosts
-
July 15, 2016 at 3:13 am #1140222Marlene HasselParticipant
I followed the instructions and put the translation files in the lang folder, but it’s still in english.
July 15, 2016 at 5:34 am #1140237NicoMemberHowdy 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,
NicoJuly 15, 2016 at 5:49 am #1140240Marlene HasselParticipantI’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.
July 15, 2016 at 6:50 am #1140254NicoMemberThanks 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,
NicoJuly 27, 2016 at 5:59 am #1144546Marlene HasselParticipantI 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”July 27, 2016 at 8:12 am #1144632NicoMemberThanks 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,
NicoAugust 18, 2016 at 9:35 am #1153164Support 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 ‘Translation not working’ is closed to new replies.