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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Translate SiteTree context menu??


Go to End


2 Posts   966 Views

Avatar
martimiz

Forum Moderator, 1391 Posts

2 February 2011 at 10:43pm

Hi all,

Has anyone found a proper way to translate the SiteTree context menu - the popup you get when right-clicking the CMS Sitetree?

It's the TreeContextMenu = {... } bit in the /cms/javascript/CMSMain_left.js. Using the ss.i18n._t( ... ) method is not an option, I hope someone has thought of some workaround besides hacking the code directly?

Thanks,
Martine

Avatar
martimiz

Forum Moderator, 1391 Posts

4 March 2011 at 7:25am

For anyone who's still interested: it can't be done properly . The menutext is hardcoded into the CMSMain_left.js file (around line 665) - in the indexvalues of the TreeContextMenu array. These indexvalues are then used in the LeftAndMain.js createContextMenu() function to create the contextmenu's innerHTML...

So my suggestion would be:

- replace the readable text indexvalues by something more 'symbolic' in cms/javascript/CMSMain_left.js around line 665

- translate them in cms/javascript/LeftAndMain.js around line 825 using something like translatedMenuItemName = ss.i18n._t('CONTEXTMENU.' + menuItemName, menuItemName);

- provide proper translations in cms/javascript/lang/en_US.js ao

Cheers, Martine

(Now if only I remembered how to properly do a patchfile )