Jump to:

7935 Posts in 1536 Topics by 943 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: 568 Views
  • Pipifix
    Avatar
    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

    <?php
    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(
           'Photo.CMSThumbnail.Tag',
          '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
    Avatar
    4085 Posts

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

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

    568 Views
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.