Skip to content

Commit ba7db3b

Browse files
ZeegaanNikolaj Geisleelit0451
authored
v9: Use localization keys instead of hardcoded string (#11406)
* Update help.controller.js * updated with better localization keys * Added more translations * Fixed spelling mistakes * Updated help.controller.js according to review * Fix localizaMany to include another call * Cleanup Co-authored-by: Nikolaj Geisle <[email protected]> Co-authored-by: Elitsa Marinovska <[email protected]>
1 parent 1359eb8 commit ba7db3b

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
(function () {
23
"use strict";
34

@@ -13,6 +14,12 @@
1314
vm.customDashboard = null;
1415
vm.tours = [];
1516
vm.systemInfoDisplay = false;
17+
vm.labels = {};
18+
vm.labels.copiedSuccessInfo = "";
19+
vm.labels.copySuccessStatus = "";
20+
vm.labels.copiedErrorInfo = "";
21+
vm.labels.copyErrorStatus = "";
22+
1623

1724
vm.closeDrawer = closeDrawer;
1825
vm.startTour = startTour;
@@ -36,14 +43,32 @@
3643
localizationService.localize("general_help").then(function(data){
3744
vm.title = data;
3845
});
46+
//Set help dashboard messages
47+
var labelKeys = [
48+
"general_help",
49+
"speechBubbles_copySuccessMessage",
50+
"general_success",
51+
"speechBubbles_cannotCopyInformation",
52+
"general_error"
53+
];
54+
localizationService.localizeMany(labelKeys).then(function(resp){
55+
[
56+
vm.title,
57+
vm.labels.copiedSuccessInfo,
58+
vm.labels.copySuccessStatus,
59+
vm.labels.copiedErrorInfo,
60+
vm.labels.copyErrorStatus
61+
] = resp;
62+
});
63+
3964
currentUserResource.getUserData().then(function(systemInfo){
4065
vm.systemInfo = systemInfo;
4166
let browserInfo = platformService.getBrowserInfo();
4267
if(browserInfo != null){
4368
vm.systemInfo.push({name :"Browser", data: browserInfo.name + " " + browserInfo.version});
4469
}
4570
vm.systemInfo.push({name :"Browser OS", data: getPlatform()});
46-
});
71+
} );
4772
tourService.getGroupedTours().then(function(groupedTours) {
4873
vm.tours = groupedTours;
4974
getTourGroupCompletedPercentage();
@@ -208,22 +233,33 @@
208233
}
209234
}
210235
function copyInformation(){
211-
let copyText = "<html>\n<body>\n<!--StartFragment-->\n\nCategory | Data\n-- | --\n";
236+
//Write start and end text for table formatting in github issues
237+
let copyStartText = "<html>\n<body>\n<!--StartFragment-->\n\nCategory | Data\n-- | --\n";
238+
let copyEndText = "\n<!--EndFragment-->\n</body>\n</html>";
239+
240+
let copyText = copyStartText;
212241
vm.systemInfo.forEach(function (info){
213242
copyText += info.name + " | " + info.data + "\n";
214243
});
215-
copyText += "\n<!--EndFragment-->\n</body>\n</html>"
216-
navigator.clipboard.writeText(copyText);
217-
if(copyText != null){
218-
notificationsService.success("Copied!", "Your system information is now in your clipboard");
244+
245+
copyText += copyEndText;
246+
247+
// Check if copyText is only start + end text
248+
// if it is something went wrong and we will not copy to clipboard
249+
let emptyCopyText = copyStartText + copyEndText;
250+
if(copyText !== emptyCopyText) {
251+
notificationsService.success(vm.labels.copySuccessStatus, vm.labels.copiedSuccessInfo);
252+
navigator.clipboard.writeText(copyText);
219253
}
220-
else{
221-
notificationsService.error("Error", "Could not copy system information");
254+
else {
255+
notificationsService.error(vm.labels.copyErrorStatus, vm.labels.copiedErrorInfo);
222256
}
223257
}
258+
224259
function getPlatform() {
225260
return window.navigator.platform;
226261
}
262+
227263
evts.push(eventsService.on("appState.tour.complete", function (event, tour) {
228264
tourService.getGroupedTours().then(function(groupedTours) {
229265
vm.tours = groupedTours;
@@ -239,8 +275,8 @@
239275
});
240276

241277
oninit();
242-
243278
}
244279

245280
angular.module("umbraco").controller("Umbraco.Drawers.Help", HelpDrawerController);
281+
246282
})();

src/Umbraco.Web.UI/umbraco/config/lang/da.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,8 @@ Mange hilsner fra Umbraco robotten
13951395
<key alias="publishWithMissingDomain">Der er ikke noget domæne konfigureret for %0%, kontakt vensligst en
13961396
administrator, se loggen for mere information
13971397
</key>
1398+
<key alias="copySuccessMessage">Dit systems information er blevet kopieret til udklipsholderen</key>
1399+
<key alias="cannotCopyInformation">Kunne desværre ikke kopiere dit systems information til udklipsholderen</key>
13981400
</area>
13991401
<area alias="stylesheet">
14001402
<key alias="addRule">Tilføj style</key>

src/Umbraco.Web.UI/umbraco/config/lang/en.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,8 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
15721572
<key alias="publishWithMissingDomain">There is no domain configured for %0%, please contact an administrator, see
15731573
log for more information
15741574
</key>
1575+
<key alias="copySuccessMessage">Your system information has successfully been copied to the clipboard</key>
1576+
<key alias="cannotCopyInformation">Could not copy your system information to the clipboard</key>
15751577
</area>
15761578
<area alias="stylesheet">
15771579
<key alias="addRule">Add style</key>

src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,8 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
16151615
<key alias="publishWithMissingDomain">There is no domain configured for %0%, please contact an administrator, see
16161616
log for more information
16171617
</key>
1618+
<key alias="copySuccessMessage">Your system information has successfully been copied to the clipboard</key>
1619+
<key alias="cannotCopyInformation">Could not copy your system information to the clipboard</key>
16181620
</area>
16191621
<area alias="stylesheet">
16201622
<key alias="addRule">Add style</key>

0 commit comments

Comments
 (0)