I explored the events plugin (from https://github.com/pixelandtonic/Events) and I understand the most of that. Now I will try to make the events localized.

The Event itself has no localized field, just the fieldLayout fields. Do I have to save a second record in the event db or did I just have to save the element with the corresponding locale id?

Can you give me a hint what steps are needed that I can edit them in two languages?

So far, I load an existing event

craft()->elements->getElementById($eventId, 'Events_Event', $locale);

with the new locale parameter and create the edit form, putting the locale as hidden field to the form ('de' instead 'en'). The fieldLayout fields are showing the 'de'-icon above the input fields.

When I try to save it, I pass through the locale in the $event variable to craft()->elements->saveElement($event)

I do not pass it to the $eventRecord because the $eventRecord itself didn't have a locale.

The event will be saved, just not in 'de' but in 'en'.

Do I have to tell the elementtype or the model that it can be localized to make it work?

1 Answer 1


I got it. I added this function to the Event_ElementType

public function isLocalized()
    return true;

This adds a language selector to your event index.

Then I enhanced the locale to the URL in getCpEditUrl() of the EventModel:

$locale = (craft()->isLocalized() && $this->locale != craft()->language) ? '/' . $this->locale : '';
return UrlHelper::getCpUrl('events/'.$calendar->handle.'/'.$this->id . $locale );

The additional route for the locale edit form is like this:

events/(?P<calendarHandle>{handle})/(?P<eventId>\d+)/(?P<locale>[-\w\.*]+)' => array('action' => 'events/editEvent')
  • phaetons, I am trying to create a localized ElementType myself. I followed much of what you mentioned here, and it'll let me edit in various languages using the ElementType picker. However, the only changes that are saved localized are the Title. Any custom fields are always globally changed. Any pointers? Or better yet, post your modified Events plugin code to GitHub? Dec 14, 2015 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.