Skip to content
This repository was archived by the owner on Oct 9, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/koinsight.koplugin/call_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local http = require("socket.http")
local UIManager = require("ui/uimanager")
local JSON = require("json")
local InfoMessage = require("ui/widget/infomessage")
local _ = require("gettext")
local _ = require("koinsight_l10n")

function response_not_valid(content)
logger.err("[KoInsight] callApi: response was not valid JSON", content)
Expand Down Expand Up @@ -65,7 +65,7 @@ return function(method, url, headers, body, filepath, quiet)
if not quiet then
logger.err("[KoInsight] callApi: HTTP error", status or code, resp_headers, result)
UIManager:show(InfoMessage:new({
text = _("Server error" .. (result and ": " .. result["error"] or "")),
text = _("Server error") .. (result and ": " .. result["error"] or ""),
}))
end

Expand Down
68 changes: 68 additions & 0 deletions plugins/koinsight.koplugin/koinsight_l10n.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
-- Plugin-local translations for KoInsight.
-- KOReader's gettext catalog only covers core strings, so plugin strings are
-- looked up here first and fall back to KOReader's gettext (i.e. English).
local gettext = require("gettext")

local translations = {
sk = {
["About KoInsight"] = "O doplnku KoInsight",
["Aggressive suspend sync disabled"] = "Agresívna synchronizácia pri uspaní vypnutá",
["Aggressive suspend sync enabled"] = "Agresívna synchronizácia pri uspaní zapnutá",
["Aggressive sync on suspend (auto Wi-Fi)"] = "Agresívna synchronizácia pri uspaní (automatické Wi-Fi)",
["Apply"] = "Použiť",
["Cancel"] = "Zrušiť",
["Data upload failed."] = "Odoslanie údajov zlyhalo.",
["Data uploaded."] = "Údaje boli odoslané.",
["Enter the location of your KoInsight server"] = "Zadajte adresu vášho servera KoInsight",
["Error during auto sync: "] = "Chyba pri automatickej synchronizácii: ",
["Error toggling aggressive sync setting"] = "Chyba pri prepínaní agresívnej synchronizácie",
["Error toggling sync setting"] = "Chyba pri prepínaní nastavenia synchronizácie",
["Error:"] = "Chyba:",
["Info"] = "Informácie",
["KoInsight is a sync plugin for KoInsight instances.\n\nPlugin version: %s\n\nSee https://github.com/GeorgeSG/koinsight."] = "KoInsight je synchronizačný doplnok pre inštancie KoInsight.\n\nVerzia doplnku: %s\n\nViac na https://github.com/GeorgeSG/koinsight.",
["KoInsight server URL is not configured."] = "URL servera KoInsight nie je nastavená.",
["KoInsight settings saved."] = "Nastavenia KoInsight boli uložené.",
["KoInsight settings"] = "Nastavenia KoInsight",
["KoInsight: Sync all books"] = "KoInsight: Synchronizovať všetky knihy",
["No books with annotations found in reading history."] = "V histórii čítania sa nenašli žiadne knihy s poznámkami.",
["Please configure the server URL first."] = "Najprv nastavte URL servera.",
["Please enter a server URL."] = "Zadajte URL servera.",
["Server URL:"] = "URL servera:",
["Server error"] = "Chyba servera",
["Server response is not valid."] = "Odpoveď servera nie je platná.",
["Set server URL"] = "Nastaviť URL servera",
["Set suspend connect timeout…"] = "Nastaviť časový limit pripojenia pri uspaní…",
["Starting sync..\nScanning reading history for books with annotations."] = "Spúšťam synchronizáciu…\nPrehľadávam históriu čítania a hľadám knihy s poznámkami.",
["Success:"] = "Úspech:",
["Suspend connect timeout (seconds)"] = "Časový limit pripojenia pri uspaní (sekundy)",
["Sync complete!\n%d/%d books synced successfully\n%d failed"] = "Synchronizácia dokončená!\n%d/%d kníh úspešne synchronizovaných\nNeúspešné: %d",
["Sync failed: "] = "Synchronizácia zlyhala: ",
["Sync on suspend disabled"] = "Synchronizácia pri uspaní vypnutá",
["Sync on suspend enabled"] = "Synchronizácia pri uspaní zapnutá",
["Sync on suspend"] = "Synchronizovať pri uspaní",
["Synchronize data"] = "Synchronizovať údaje",
["Syncing: %d/%d books\n%d annotations for current book"] = "Synchronizácia: %d/%d kníh\n%d poznámok v aktuálnej knihe",
["The server URL must start with 'http://' or 'https://'.\n\n"] = "URL servera musí začínať na 'http://' alebo 'https://'.\n\n",
["Timeout (3..60):"] = "Limit (3..60):",
["Timeout saved."] = "Časový limit bol uložený.",
["Unable to register device."] = "Zariadenie sa nepodarilo zaregistrovať.",
["http://example.com:port"] = "http://priklad.sk:port",
},
}

local function currentLanguage()
local lang = gettext.current_lang
if (not lang or lang == "C") and G_reader_settings then
lang = G_reader_settings:readSetting("language")
end
if not lang then
return nil
end
-- "sk_SK" / "sk-SK" -> "sk"
return lang:match("^(%a+)")
end

return function(msgid)
local catalog = translations[currentLanguage()]
return (catalog and catalog[msgid]) or gettext(msgid)
end
15 changes: 8 additions & 7 deletions plugins/koinsight.koplugin/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local _ = require("gettext")
local _ = require("koinsight_l10n")
local Dispatcher = require("dispatcher") -- luacheck:ignore
local InfoMessage = require("ui/widget/infomessage")
local logger = require("logger")
Expand Down Expand Up @@ -89,9 +89,10 @@ function koinsight:addToMainMenu(menu_items)
callback = function()
local const = require("./const")
UIManager:show(InfoMessage:new({
text = "KoInsight is a sync plugin for KoInsight instances.\n\nPlugin version: "
.. const.VERSION
.. "\n\nSee https://github.com/GeorgeSG/koinsight.",
text = string.format(
_("KoInsight is a sync plugin for KoInsight instances.\n\nPlugin version: %s\n\nSee https://github.com/GeorgeSG/koinsight."),
const.VERSION
),
}))
end,
},
Expand Down Expand Up @@ -171,7 +172,7 @@ function koinsight:performFullSync()
if not ok then
UIManager:close(progress_info)
logger.err("[KoInsight] Full sync failed: " .. tostring(err))
UIManager:show(InfoMessage:new({ text = _("Sync failed: " .. tostring(err)), timeout = 5 }))
UIManager:show(InfoMessage:new({ text = _("Sync failed: ") .. tostring(err), timeout = 5 }))
end
end)
end
Expand Down Expand Up @@ -244,10 +245,10 @@ function koinsight:performSyncOnSuspend()
end)

if not success then
message = "Error during auto sync: " .. tostring(error_msg)
local message = "Error during auto sync: " .. tostring(error_msg)
logger.err("[KoInsight] " .. message)
UIManager:show(InfoMessage:new({
text = _(message),
text = _("Error during auto sync: ") .. tostring(error_msg),
}))
else
logger.info("[KoInsight] Suspend sync completed successfully")
Expand Down
2 changes: 1 addition & 1 deletion plugins/koinsight.koplugin/settings.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local _ = require("gettext")
local _ = require("koinsight_l10n")
local BD = require("ui/bidi")
local DataStorage = require("datastorage")
local InfoMessage = require("ui/widget/infomessage")
Expand Down
10 changes: 5 additions & 5 deletions plugins/koinsight.koplugin/upload.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local _ = require("gettext")
local _ = require("koinsight_l10n")
local callApi = require("call_api")
local InfoMessage = require("ui/widget/infomessage")
local JSON = require("json")
Expand Down Expand Up @@ -30,7 +30,7 @@ function render_response_message(response, prefix, default_text)
end

UIManager:show(InfoMessage:new({
text = _(text),
text = text,
}))
end

Expand All @@ -46,7 +46,7 @@ function send_device_data(server_url, silent)
local ok, response = callApi("POST", url, get_headers(body), body)

if ok ~= true and not silent then
render_response_message(response, "Error:", "Unable to register device.")
render_response_message(response, _("Error:"), _("Unable to register device."))
end
end

Expand Down Expand Up @@ -78,9 +78,9 @@ function send_statistics_data(server_url, silent)

if not silent then
if ok then
render_response_message(response, "Success:", "Data uploaded.")
render_response_message(response, _("Success:"), _("Data uploaded."))
else
render_response_message(response, "Error:", "Data upload failed.")
render_response_message(response, _("Error:"), _("Data upload failed."))
end
end
end
Expand Down
Loading