package main import ( "fmt" "os" "strings" ) var Languages = map[string]map[string]string{ "en": { "fileCountFormat": "%d", }, "de": { "fileCountFormat": "%d", "%s files": "%s Dateien", "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", "Delete files? [y/N/c]: ": "Dateien löschen? [y/N/c]: ", "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", "exit? [y/N]: ": "Beenden? [y/N]: ", }, "ja": { "fileCountFormat": "%d個", "%s files": "%s", "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", "Delete files? [y/N/c]: ": "削除してほしいですか? [y/N/c]: ", "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」コマンドを使って終了します", "exit? [y/N]: ": "終了してほしいですか? [y/N]: ", }, } 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...) }