#163 Default locale id from text node for lang_text component

This commit is contained in:
Insality 2022-01-27 18:31:33 +02:00
parent 54f80aeccd
commit f534baf2ee
3 changed files with 18 additions and 20 deletions

View File

@ -24,7 +24,7 @@ local LangText = component.create("lang_text")
--- Component init function --- Component init function
-- @tparam LangText self -- @tparam LangText self
-- @tparam node node The text node -- @tparam node node The text node
-- @tparam string locale_id Default locale id, optional -- @tparam string locale_id Default locale id or text from node as default
-- @tparam bool no_adjust If true, will not correct text size -- @tparam bool no_adjust If true, will not correct text size
function LangText.init(self, node, locale_id, no_adjust) function LangText.init(self, node, locale_id, no_adjust)
self.druid = self:get_druid() self.druid = self:get_druid()
@ -34,9 +34,7 @@ function LangText.init(self, node, locale_id, no_adjust)
self.on_change = Event() self.on_change = Event()
if locale_id then self:translate(locale_id or gui.get_text(self.node))
self:translate(locale_id)
end
return self return self
end end

View File

@ -210,7 +210,7 @@ nodes {
} }
type: TYPE_TEXT type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA blend_mode: BLEND_MODE_ALPHA
text: "Button:" text: "ui_section_button"
font: "game" font: "game"
id: "text_button" id: "text_button"
xanchor: XANCHOR_NONE xanchor: XANCHOR_NONE
@ -604,7 +604,7 @@ nodes {
} }
type: TYPE_TEXT type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA blend_mode: BLEND_MODE_ALPHA
text: "Text:" text: "ui_section_text"
font: "game" font: "game"
id: "text_text" id: "text_text"
xanchor: XANCHOR_NONE xanchor: XANCHOR_NONE
@ -848,7 +848,7 @@ nodes {
} }
type: TYPE_TEXT type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA blend_mode: BLEND_MODE_ALPHA
text: "Timer:" text: "ui_section_timer"
font: "game" font: "game"
id: "text_timer" id: "text_timer"
xanchor: XANCHOR_NONE xanchor: XANCHOR_NONE
@ -1029,7 +1029,7 @@ nodes {
} }
type: TYPE_TEXT type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA blend_mode: BLEND_MODE_ALPHA
text: "Progress bar:" text: "ui_section_progress"
font: "game" font: "game"
id: "text_progress" id: "text_progress"
xanchor: XANCHOR_NONE xanchor: XANCHOR_NONE
@ -1320,7 +1320,7 @@ nodes {
} }
type: TYPE_TEXT type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA blend_mode: BLEND_MODE_ALPHA
text: "Slider:" text: "ui_section_slider"
font: "game" font: "game"
id: "text_slider" id: "text_slider"
xanchor: XANCHOR_NONE xanchor: XANCHOR_NONE
@ -1611,7 +1611,7 @@ nodes {
} }
type: TYPE_TEXT type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA blend_mode: BLEND_MODE_ALPHA
text: "Radio:" text: "ui_section_radio"
font: "game" font: "game"
id: "text_radio" id: "text_radio"
xanchor: XANCHOR_NONE xanchor: XANCHOR_NONE
@ -2234,7 +2234,7 @@ nodes {
} }
type: TYPE_TEXT type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA blend_mode: BLEND_MODE_ALPHA
text: "Checkbox:" text: "ui_section_checkbox"
font: "game" font: "game"
id: "text_checkbox" id: "text_checkbox"
xanchor: XANCHOR_NONE xanchor: XANCHOR_NONE
@ -2857,7 +2857,7 @@ nodes {
} }
type: TYPE_TEXT type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA blend_mode: BLEND_MODE_ALPHA
text: "Input:" text: "ui_section_input"
font: "game" font: "game"
id: "text_input" id: "text_input"
xanchor: XANCHOR_NONE xanchor: XANCHOR_NONE

View File

@ -25,14 +25,14 @@ end
local function setup_texts(self) local function setup_texts(self)
self.druid:new_lang_text("text_button", "ui_section_button") self.druid:new_lang_text("text_button")
self.druid:new_lang_text("text_text", "ui_section_text") self.druid:new_lang_text("text_text")
self.druid:new_lang_text("text_timer", "ui_section_timer") self.druid:new_lang_text("text_timer")
self.druid:new_lang_text("text_progress", "ui_section_progress") self.druid:new_lang_text("text_progress")
self.druid:new_lang_text("text_slider", "ui_section_slider") self.druid:new_lang_text("text_slider")
self.druid:new_lang_text("text_radio", "ui_section_radio") self.druid:new_lang_text("text_radio")
self.druid:new_lang_text("text_checkbox", "ui_section_checkbox") self.druid:new_lang_text("text_checkbox")
self.druid:new_lang_text("text_input", "ui_section_input") self.druid:new_lang_text("text_input")
self.druid:new_lang_text("text_translated", "ui_text_example") self.druid:new_lang_text("text_translated", "ui_text_example")
self.druid:new_lang_text("text_button_lang", "ui_text_change_lang") self.druid:new_lang_text("text_button_lang", "ui_text_change_lang")