2
votes

I'm trying to translate a custom ModelAdmin menu title as such:

private static $menu_title = _t('CMS.MyModelAdmin', 'My Model Admin');

This results in a 500 error, whereas a static string works without issues. I'm not sure why since I assumed this variable isn't a database entry.

How can you translate the menu title, preferably using _t?

1

1 Answers

4
votes

I've not translated V3, however looking at...

http://api.silverstripe.org/3.1/source-class-LeftAndMain.html#665

$title = _t("{$menuItem->controller}.MENUTITLE", $defaultTitle);

This would indicate to me that if you have a string defined along with the other lang strings in the YML format like this (but for all required languages)...

mysite\lang\en_GB.yml

en_GB:
  MyAdmin:
    MENUTITLE: 'MyTitle'

(where "MyAdmin" is the name of the "class MyAdmin extends ModelAdmin...")