Page 1 of 1

How to localization text-box

Posted: Fri Feb 23, 2018 1:42 pm
by WIZ4
I would like the text for text-box to be stored in file ru.cfg which is located in the sceanario folder myScenario\locale\ru\ru.cfg
File contents ru.cfg:

Code: Select all

[msg]
plase=hello
events.on_player_created play this function:

Code: Select all

function try(player)
local infotext = {"msg.plase"} --What's wrong with this?

local frame = player.gui.center.add { type = "frame", name = "info_panel"}
	frame.style.top_padding = 10
	frame.style.left_padding = 10
	frame.style.right_padding = 700
	frame.style.bottom_padding = 10
	local info_table = frame.add { type = "table", column_count = 1, name = "info_table" }
	local text_box = info_table.add { type = "text-box", text = infotext, name = "text_box" }
	text_box.read_only = true
	text_box.selectable = true
	text_box.word_wrap = false
	text_box.style.right_padding = 100
	text_box.style.top_padding = 0
	text_box.style.left_padding = 0
	text_box.style.bottom_padding = 0
end	
And I get this error
Screenshot_5.png
Screenshot_5.png (353.94 KiB) Viewed 1055 times
When local info-text = "hello" That it works as it should. But how do I localize this text?

Re: How to localization text-box

Posted: Fri Feb 23, 2018 2:13 pm
by Klonan
You cannot localise the text in textboxes, because it can be read back and locale is not deterministic

You will have to use a label

Re: How to localization text-box

Posted: Mon Feb 26, 2018 9:15 am
by bobingabout
instead of a text box, try a label

An extract from my mod

Code: Select all

  local gui = player.gui.center.add({type = "frame", name = "bob_inserter_gui", direction = "vertical"})
  globtable.gui = gui
  gui.add({type = "table", name = "title", column_count = 2, style = "table"})
  gui.title.add({type = "label", name = "entity_name", caption = {"entity-name." .. entity.name}})
  gui.title.add({type = "label", name = "entity_position", caption =  "  " .. entity.position.x .. ", " .. entity.position.y})
  gui.add({type = "button", name = "bob_inserter_gui_close", caption = {"gui.ok"}, style = "button_style"})
is there any reason why you're specifically trying to put it in a text box?