From 43adb5f52d2b6fd325f8cc228d0f949411ac3754 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 20 Nov 2021 11:14:04 +0200 Subject: [PATCH] #147 Remove ... from lang_text to fixed arguments, add lang_text:format additional functions --- druid/extended/lang_text.lua | 15 ++++++++++++--- druid/system/settings.lua | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) mode change 100644 => 100755 druid/extended/lang_text.lua mode change 100644 => 100755 druid/system/settings.lua diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua old mode 100644 new mode 100755 index af4ba16..06b5a8e --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -61,11 +61,20 @@ end --- Translate the text by locale_id -- @tparam LangText self -- @tparam string locale_id Locale id -function LangText.translate(self, locale_id, ...) - self.last_locale_args = {...} +-- @tparam string ... Locale arguments to pass in text function +function LangText.translate(self, locale_id, a, b, c, d, e, f, g) + self.last_locale_args = { a, b, c, d, e, f, g } self.last_locale = locale_id or self.last_locale - self.text:set_to(settings.get_text(self.last_locale, ...) or "") + self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") end +--- Format string with new text params on localized text +-- @tparam LangText self +-- @tparam string ... Locale arguments to pass in text function +function LangText.format(self, a, b, c, d, e, f, g) + self.last_locale_args = { a, b, c, d, e, f, g } + self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") +end + return LangText diff --git a/druid/system/settings.lua b/druid/system/settings.lua old mode 100644 new mode 100755 index 0b9cfd9..9d217ab --- a/druid/system/settings.lua +++ b/druid/system/settings.lua @@ -9,7 +9,7 @@ local M = {} M.default_style = nil -function M.get_text(name, ...) +function M.get_text(name, a, b, c, d, e, f, g) return "[Druid]: locales not inited" end