Posted: July 3, 2013 at 2:43 am
|
Hi ! I have event espresso and WPML. My question is pretty simple… How could I make my event (and registration form) translatable π ?
|
|
Hi, Event Espresso has no WPML integration. That being said it should translate the plugin as we use (except in rare situations) the standard WordPress system for allowing text strings to be translated. There was a discussion about this here https://eventespresso.com/topic/translating-events-wpml-intergration/ |
|
Hi ! Ok but how can I translate my event description etc ??? WPML is the best WP plugin for multilanguage, I think it could be great to do something with them… |
|
Hi, I am not sure if it is possible to translate the text like that with WPML. We are considering adding multi-lingual support but it will not even be considered until 4.0 is release and stable and the same with add ons. You could perhaps try QTranslate or another plugin or set up. |
|
Hi, I can not consider an other plugin. Because WPML is much more complete and offer more possibilities… |
|
It could word if the event was a custom post type… Cause WPML can manage the custom post type to be multilangual… |
|
That will be available in 4.0 onwards as standard. You could use the Custom Post type system built into 3.1.X to display events. https://eventespresso.com/wiki/custom-post-types-basic-setup/ |
|
Oh ok I’ve just seen this feature. It could be enough to work with WPML in fact. I’ve set up the custom post type to “Espresso Event” (which was there by default ? I didn’t create it). So I have a “Event Posts” menu in WP admin and my event is listed in the listing table. But If I edit this post in the “Espresso Event”, save it, then click on the “View Events” button, it show me http://mydomain.com/myevent/ instead of http://mydomain.com/events/myevent/ . And this one is the original one, not the modified one… |
|
Hi, The basic usage is to create or edit an event and at the bottom make sure “Add/Update post for this event?” is set to yes and the post type is Events. This will create a duplicate of the event but as a custom post type. Then create a page and give it the Espresso Events template. Now when you go to that page it will list the custom post types. As mentioned 4.0 will work with custom post types by default. |
|
What do you mean ? |
|
Sorry, I misunderstood. Did you refresh your permalinks? (Go to Permalinks and just save) |
|
Ok it’s working now, but I only have the content of the event on my page. How could I have all the informations like a normal event page ? I want to use the registration_page_display.php, don’t want to re-code everything again… Not possible ? |
|
If you have the single-espresso_event.php file in your theme folder it should show the registration form, unless you have hidden that form in the event itself (they are linked). |
|
Hi, It’s ok for that part. But how could I translate the labels of the registration form ? |
Hi Noomia, I can’t say for 100% that this will work because I do not have a copy of WPML to test, but you can make the labels run through gettext by changing line 34 of event-espresso/includes/funcitons/form-build.php to read like this: $label = '<label for="' . $XATT1 . $field_name . $XATT2 . '" class="' . $class . '">' . trim( stripslashes( str_replace( ''', "'", __($question->question) ))) . $required_label . '</label> '; basically what the above is doing is changing $question->question to __($question->question) Then you can copy the entire function to /wp-content/uploads/espresso/custom_functions.php to keep it from getting overwritten on an update. See https://eventespresso.com/wiki/custom-files-addon/ for more info on the custom files add-on. Then you should be able to use WPML’s String Translation feature to translate the labels on the registration form: http://wpml.org/documentation/getting-started-guide/string-translation/ |
|
|
Hi ! This unfortunately don’t work… |
Can you outline what was tried here? The code that I posted was tested to work with the gettext filter. So what I did to test it was run a function like this: function mycustom_filter_gettext( $translated, $original, $domain ) { // This is an array of original strings // and what they should be replaced with $strings = array( 'First Name' => 'Blammo', // Add some more strings here ); // See if the current string is in the $strings array // If so, replace it's translation if ( isset( $strings[$original] ) ) { // This accomplishes the same thing as __() // but without running it through the filter again $translations = &get_translations_for_domain( $domain ); $translated = $translations->translate( $strings[$original] ); } return $translated; } add_filter( 'gettext', 'mycustom_filter_gettext', 10, 3 ); Which changed the “First Name” string to be “Blammo”. So if WPML uses gettext for its string translation feature it should be good to go. |
|
|
What I did : 1) Replace line 34 of form-build.php by 2) Copy the entire function in custom_functions.php 3) Goes to WPML string translation : can’t find the string… |
|
Do I have t put that <code>function mycustom_filter_gettext( $translated, $original, $domain ) { 2 3 // This is an array of original strings 4 // and what they should be replaced with 5 $strings = array( 6 'First Name' => 'Blammo', 7 // Add some more strings here 8 ); 9 10 // See if the current string is in the $strings array 11 // If so, replace it's translation 12 if ( isset( $strings[$original] ) ) { 13 // This accomplishes the same thing as __() 14 // but without running it through the filter again 15 $translations = &get_translations_for_domain( $domain ); 16 $translated = $translations->translate( $strings[$original] ); 17 } 18 19 return $translated; 20 } 21 22 add_filter( 'gettext', 'mycustom_filter_gettext', 10, 3 );</code> in my function.php ? |
What that will do is translate the label all the time. I think what you’re looking to do is serve a different translation via WPML, which is only translating it some of the time. What you might need to do is add your question label translations to the .mo/.po files and modify the question label code so it has a text domain argument. Please see these WPML guides for more details: http://wpml.org/documentation/getting-started-guide/theme-localization/ http://wpml.org/documentation/support/troubleshooting-string-localization/ |
|
|
I succeeded π ! I used the “Method 2” explained there : http://wpml.org/faq/getting-string-translation-to-work/ So… 1) in function.php, I declared all my labels like this 2) In the custom_functions.php, I replaced this So I change 3) I went to WPML -> String Translation and simply translated my labels π Thank you, I hope this can help other people π ! |
That’s a good one. Thanks for sharing. |
|
|
Last one : I have a few checkboxes, my the name of each checkboxes (answer) is not translated because I only type icl_t(‘event espresso’, $question->question, $question->question ) for the labels… Where do I have to add this for the checkboxes themselves ? Thanks π |
|
I figured it out by myself π Thank you for your great support π |
|
Ahah new question ! I can’t find where is the “Registration Details” h3 … |
You’re welcome. I was going to say it’s probably down in the block below where it says: case "MULTIPLE" : but I’m glad you’ve got it sorted. |
|
Registration Details is in /templates/registration_page_display.php ~ line 201. |
|
The support post ‘WPML integration’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.