mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-22 22:58:25 +00:00
Fix translation in upgrading/restarting dialogs
This commit is contained in:
parent
83d707fc4b
commit
68b1ffec19
File diff suppressed because one or more lines are too long
@ -10,12 +10,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.google.com/p/go.net/html"
|
"code.google.com/p/go.net/html"
|
||||||
)
|
)
|
||||||
|
|
||||||
var trans = make(map[string]string)
|
var trans = make(map[string]string)
|
||||||
|
var attrRe = regexp.MustCompile(`\{\{'([^']+)'\s+\|\s+translate\}\}`)
|
||||||
|
|
||||||
func generalNode(n *html.Node) {
|
func generalNode(n *html.Node) {
|
||||||
translate := false
|
translate := false
|
||||||
@ -24,6 +26,10 @@ func generalNode(n *html.Node) {
|
|||||||
if a.Key == "translate" {
|
if a.Key == "translate" {
|
||||||
translate = true
|
translate = true
|
||||||
break
|
break
|
||||||
|
} else {
|
||||||
|
if matches := attrRe.FindStringSubmatch(a.Val); len(matches) == 2 {
|
||||||
|
translation(matches[1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if n.Type == html.TextNode {
|
} else if n.Type == html.TextNode {
|
||||||
@ -44,12 +50,7 @@ func generalNode(n *html.Node) {
|
|||||||
|
|
||||||
func inTranslate(n *html.Node) {
|
func inTranslate(n *html.Node) {
|
||||||
if n.Type == html.TextNode {
|
if n.Type == html.TextNode {
|
||||||
v := strings.TrimSpace(n.Data)
|
translation(n.Data)
|
||||||
if _, ok := trans[v]; !ok {
|
|
||||||
av := strings.Replace(v, "{%", "{{", -1)
|
|
||||||
av = strings.Replace(av, "%}", "}}", -1)
|
|
||||||
trans[v] = av
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
log.Println("translate node with non-text child <")
|
log.Println("translate node with non-text child <")
|
||||||
log.Println(n)
|
log.Println(n)
|
||||||
@ -60,6 +61,15 @@ func inTranslate(n *html.Node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func translation(v string) {
|
||||||
|
v = strings.TrimSpace(v)
|
||||||
|
if _, ok := trans[v]; !ok {
|
||||||
|
av := strings.Replace(v, "{%", "{{", -1)
|
||||||
|
av = strings.Replace(av, "%}", "}}", -1)
|
||||||
|
trans[v] = av
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fd, err := os.Open(os.Args[1])
|
fd, err := os.Open(os.Args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
13
gui/app.js
13
gui/app.js
@ -514,8 +514,6 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
|
|||||||
|
|
||||||
$scope.restart = function () {
|
$scope.restart = function () {
|
||||||
restarting = true;
|
restarting = true;
|
||||||
$scope.restartingTitle = "Restarting"
|
|
||||||
$scope.restartingBody = "Syncthing is restarting."
|
|
||||||
$('#restarting').modal({backdrop: 'static', keyboard: false});
|
$('#restarting').modal({backdrop: 'static', keyboard: false});
|
||||||
$http.post(urlbase + '/restart');
|
$http.post(urlbase + '/restart');
|
||||||
$scope.configInSync = true;
|
$scope.configInSync = true;
|
||||||
@ -537,14 +535,13 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.upgrade = function () {
|
$scope.upgrade = function () {
|
||||||
$scope.restartingTitle = "Upgrading"
|
restarting = true;
|
||||||
$scope.restartingBody = "Syncthing is upgrading."
|
$('#upgrading').modal({backdrop: 'static', keyboard: false});
|
||||||
$('#restarting').modal({backdrop: 'static', keyboard: false});
|
|
||||||
$http.post(urlbase + '/upgrade').success(function () {
|
$http.post(urlbase + '/upgrade').success(function () {
|
||||||
restarting = true;
|
$('#restarting').modal({backdrop: 'static', keyboard: false});
|
||||||
$scope.restartingBody = "Syncthing is restarting into the new version."
|
$('#upgrading').modal('hide');
|
||||||
}).error(function () {
|
}).error(function () {
|
||||||
$('#restarting').modal('hide');
|
$('#upgrading').modal('hide');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -391,8 +391,12 @@
|
|||||||
|
|
||||||
<!-- Restarting modal -->
|
<!-- Restarting modal -->
|
||||||
|
|
||||||
<modal id="restarting" icon="refresh" title="{{restartingTitle}}" status="info">
|
<modal id="restarting" icon="refresh" title="{{'Restarting' | translate}}" status="info">
|
||||||
<p>{{restartingBody}} <span translate>Please wait</span>…</p>
|
<p><span translate>Syncthing is restarting.</span> <span translate>Please wait</span>...</p>
|
||||||
|
</modal>
|
||||||
|
|
||||||
|
<modal id="upgrading" icon="refresh" title="{{'Upgrading' | translate}}" status="info">
|
||||||
|
<p><span translate>Syncthing is upgrading.</span> <span translate>Please wait</span>...</p>
|
||||||
</modal>
|
</modal>
|
||||||
|
|
||||||
<!-- Shutdown modal -->
|
<!-- Shutdown modal -->
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"Bugs": "Bugs",
|
"Bugs": "Bugs",
|
||||||
"CPU Utilization": "CPU Utilization",
|
"CPU Utilization": "CPU Utilization",
|
||||||
"Close": "Close",
|
"Close": "Close",
|
||||||
|
"Connection Error": "Connection Error",
|
||||||
"Copyright © 2014 Jakob Borg and the following Contributors:": "Copyright © 2014 Jakob Borg and the following Contributors:",
|
"Copyright © 2014 Jakob Borg and the following Contributors:": "Copyright © 2014 Jakob Borg and the following Contributors:",
|
||||||
"Delete": "Delete",
|
"Delete": "Delete",
|
||||||
"Disconnected": "Disconnected",
|
"Disconnected": "Disconnected",
|
||||||
@ -46,6 +47,7 @@
|
|||||||
"Max Outstanding Requests": "Max Outstanding Requests",
|
"Max Outstanding Requests": "Max Outstanding Requests",
|
||||||
"No": "No",
|
"No": "No",
|
||||||
"Node ID": "Node ID",
|
"Node ID": "Node ID",
|
||||||
|
"Node Identification": "Node Identification",
|
||||||
"Node Name": "Node Name",
|
"Node Name": "Node Name",
|
||||||
"Notice": "Notice",
|
"Notice": "Notice",
|
||||||
"OK": "OK",
|
"OK": "OK",
|
||||||
@ -65,6 +67,7 @@
|
|||||||
"Rescan Interval (s)": "Rescan Interval (s)",
|
"Rescan Interval (s)": "Rescan Interval (s)",
|
||||||
"Restart": "Restart",
|
"Restart": "Restart",
|
||||||
"Restart Needed": "Restart Needed",
|
"Restart Needed": "Restart Needed",
|
||||||
|
"Restarting": "Restarting",
|
||||||
"Save": "Save",
|
"Save": "Save",
|
||||||
"Scanning": "Scanning",
|
"Scanning": "Scanning",
|
||||||
"Select the nodes to share this repository with.": "Select the nodes to share this repository with.",
|
"Select the nodes to share this repository with.": "Select the nodes to share this repository with.",
|
||||||
@ -84,6 +87,8 @@
|
|||||||
"Syncing": "Syncing",
|
"Syncing": "Syncing",
|
||||||
"Syncthing has been shut down.": "Syncthing has been shut down.",
|
"Syncthing has been shut down.": "Syncthing has been shut down.",
|
||||||
"Syncthing includes the following software or portions thereof:": "Syncthing includes the following software or portions thereof:",
|
"Syncthing includes the following software or portions thereof:": "Syncthing includes the following software or portions thereof:",
|
||||||
|
"Syncthing is restarting.": "Syncthing is restarting.",
|
||||||
|
"Syncthing is upgrading.": "Syncthing is upgrading.",
|
||||||
"Syncthing seems to be down, or there is a problem with your Internet connection. Retrying…": "Syncthing seems to be down, or there is a problem with your Internet connection. Retrying…",
|
"Syncthing seems to be down, or there is a problem with your Internet connection. Retrying…": "Syncthing seems to be down, or there is a problem with your Internet connection. Retrying…",
|
||||||
"The aggregated statistics are publicly available at {%url%}.": "The aggregated statistics are publicly available at {{url}}.",
|
"The aggregated statistics are publicly available at {%url%}.": "The aggregated statistics are publicly available at {{url}}.",
|
||||||
"The configuration has been saved but not activated. Syncthing must restart to activate the new configuration.": "The configuration has been saved but not activated. Syncthing must restart to activate the new configuration.",
|
"The configuration has been saved but not activated. Syncthing must restart to activate the new configuration.": "The configuration has been saved but not activated. Syncthing must restart to activate the new configuration.",
|
||||||
@ -101,6 +106,7 @@
|
|||||||
"Unknown": "Unknown",
|
"Unknown": "Unknown",
|
||||||
"Up to Date": "Up to Date",
|
"Up to Date": "Up to Date",
|
||||||
"Upgrade To {%version%}": "Upgrade To {{version}}",
|
"Upgrade To {%version%}": "Upgrade To {{version}}",
|
||||||
|
"Upgrading": "Upgrading",
|
||||||
"Upload Rate": "Upload Rate",
|
"Upload Rate": "Upload Rate",
|
||||||
"Usage": "Usage",
|
"Usage": "Usage",
|
||||||
"Use Compression": "Use Compression",
|
"Use Compression": "Use Compression",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user