Support

Home Forums Event Espresso Premium WPML integration

WPML integration

Posted: July 3, 2013 at 2:43 am


Noomia

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 πŸ™‚ ?

  • This topic was modified 10 years, 10 months ago by  Noomia.


Dean

July 3, 2013 at 3:11 am

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/


Noomia

July 3, 2013 at 3:37 am

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…


Dean

July 3, 2013 at 3:58 am

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.

http://codex.wordpress.org/Multilingual_WordPress


Noomia

July 3, 2013 at 5:25 am

Hi,

I can not consider an other plugin. Because WPML is much more complete and offer more possibilities…


Noomia

July 3, 2013 at 5:28 am

It could word if the event was a custom post type… Cause WPML can manage the custom post type to be multilangual…


Dean

July 3, 2013 at 5:33 am

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/


Noomia

July 3, 2013 at 5:40 am

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…


Dean

July 3, 2013 at 6:07 am

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.


Noomia

July 3, 2013 at 6:30 am

give it the Espresso Events template

What do you mean ?
I want my single event custom post type to be displayed on one page


Dean

July 3, 2013 at 6:42 am

Sorry, I misunderstood. Did you refresh your permalinks? (Go to Permalinks and just save)


Noomia

July 3, 2013 at 6:44 am

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 ?


Dean

July 3, 2013 at 7:14 am

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


Noomia

July 4, 2013 at 2:02 am

Hi,

It’s ok for that part. But how could I translate the labels of the registration form ?


Josh

  • Support Staff

July 5, 2013 at 8:46 am

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( '&#039;', "'", __($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/


Noomia

July 10, 2013 at 6:32 am

Hi !

This unfortunately don’t work…


Josh

  • Support Staff

July 10, 2013 at 8:05 am

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.


Noomia

July 10, 2013 at 8:19 am

What I did :

1) Replace line 34 of form-build.php by
$label = '<label for="' . $XATT1 . $field_name . $XATT2 . '" class="' . $class . '">' . trim( stripslashes( str_replace( ''', "'", __($question->question) ))) . $required_label . '</label> ';

2) Copy the entire function in custom_functions.php

3) Goes to WPML string translation : can’t find the string…


Noomia

July 10, 2013 at 8:20 am

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
        &#039;First Name&#039; =&gt; &#039;Blammo&#039;,
7
        // Add some more strings here
8
    );
9
  
10
    // See if the current string is in the $strings array
11
    // If so, replace it&#039;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 = &amp;get_translations_for_domain( $domain );
16
        $translated = $translations-&gt;translate( $strings[$original] );
17
    }
18
  
19
    return $translated;
20
}
21
  
22
add_filter( &#039;gettext&#039;, &#039;mycustom_filter_gettext&#039;, 10, 3 );</code>

in my function.php ?


Josh

  • Support Staff

July 10, 2013 at 8:33 am

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/


Noomia

July 10, 2013 at 8:41 am

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
icl_register_string('event espresso', 'Last Name', 'Last Name');

2) In the custom_functions.php, I replaced this
$label = '<label for="' . $XATT1 . $field_name . $XATT2 . '" class="' . $class . '">' . trim( stripslashes( str_replace( ''', "'", $question->question ))) . $required_label . '</label> ';
by this
$label = '<label for="' . $XATT1 . $field_name . $XATT2 . '" class="' . $class . '">' . trim( stripslashes( str_replace( ''', "'", icl_t('event espresso', $question->question, $question->question )))) . $required_label . '</label> ';

So I change $question->question by icl_t('event espresso', $question->question, $question->question )

3) I went to WPML -> String Translation and simply translated my labels πŸ™‚

Thank you, I hope this can help other people πŸ™‚ !


Josh

  • Support Staff

July 10, 2013 at 8:48 am

That’s a good one. Thanks for sharing.


Noomia

July 10, 2013 at 8:53 am

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 πŸ™‚


Noomia

July 10, 2013 at 8:57 am

I figured it out by myself πŸ™‚

Thank you for your great support πŸ™‚


Noomia

July 10, 2013 at 9:05 am

Ahah new question !

I can’t find where is the “Registration Details” h3 …


Josh

  • Support Staff

July 10, 2013 at 9:05 am

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.


Josh

  • Support Staff

July 10, 2013 at 9:07 am

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.

Event Espresso