wordpress, atahualpa, xLanguage and widget titles translation
My site is implemented in wordpress. I use the very nice atahualpa theme from bytesforall and a special plugin for multilingual websites, xLanguage from Sam Wong.
Multilingual support is very important for many people and I hope wordpress will support directly multilingual sites in the future. Currently xLanguage is the best approach in my opinion and I have tried most -if not all- multilingual wordpress plugins.
Of course nothing is perfect and the atahualpa and xLanguage combination do not escape from this rule. There are some small problems when you use them together, some titles (widget titles for example) do not get translated. The fix is considered simple but if you have no knowledge of php or coding in general it will give you a hard time. This is especially true since nobody has posted a solution on the internet. As my moto goes,if it isn’t on the internet then someone should put it there , I will give you an example of how I fixed this for the BFA Recent Comments widget as can be seen at my home page.
The Fix
It all starts with a “light” read – you can skip it though. Sam Wong explains at his blog how you can add xLanguage support to themes and widgets that do not work out the box. Just rollover to the widget title customization section.
You may have noticed that the easy way (adding hooks from your site’s admin panel) does not work. We have to go for the second easiest way and that includes a text editor. Yay!
I will show you how to do it for the BFA Recent Comments widget and hopefully you will manage to do it for the rest of your widgets.
First you have to find where the php function file for the widget you want to fix rests. This is easy. Just look in the functions directory in atahualpa’s catalog. In your wordpress installation that would be:
_wordpress_directory_ /wp-content/themes/atahualpa/functions
The file we need is not surpisingly called bfa_recent_comments.php. If you manage your site remotely just download the file to your computer. Also now would be a good time to back up this file, just in case.
Open bfa_recent_comments.php with your text editor. It is php code alright but no need to get alarmed. Move down until you reach the section with the Fetch our parame ters comment. This is for my version at line 61. After that some variables assignments take place. What we are interested in is the __$bfa_rc_title variable. In this variable our widget title is stored. Had we opened the bfa_popular_posts.php file which implements the BFA Popular Posts widget, the variable we would look for would be $bfa_pp_title so I hope you get the point.
The critical line looks like this:
$bfa_rc_title = $bfa_rc_options['bfa_rc_title'];
What we need to do is to apply the localization filter as Sam Wong describes at his site. Just change the line to look like this:
$bfa_rc_title = apply_filters('localization',$bfa_rc_options['bfa_rc_title']);
That’s it! Save the file and upload it to your site (if needed) to replace the original one. Now your BFA Recent Posts widget title supports xLanguage translation!