Skip to content

Commit

Permalink
v9: Use localization keys instead of hardcoded string (umbraco#11406)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Nov 4, 2021
1 parent 1359eb8 commit ba7db3b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

(function () {
"use strict";

Expand All @@ -13,6 +14,12 @@
vm.customDashboard = null;
vm.tours = [];
vm.systemInfoDisplay = false;
vm.labels = {};
vm.labels.copiedSuccessInfo = "";
vm.labels.copySuccessStatus = "";
vm.labels.copiedErrorInfo = "";
vm.labels.copyErrorStatus = "";


vm.closeDrawer = closeDrawer;
vm.startTour = startTour;
Expand All @@ -36,14 +43,32 @@
localizationService.localize("general_help").then(function(data){
vm.title = data;
});
//Set help dashboard messages
var labelKeys = [
"general_help",
"speechBubbles_copySuccessMessage",
"general_success",
"speechBubbles_cannotCopyInformation",
"general_error"
];
localizationService.localizeMany(labelKeys).then(function(resp){
[
vm.title,
vm.labels.copiedSuccessInfo,
vm.labels.copySuccessStatus,
vm.labels.copiedErrorInfo,
vm.labels.copyErrorStatus
] = resp;
});

currentUserResource.getUserData().then(function(systemInfo){
vm.systemInfo = systemInfo;
let browserInfo = platformService.getBrowserInfo();
if(browserInfo != null){
vm.systemInfo.push({name :"Browser", data: browserInfo.name + " " + browserInfo.version});
}
vm.systemInfo.push({name :"Browser OS", data: getPlatform()});
});
} );
tourService.getGroupedTours().then(function(groupedTours) {
vm.tours = groupedTours;
getTourGroupCompletedPercentage();
Expand Down Expand Up @@ -208,22 +233,33 @@
}
}
function copyInformation(){
let copyText = "<html>\n<body>\n<!--StartFragment-->\n\nCategory | Data\n-- | --\n";
//Write start and end text for table formatting in github issues
let copyStartText = "<html>\n<body>\n<!--StartFragment-->\n\nCategory | Data\n-- | --\n";
let copyEndText = "\n<!--EndFragment-->\n</body>\n</html>";

let copyText = copyStartText;
vm.systemInfo.forEach(function (info){
copyText += info.name + " | " + info.data + "\n";
});
copyText += "\n<!--EndFragment-->\n</body>\n</html>"
navigator.clipboard.writeText(copyText);
if(copyText != null){
notificationsService.success("Copied!", "Your system information is now in your clipboard");

copyText += copyEndText;

// Check if copyText is only start + end text
// if it is something went wrong and we will not copy to clipboard
let emptyCopyText = copyStartText + copyEndText;
if(copyText !== emptyCopyText) {
notificationsService.success(vm.labels.copySuccessStatus, vm.labels.copiedSuccessInfo);
navigator.clipboard.writeText(copyText);
}
else{
notificationsService.error("Error", "Could not copy system information");
else {
notificationsService.error(vm.labels.copyErrorStatus, vm.labels.copiedErrorInfo);
}
}

function getPlatform() {
return window.navigator.platform;
}

evts.push(eventsService.on("appState.tour.complete", function (event, tour) {
tourService.getGroupedTours().then(function(groupedTours) {
vm.tours = groupedTours;
Expand All @@ -239,8 +275,8 @@
});

oninit();

}

angular.module("umbraco").controller("Umbraco.Drawers.Help", HelpDrawerController);

})();
2 changes: 2 additions & 0 deletions src/Umbraco.Web.UI/umbraco/config/lang/da.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,8 @@ Mange hilsner fra Umbraco robotten
<key alias="publishWithMissingDomain">Der er ikke noget domæne konfigureret for %0%, kontakt vensligst en
administrator, se loggen for mere information
</key>
<key alias="copySuccessMessage">Dit systems information er blevet kopieret til udklipsholderen</key>
<key alias="cannotCopyInformation">Kunne desværre ikke kopiere dit systems information til udklipsholderen</key>
</area>
<area alias="stylesheet">
<key alias="addRule">Tilføj style</key>
Expand Down
2 changes: 2 additions & 0 deletions src/Umbraco.Web.UI/umbraco/config/lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,8 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="publishWithMissingDomain">There is no domain configured for %0%, please contact an administrator, see
log for more information
</key>
<key alias="copySuccessMessage">Your system information has successfully been copied to the clipboard</key>
<key alias="cannotCopyInformation">Could not copy your system information to the clipboard</key>
</area>
<area alias="stylesheet">
<key alias="addRule">Add style</key>
Expand Down
2 changes: 2 additions & 0 deletions src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,8 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="publishWithMissingDomain">There is no domain configured for %0%, please contact an administrator, see
log for more information
</key>
<key alias="copySuccessMessage">Your system information has successfully been copied to the clipboard</key>
<key alias="cannotCopyInformation">Could not copy your system information to the clipboard</key>
</area>
<area alias="stylesheet">
<key alias="addRule">Add style</key>
Expand Down

0 comments on commit ba7db3b

Please sign in to comment.