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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

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

[ask] different widget title in each language?


Go to End


8 Posts   2626 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, 1899 Posts

18 January 2012 at 4:58am

Edited: 18/01/2012 7:55am

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, 1899 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, 1899 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.