WPML and styling support
WordPress Event Management, Calendars & Registration › Forums › Request A Feature › WPML and styling support
This topic contains 10 replies, has 3 voices, and was last updated by Stephen Harris 12 years, 8 months ago.
-
AuthorPosts
-
December 17, 2012 at 10:45 pm #2714
Hi Stephen,
Could you please wrap the widget titles in gettext calls to make them translatable in multilingual setups? For example, line 113 in class-eo-event-list-widget.php:
echo $before_title.esc_html(__($instance['title'],'eventorganiser')).$after_title;
In the same file, could you please wrap the start date and time in span tags (or else) and attribute some class for easier styling? Line 179:
$template = "<a title='%event_title_attr%' href='%event_url%'>%event_title%</a> "."".__('on','eventorganiser')." %start{{$date}}{{$time}}%"."";
Thanks!
Maxim
December 17, 2012 at 10:53 pm #2715Sure :). Might be a chance to introduce microformats (http://support.google.com/webmasters/bin/answer.py?hl=en&answer=164506).
Since these changes are minor will try to get them in for 1.6.2
Stephen Harris
December 17, 2012 at 11:19 pm #2716Cool, that would be great! 😉
postrel
December 17, 2012 at 11:35 pm #2717Also – you can replace the default template using the template field,,,
(In 1.7 I’m planning on adding an alternative – a dropdown where you can select a template file)
Stephen Harris
December 17, 2012 at 11:51 pm #2721Thanks for the hint! Do you mean I can place the template files (such as archive-event.php) in my theme folder? But it doesn’t work for widget templates, does it?
postrel
December 18, 2012 at 12:02 am #2724That’s right – for the widget you use a template place holder.
But the idea is that I’ll be adding a drop-down that will list template files specifically designed for the widget. The plugin will come with some default templates, and these too will be able to be copied into your theme and edited. You’ll also be able to add your own additional templates into the theme. (e.g. you may want one widget to list events in a table, another in a list, and yet another which involves some form of complex logic).
The ‘placeholder’ option will still be available since not everyone will feel up to manipulating template files.
Stephen Harris
December 18, 2012 at 12:06 am #2725Maxim,
I’ve just noticed what you’ve meant by passing titles through gettext calls. You can’t do the following:
__($instance['title'])
you can only pass strings to the gettext functions and not variables… (see http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/)
Stephen Harris
December 18, 2012 at 12:21 am #2726Well, it works fine for me using WPML and their String Translation tool. You should not pass variables to the gettext functions if you aim at an automatic translation (or internationalisation). But if you pick up the strings manually, why not?
postrel
December 18, 2012 at 1:15 am #2727How would you translate it when passing through gettext? Are you using a filter somewhere to change the content depending on the language set? If so, I could apply the filter
widget_title
(I probably should do anyway)? You can also filter the$instance
array atwidget_display_callback
(https://github.com/WordPress/WordPress/blob/3.5/wp-includes/widgets.php#L179). Either of these suffice?I’m concerned about passing a variable to gettext because of this line:
Bottom line: Inside all translation functions, no PHP variables are allowed in the strings, for any reason, ever. Plain single-quoted strings only.
I haven’t looked into what problems it could cause if I ignored that advice – but he puts it rather strongly.
Stephen Harris
December 18, 2012 at 1:42 am #2728Yes, the WPML plugin applies filters to change the content based on the language. I don’t really know now if either of your solutions will suffice, I’ll look into it. Please find in the attached image the way I’ve set up the event list widget.
postrel
December 19, 2012 at 1:25 am #2740Seems like applying
widget_title
would resolve this… http://wpml.org/faq/getting-string-translation-to-work/E.g.
echo $before_title.apply_filters('widget_title',$instance['title']).$after_title;
Does that work?
Stephen Harris
-
AuthorPosts
The forum ‘Request A Feature’ is closed to new topics and replies.