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   1510 Views

Avatar
medoose

27 June 2010 at 1:05pm (Last edited: 18 January 2012 7:55am), Community Member, 3 Posts

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

23 July 2010 at 4:01am (Last edited: 18 January 2012 7:55am), Community Member, 83 Posts

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

18 January 2012 at 4:09am (Last edited: 18 January 2012 7:55am), Community Member, 82 Posts

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

thanks

Avatar
swaiba

18 January 2012 at 4:58am (Last edited: 18 January 2012 7:55am), Forum Moderator, 1796 Posts

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

Avatar
sajok

18 January 2012 at 5:15am (Last edited: 18 January 2012 7:55am), Community Member, 82 Posts

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

Avatar
swaiba

18 January 2012 at 6:35am (Last edited: 18 January 2012 7:55am), Forum Moderator, 1796 Posts

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

18 January 2012 at 7:51am (Last edited: 18 January 2012 7:55am), Community Member, 82 Posts

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

18 January 2012 at 7:55am (Last edited: 18 January 2012 7:55am), Forum Moderator, 1796 Posts

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.