From f9bde5071742870d0af58a63239d567dadc01ee3 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Tue, 10 May 2022 22:34:47 +0100 Subject: [PATCH] added translate --- translate.nim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/translate.nim b/translate.nim index b2c3474..1102c9e 100644 --- a/translate.nim +++ b/translate.nim @@ -3,6 +3,7 @@ import std/[re,httpclient,json,strutils] # TODO: Add language detection and translate into HOME language +# Once one translation is done, stay in that translation until told otherwise const LIBRETRANSLATE_URL = "https://libretranslate.pussthecat.org/translate" const HOME = "en" @@ -64,13 +65,17 @@ proc main(message:varargs[string] = @[]) = var info = newInfo("Translate") info.selected_bg = green var args: seq[string] = @[] - for msg in message: - if msg != "": - args.add(msg) + if len(message) > 0: + for msg in message: + if msg != "": + args.add(msg) + args.add("back") args.add("exit") let output = outputData(info,args) if output == "exit" or output == "": return + elif output == "back": + main() elif output in message: copyToClipboard(output) else: