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.

Widgets /

Discuss SilverStripe Widgets.

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

Using i18n in widgets (subclass of Widget) or widget extensions (subclass of DataExtension)

Go to End



Community Member, 26 Posts

6 November 2013 at 9:53pm

Trying to get translations to work in widget. But get not the translation

Directory structure of the widget in the ss root is:

- widget_test
-- _config
--- TestWidget.yml
-- code
--- extension
---- TestWidgetExtension.php
--- model
---- TestWidget.php
-- lang
--- _manifest_exclude
--- de.yml
--- en.yml
-- templates
-- _config.php


<?php /* */ ?>


Example code of TestWidget.php:

function getCMSFields()
$fields = new FieldList(
new TabSet("GeneralTab",
$tabTemplate = new Tab(
$name = 'SubTab',
new HeaderField("filters", _t('FormFieldLabels.FILTERS', 'Filters')),
new HeaderField("sorting", _t('FormFieldLabels.SORTING', 'Sorting'))
$tabRequest = new Tab(
$name = 'RequestSettings'
$tabInfo = new Tab(
$name = 'InfoTab'

$tabTemplate->setTitle(_t('TabLabels.TEMPLATESETTINGS', "Template settings"));
$tabRequest->setTitle(_t('TabLabels.REQUESTSETTINGS', "Request settings"));
$tabInfo->setTitle(_t('TabLabels.INFOTAB', "Details"));

$this->extend('updateCMSFields', $fields);
return $fields;


Example code of TestWidgetExtension.php:

function updateCMSFields(FieldList $fields)
// Template settings
// - Filters
$fields->addFieldToTab('GeneralTab.SubTab', new NumericField("ResultStart", _t('FormFieldLabels.STARTROW', "STARTROW")), "sorting");


Example code of de.yml:
STARTROW: "Start at ..."


The NumericField is rendered, but the label is "STARTROW", instead it should be "Start at ..." Another problem is, that the values of the formfields don´t find their way to the database, but I already posted this in another topic (

Any idea could help!