How to localization text-box

Place to get help with not working mods / modding interface.
User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

How to localization text-box

Post 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 1054 times
When local info-text = "hello" That it works as it should. But how do I localize this text?
My native language is russian. Sorry if my messages are difficult to read.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5412
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: How to localization text-box

Post 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
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: How to localization text-box

Post 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?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”