I don't know wether it is a bug, but it is strange.
In a gui/textfield, you can type unicode caracters (like é è à). But if you get the text in a lua string, and then try to print it in the console, unicode cars are displayed but the string length is longer than expected. And they do not seem to be managed by the lua string lib (for example if I try to extract car by car using string.sub(s,i,i) ).
An explanation ? Or a hint or a turnaround ?
[0.12.30] unicode / mod / lua
[0.12.30] unicode / mod / lua
My mods on the Factorio Mod Portal
Re: [0.12.30] unicode / mod / lua
Lua doesn't suport unicode by default.
More info on this link (http://lua-users.org/wiki/LuaUnicode).
It would be probably possible to use custom lua code to do string operations on unicode strings though.
More info on this link (http://lua-users.org/wiki/LuaUnicode).
It would be probably possible to use custom lua code to do string operations on unicode strings though.
Re: [0.12.30] unicode / mod / lua
Thanks for your answer Kovarex.
I'll give a try to UTF-8.lua functions.
I am in the locale stuff these days. I asked more questions on localization ) :
viewtopic.php?f=25&t=24144
and
viewtopic.php?f=25&t=24145
I really think that localization is a good thing to spread Factorio all over the world as a lot of user do not speak english, but a lot of users want to try mods.
So if not existing, you should add a few API functions that give access to localization.
A LUAplayer.get_localized_string( cfg_tag ) would be nice, that would read into the locale cfg file.
I noticed also that there is no localised_name variable on the LUArecipe.
I'll give a try to UTF-8.lua functions.
I am in the locale stuff these days. I asked more questions on localization ) :
viewtopic.php?f=25&t=24144
and
viewtopic.php?f=25&t=24145
I really think that localization is a good thing to spread Factorio all over the world as a lot of user do not speak english, but a lot of users want to try mods.
So if not existing, you should add a few API functions that give access to localization.
A LUAplayer.get_localized_string( cfg_tag ) would be nice, that would read into the locale cfg file.
I noticed also that there is no localised_name variable on the LUArecipe.
My mods on the Factorio Mod Portal
Re: [0.12.30] unicode / mod / lua
The "print" method already supports exactly that - you give it a table with the key and parameters it has if any and it prints it localized. Most things that reach the display support this format.binbinhfr wrote:Thanks for your answer Kovarex.
I'll give a try to UTF-8.lua functions.
I am in the locale stuff these days. I asked more questions on localization ) :
viewtopic.php?f=25&t=24144
and
viewtopic.php?f=25&t=24145
I really think that localization is a good thing to spread Factorio all over the world as a lot of user do not speak english, but a lot of users want to try mods.
So if not existing, you should add a few API functions that give access to localization.
A LUAplayer.get_localized_string( cfg_tag ) would be nice, that would read into the locale cfg file.
I noticed also that there is no localised_name variable on the LUArecipe.
If you want to get ahold of me I'm almost always on Discord.
Re: [0.12.30] unicode / mod / lua
Several persons claims it is simple, but bould you be more precise and help me on a simple example :Rseding91 wrote: The "print" method already supports exactly that - you give it a table with the key and parameters it has if any and it prints it localized. Most things that reach the display support this format.
let say that I want to change the caption of a GUI label, so that it concatenates a fixed localized string prefix-message = "Inventory is missing entity" and the localized name of an entity ent.localised_name.
gui.caption = "{\"prefix-message\"}" .. ent.localised_name does not seem to work....
what should I exactly put into my cfg file and in my control.lua ?
My mods on the Factorio Mod Portal
Re: [0.12.30] unicode / mod / lua
Code: Select all
prefix-message=Inventory is missing entity __1__
Code: Select all
gui_element.add{type="label", caption={"prefix-message", entity.localised_name}}
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: [0.12.30] unicode / mod / lua
For entities in inventory, it was just a stupid exampleprg wrote:Code: Select all
prefix-message=Inventory is missing entity __1__
(You don't have entities in your inventory BTW)Code: Select all
gui_element.add{type="label", caption={"prefix-message", entity.localised_name}}
But for the rest, thank you !!! I'll test this this evening at home.
I suppose that it is also working if I later write the caption separately ?
Code: Select all
gui_element.gui_label.caption={"prefix-message", itemProto.localised_name}
My mods on the Factorio Mod Portal
Re: [0.12.30] unicode / mod / lua
Thanks again, very good and useful tip ! It works perfectly and now I can localized even the whole GUI.
My mods on the Factorio Mod Portal