Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Translate the name of a dataobject (DOM)

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 582 Views
  • Pipifix
    Community Member
    54 Posts

    Translate the name of a dataobject (DOM) Link to this post

    Hi guys,

    I've got a simple staffmember dataobject. evrything works fine. But my client wantet the labels and vlaues to be translated. It's possible to get the atributes of the do translated by the static $field_label function. The DOM is translated by a single line in the _config.php (i18n::include_locale_file('dataobject_manager', 'de_DE');) . But there is a question left: How to translate the name of the dataobject itself? In the Backend, on the DOM, the "Add Staffmember" button should show "Mitarbeiter hinzufügen".

    My code

    class StaffMember extends DataObject
       static $db = array (
          'Anrede' => "Enum('Herr, Frau')",
          'Vorname' => 'Varchar(100)',
          'Name' => 'Varchar(255)',
          'Role' => 'Varchar(100)',
          'Phone' => 'Varchar(50)',
          'Mail' => 'Varchar(50)',
          'Location' => "Enum('Weißenfels, Zwickau')",
          'Description' => 'Text',
          'IsActive' => 'Boolean',
          'ShowOnContactPage' => 'Boolean'
       //1:n Beziehungen -> Staffmember hat eine Seite und ein Portraitbild
       static $has_one = array (
          'StaffPage' => 'StaffPage',
          'Photo' => 'Image'
       //Standardwerte für die Dropdowns im DOM   
       static $defaults = array(
    'Anrede' => 'Herr',
    'Location' => 'Weißenfels',
    'IsActive' => 'true',
    'ShowOnContactPage' => 'false'

       //Fields to show in the DOM
       //Todo checkbox in DOM für Anzeige auf der Kontaktseite
       static $summary_fields = array(
          'Vorname' => 'Vorname',
          'Name' => 'Name',
          'Location' => 'Location',
          'IsActive' => 'IsActive',
          'ShowOnContactPage' => 'ShowOnContactPage'
       static $field_labels = array(
          'StaffMember' => 'Mitarbeiter',
          'Role' => 'Stellenbeschreibung',
          'Phone' => 'Telefon',
          'Mail' => 'Mailadresse',
          'Location' => 'Zweigstelle',
          'Description' => 'Mitarbeiteraussage',
          'IsActive' => 'aktiver Mitarbeiter',
          'ShowOnContactPage' => 'Kontaktseitenanzeige',



    Thanks for your help. Pipifix

  • UncleCheese
    4085 Posts

    Re: Translate the name of a dataobject (DOM) Link to this post

    You can use $yourDOM->setAddTitle(_t('MyTranslation'));

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.