Hi,
I'd like to access some kind of locale from the lua code (for example, to display messages in the locale langage).
So is there a function like GetStringLocale( "error-message" )
and in the locales there would be :
error-message = This is an error message
or
error-message = Ceci est un message d'erreur
locale string access from lua
locale string access from lua
My mods on the Factorio Mod Portal
Re: locale string access from lua
no idea ?
I really wonder how to generate locale translated message errors (or any kind of messages)...
I really wonder how to generate locale translated message errors (or any kind of messages)...
My mods on the Factorio Mod Portal
Re: locale string access from lua
Thanks for your answer, but could you be more precise, concerning what I should write into en.cfg in the locale dir ?DaveMcW wrote:Code: Select all
player.print({"error-message"})
At the beginning of en.cfg, I simply put :
Code: Select all
error-message = Test error message
Code: Select all
unknown key : "error-message"
My mods on the Factorio Mod Portal
Re: locale string access from lua
Where exactly did you put that file?
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: locale string access from lua
My fault : I forgot to relaunch completely factorio, because it seems that a simple game reload does not work (as with control.lua...).prg wrote:Where exactly did you put that file?
So it works for player.print, but how can I get this translation into my gui for example ? Into a string ? Let say I want to have the title of the buttons or of the frames also translated...
My mods on the Factorio Mod Portal
Re: locale string access from lua
Code: Select all
player.gui.center.add{type="frame", caption={"my-caption"}}
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: locale string access from lua
Ok. That's a beginning, but let say that I want to display an error message in a gui-label, with a caption like this :prg wrote:Code: Select all
player.gui.center.add{type="frame", caption={"my-caption"}}
"Objects missing : iron plate, steel plate, iron bar"
of course, the list of objects is subject to change...
my problem is that
Code: Select all
local s = tostring({"error-message"}) .. entity.localised_name
as far as I understand, localized string are interprated by factorio, in call to print, caption, etc... but not by lua itself.
So can I concatenate a string that would maintain the CFG tags and passed them to the factorio calls ?
My mods on the Factorio Mod Portal