diskspace/translate.go

82 lines
3.9 KiB
Go
Raw Normal View History

2022-06-28 13:11:16 +02:00
package main
import (
"fmt"
"os"
"strings"
)
var Languages = map[string]map[string]string{
2022-08-16 22:12:26 +02:00
"en": {
"fileCountFormat": "%d",
},
"de": {
"fileCountFormat": "%d",
"%s files": "%s Dateien",
2022-06-28 13:11:16 +02:00
"Scanning ": "Verarbeite ",
"Scanning took %s": "Verarbeitung dauerte %s",
"'%s' is not a directory": "'%s' ist kein Verzeichnis",
"The following items will be removed:": "Die folgenden Elemente werden entfernt:",
"Files: %d": "Dateien: %d",
"Directories: %d": "Ordner: %d",
"Total size: %s": "Gesamtgröße: %s",
"'%s' could not be found": "'%s' konnte nicht gefunden werden",
"Could not delete '%s': %s": "'%s' konnte nicht gelöscht werden: %s",
"ambiguous path: %s": "Nicht eindeutiger Pfad: %s",
"possible paths:\n%s": "Mögliche Pfade:\n%s",
"Commands:": "Befehle:",
"ls: list files": "ls: Dateien auflisten",
"cd: change directory": "cd: Verzeichnis wechseln",
"rm: mark files for removal": "rm: Markiere Dateien zur Löschung",
"urm: unmark files for removal": "urm: Entmarkiere Dateien zur Löschung",
"exit: delete marked files and exit": "exit: Lösche markierte Dateien und beende Programm",
"Use command 'exit' for exiting properly": "Nutze den Befehl 'exit', um das Programm ordnungsgemäß zu beenden",
"Delete files? [%s/%s/%s]: ": "Dateien löschen? [%s/%s/%s]: ",
"exit? [%s/%s]: ": "Beenden? [%s/%s]: ",
2022-06-28 13:11:16 +02:00
},
2022-08-16 22:12:26 +02:00
"ja": {
"fileCountFormat": "%d個",
"%s files": "%s",
2022-06-28 13:11:16 +02:00
"Scanning ": "処理 ",
"Scanning took %s": "処理が %s かかりました",
"'%s' is not a directory": "「%s」はディレクトリではありません",
"The following items will be removed:": "このファイルは削除します:",
"Files: %d": "ファイル: %d",
"Directories: %d": "デイレクトリ: %d",
"Total size: %s": "全額: %s",
"'%s' could not be found": "「%s」が見つかりませんでした",
"Could not delete '%s': %s": "「%s」が削除できませんでした: %s",
"ambiguous path: %s": "あいまいなパス: %s",
"possible paths:\n%s": "可能なパス:\n%s",
"Commands:": "コマンド:",
"ls: list files": "ls: ファイルを並べます",
"cd: change directory": "cd: ディレクトリを変更",
"rm: mark files for removal": "rm: ファイルに削除のマークを付けます",
"urm: unmark files for removal": "urm: ファイルに削除のマークを除きます",
"exit: delete marked files and exit": "exit: 削除のマークされたファイルを削除して終了",
"Use command 'exit' for exiting properly": "「exit」コマンドを使って終了します",
"Delete files? [%s/%s/%s]: ": "削除してほしいですか? [%s/%s/%s]: ",
"exit? [%s/%s]: ": "終了してほしいですか? [%s/%s]: ",
2022-06-28 13:11:16 +02:00
},
}
var langmap map[string]string
func Translate(str string, args ...interface{}) string {
if langmap == nil {
langVar, _ := os.LookupEnv("LANG")
langmap = map[string]string{}
for lname, lmap := range Languages {
if strings.HasPrefix(langVar, lname) {
langmap = lmap
}
}
}
if translatedText, ok := langmap[str]; ok {
return fmt.Sprintf(translatedText, args...)
}
return fmt.Sprintf(str, args...)
}