Rinart73 Posted April 7, 2017 Share Posted April 7, 2017 It seems that game just finds all strings that end on "%_t" in lua files and replaces them before executing. Because as I can see this is not valid lua code, because "%" is a 'modulo' operator. And you can't apply arithmetic's operators to strings. I just need to know how it works, is there a way to understand, which language did player chose and is it possible to translate a string that already stored in the variable. Because this code doesn't work: local say = { "Say Hi", "Say Hello", "Say Goodbye" } for k,v in pairs(say) do printlog((v)%_t) end Link to comment Share on other sites More sharing options...
Aki Posted April 8, 2017 Share Posted April 8, 2017 Localization files are in /data/localization/ (from Avorion's root dir). They use PO file format. Magic behind %_t is made true in /data/scripts/lib/stringutility.lua. Lines from 17 to 46 inclusive. Additionally there are comments with explanation. Pretty much: __mod (modulo, hence %) of Strings' metatable is set to interp from stringutility. Localization happens in GetLocalizedString global function (see docs). It is a valid lua code. Link to comment Share on other sites More sharing options...
w00zla Posted April 8, 2017 Share Posted April 8, 2017 one thing i need to be clarified for localization is: where does the localization aka translation actually take place? in theory only the clients should be "able" to translate into correct player language, but i don´t see evidence for this in the scripts at first glance... Link to comment Share on other sites More sharing options...
Rinart73 Posted April 8, 2017 Author Share Posted April 8, 2017 Is there is a way to get current language? Link to comment Share on other sites More sharing options...
Aki Posted April 8, 2017 Share Posted April 8, 2017 one thing i need to be clarified for localization is: where does the localization aka translation actually take place? in theory only the clients should be "able" to translate into correct player language, but i don´t see evidence for this in the scripts at first glance... Localization happens in GetLocalizedString global function _t is nil. Link to comment Share on other sites More sharing options...
w00zla Posted April 8, 2017 Share Posted April 8, 2017 _t is nil. i get that, but it doesnt really answer how GetLocalizedString theoratically handles localization, i mean the function should not work/translate server-side, or? Link to comment Share on other sites More sharing options...
Rinart73 Posted April 8, 2017 Author Share Posted April 8, 2017 I have a problem related to localization. As I understand there is currently no way to show an error message without server calling this function sendChatMessage(string sender, int messageType, string message, string... arguments) I mean I just need to show a message to the player when he did something wrong. It will be player:sendChatMessage("Server"%_t, 1, "You did something wrong"%_t) right? Well there is a problem. It will translate this message according to the locale that was chosen on a Server side. So, for example we have a German player and he will see English message. There is a function with the same name on a Client side but it's not the same. Just look sendChatMessage(string text) I think it really sends the message in the chat, not shows it in the right side of the screen. I could do something like this: send player chosen language to the Server. But I can't because there is no way to get chosen language using Lua. Just some workarounds that will require more user attention that should. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now