Jump to content

Welcome to the Forum!

The best place to exchange builds and ideas! Vote for the best ideas and suggestions here.

Join the Avorion Discord!

Connect with other passionate players and talk about the latest news.
Discord

DLC Avorion Into the Rift Out Now!

Now available on Steam!
Steam

(Question) Localization - what is %_t and how it works?


Rinart73
 Share

Recommended Posts

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...