From f09a4e7c8ea046b8162f0acf753dc59fc2006c75 Mon Sep 17 00:00:00 2001 From: Galunid Date: Mon, 22 Jun 2020 15:17:14 +0200 Subject: [PATCH] Translator: Add definition of the word to the translation (#6295) closes #6293 --- frontend/ui/translator.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/ui/translator.lua b/frontend/ui/translator.lua index 0d08c68f1..28704628b 100644 --- a/frontend/ui/translator.lua +++ b/frontend/ui/translator.lua @@ -165,7 +165,7 @@ local Translator = { -- "bd", -- dictionary (articles, reverse translations, etc) -- "ex", -- examples -- "ld", -- ? - -- "md", -- definitions of source text + "md", -- definitions of source text -- "qca", -- ? -- "rw", -- "see also" list -- "rm", -- transcription / transliteration of source and translated texts @@ -489,7 +489,20 @@ function Translator:_showTranslation(text, target_lang, source_lang) table.insert(output, symbol .. " " .. t) end end - table.insert(output, "") + end + end + + if result[13] and type(result[13]) == "table" and #result[13] > 0 then + -- Definition(word) + table.insert(output, "________") + for i, r in ipairs(result[13]) do + if r[2] and type(r[2]) == "table" then + local symbol = util.unicodeCodepointToUtf8(10101 + (i < 10 and i or 10)) + table.insert(output, symbol.. " ".. r[1]) + for j, res in ipairs(r[2]) do + table.insert(output, "\t● ".. res[1]) + end + end end end