Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

[ask] different widget title in each language?


Reply


8 Posts   1570 Views

Avatar
medoose

Community Member, 3 Posts

27 June 2010 at 1:05pm

Edited: 18/01/2012 7:55am

haloo...

how can i set widget title in different language?
as this far i can understand that each widget title is set from mysite/code/my_widget.php in line :

static $title = 'Widget Title';


my default site is indonesian, and I make it bilingual (Indonesian & English)
I want each widget title is automatically changed when I choose mysite.com/?locale=en_US

could it be possible?
(sorry for my bad english... ;D)

Avatar
lx

Community Member, 83 Posts

23 July 2010 at 4:01am

Edited: 18/01/2012 7:55am

Form the Blogmodul i used the SubscribeRSSWidget.
The Headline of the widget is 'Subscribe via RSS', because its defined in line 12.

static $title = 'Subscribe via RSS';

To get a german Widget-headline i put an additional function into blog/code/widgets/SubscribeRSSWidget.php
(maybe there is a better way without touching the original blogmodul files)

function Title() {
return _t("Widget.SUBSCRIBEVIARSS",self::$title);
}

So you need an entry in your language file, in my case:

$lang['de_DE']['Widget']['SUBSCRIBEVIARSS'] = "News als RSS-Feed";


in mysite/lang/de_DE

Avatar
sajok

Community Member, 82 Posts

18 January 2012 at 4:09am

Edited: 18/01/2012 7:55am

thanks for the hack..
since this is an old post, I'm wondering if you came up with a better solution?

thanks

Avatar
swaiba

Forum Moderator, 1799 Posts

18 January 2012 at 4:58am

Edited: 18/01/2012 7:55am

This is how I did it...
http://www.silverstripe.org/widgets-2/show/11375?start=8

Avatar
sajok

Community Member, 82 Posts

18 January 2012 at 5:15am

Edited: 18/01/2012 7:55am

how can I translate the widget title with the solution you provided?

Avatar
swaiba

Forum Moderator, 1799 Posts

18 January 2012 at 6:35am

Edited: 18/01/2012 7:55am

The same way the page title changes when using translatable is enabled - the widget will only show on the translated version of the widget - rather than the same widget for each page.

Avatar
sajok

Community Member, 82 Posts

18 January 2012 at 7:51am

Edited: 18/01/2012 7:55am

still there is no field in the cms where I can translate the blog widget title, and if you mean the language file for blog I just looked at it and there is no entry for the widget title as the title is hard coded.. can you explain to me how did you translate the blog widgets?

Avatar
swaiba

Forum Moderator, 1799 Posts

18 January 2012 at 7:55am

Edited: 18/01/2012 7:55am

ok, I'm sorry I have scanned this and given an answer as how to translate a widget which is what it appeared to be asking for - I don't use the blog module widget. Instead I will move this thread to that area since the question is actually more specfic.