I have correctly created a custom widget, evreything is translating well with a correct .po file, except the title.
Here is my code :
$concert_widget_name = __('Tour Dates', 'concerts');
wp_register_sidebar_widget (
'tourdates', // your unique widget id
$concert_widget_name, // widget name
'tourdates_widget_display', // callback function to display widget
array( // options
'description' => 'Displaying upcoming tour dates'
)
);
Is there an error ? An other way to translate the widget name ?
I usually register my widgets using the register_widget function. In the constructor of the widget class I place the following code:
You can also check out the Widgets API on the WordPress Codex site. Hopefully this helps you in creating your custom widget.
Also what I usually do is merge my translations with the default ones loaded from WordPress, like so:
This code looks similar to the
load_textdomain
function from WordPress but it avoids all the filters that do exist in the original function, which helps in avoiding any WordPress hook from altering your$domain
and$mofile
variables.But I will leave that up to you. Maybe the
load_textdomain()
function from WordPress will work just as fine, but in case it doesn’t this function should do the trick.Now if your using the
loadTextDomain()
function I pasted above you can just place alanguages
folder in the same folder as yourfunctions.php
resides, in that new folder you could placetheme.nl_NL.mo
ortheme.de_DE.mo
files depending on the language your using. This should allow translation of your website and also the admin area.