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.

General Questions /

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

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

Translate SiteTree context menu??


Reply


2 Posts   680 Views

Avatar
martimiz

Forum Moderator, 1107 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, 1107 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 )