From d9c672f724ce8520df894fc5c7dbe03001be4e5b Mon Sep 17 00:00:00 2001
From: Wouter Wolters <typo3@wouterwolters.nl>
Date: Tue, 16 Feb 2016 20:48:30 +0100
Subject: [PATCH] [TASK] Make text translatable in ShortcutMenu JavaScript

Resolve the todo's for translations and notification.

Resolves: #73505
Releases: master, 7.6
Change-Id: I43cb48fcd7efeb388ed5c54c9df7464ee4e0472d
Reviewed-on: https://review.typo3.org/46728
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
---
 .../Backend/ToolbarItems/ShortcutToolbarItem.php   |  8 ++++++++
 .../Public/JavaScript/Toolbar/ShortcutMenu.js      | 14 ++++++++------
 typo3/sysext/lang/locallang_core.xlf               | 12 ++++++++++++
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php
index d6c64398479f..7af80d89725a 100644
--- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php
+++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php
@@ -102,6 +102,14 @@ class ShortcutToolbarItem implements ToolbarItemInterface
         $this->shortcuts = $this->initShortcuts();
 
         $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/ShortcutMenu');
+        $languageService = $this->getLanguageService();
+        $this->getPageRenderer()->addInlineLanguageLabelArray([
+            'bookmark.delete' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarksDelete'),
+            'bookmark.confirmDelete' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.confirmBookmarksDelete'),
+            'bookmark.create' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.createBookmark'),
+            'bookmark.savedTitle' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarkSavedTitle'),
+            'bookmark.savedMessage' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarkSavedMessage'),
+        ]);
     }
 
     /**
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js
index 6f917db1ef49..b2ff220a4568 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js
@@ -16,7 +16,11 @@
  * shortcut menu logic to add new shortcut, remove a shortcut
  * and edit a shortcut
  */
-define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Icons'], function($, Modal, Icons) {
+define(['jquery',
+		'TYPO3/CMS/Backend/Modal',
+		'TYPO3/CMS/Backend/Icons',
+		'TYPO3/CMS/Backend/Notification'
+	], function($, Modal, Icons, Notification) {
 	'use strict';
 
 	/**
@@ -75,7 +79,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Icons'], functio
 			type: 'post',
 			cache: false
 		}).done(function(data) {
-			// @todo: we can evaluate here, but what to do? a message?
+			Notification.success(TYPO3.lang['bookmark.savedTitle'], TYPO3.lang['bookmark.savedMessage']);
 			ShortcutMenu.refreshMenu();
 		});
 	};
@@ -86,8 +90,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Icons'], functio
 	 * @param {Object} $shortcutRecord
 	 */
 	ShortcutMenu.deleteShortcut = function($shortcutRecord) {
-		// @todo: translations
-		Modal.confirm('Delete bookmark', 'Do you really want to remove this bookmark?')
+		Modal.confirm(TYPO3.lang['bookmark.delete'], TYPO3.lang['bookmark.confirmDelete'])
 			.on('confirm.button.ok', function() {
 				$.ajax({
 					url: TYPO3.settings.ajaxUrls['shortcut_remove'],
@@ -122,8 +125,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Icons'], functio
 	 */
 	ShortcutMenu.createShortcut = function(moduleName, url, confirmationText, motherModule, shortcutButton, displayName) {
 		if (typeof confirmationText !== 'undefined') {
-			// @todo: translations
-			Modal.confirm('Create bookmark', confirmationText)
+			Modal.confirm(TYPO3.lang['bookmark.create'], confirmationText)
 				.on('confirm.button.ok', function() {
  					var $toolbarItemIcon = $(ShortcutMenu.options.toolbarIconSelector, ShortcutMenu.options.containerSelector),
 						$existingIcon = $toolbarItemIcon.clone();
diff --git a/typo3/sysext/lang/locallang_core.xlf b/typo3/sysext/lang/locallang_core.xlf
index 56e07f3ee5a6..e5c7791fbc2d 100644
--- a/typo3/sysext/lang/locallang_core.xlf
+++ b/typo3/sysext/lang/locallang_core.xlf
@@ -1173,6 +1173,18 @@ Do you want to refresh it now?</source>
 			<trans-unit id="toolbarItems.bookmarksDelete">
 				<source>Delete bookmark</source>
 			</trans-unit>
+			<trans-unit id="toolbarItems.confirmBookmarksDelete">
+				<source>Do you really want to remove this bookmark?</source>
+			</trans-unit>
+			<trans-unit id="toolbarItems.createBookmark">
+				<source>Create bookmark</source>
+			</trans-unit>
+			<trans-unit id="toolbarItems.bookmarkSavedTitle">
+				<source>Bookmark saved</source>
+			</trans-unit>
+			<trans-unit id="toolbarItems.bookmarkSavedMessage">
+				<source>The bookmark was saved.</source>
+			</trans-unit>
 			<trans-unit id="toolbarItems.search">
 				<source>Search</source>
 			</trans-unit>
-- 
GitLab