mirror of
https://github.com/syncthing/syncthing.git
synced 2025-12-23 22:18:14 -05:00
gui: Translate theme names in settings (#8006)
Add each subdirectory of the guiDir as a translation candidate string. The key is prefixed with "theme-name-" and the default English translation corresponds to the directory name turned to title case. Disable the automatic name mangling in the GUI JS code in favor of just looking up the translation.
This commit is contained in:
@@ -138,6 +138,22 @@ func walkerFor(basePath string) filepath.WalkFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func collectThemes(basePath string) {
|
||||
files, err := os.ReadDir(basePath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
key := "theme-name-" + f.Name()
|
||||
if _, ok := trans[key]; !ok {
|
||||
name := strings.Title(f.Name())
|
||||
trans[key] = name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
fd, err := os.Open(os.Args[1])
|
||||
if err != nil {
|
||||
@@ -152,6 +168,7 @@ func main() {
|
||||
var guiDir = os.Args[2]
|
||||
|
||||
filepath.Walk(guiDir, walkerFor(guiDir))
|
||||
collectThemes(guiDir)
|
||||
|
||||
bs, err := json.MarshalIndent(trans, "", " ")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user