-
-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add motd to autohost and challenge #3648
Conversation
This is how multilingual motd would work:
Only the "default" entry is required. For ease-of-use and compatibility if the simple way is merged first, if "motd" is a string it would be used as the default one without any language-specific motd. In multiopt.cpp the motds are sent along other game options. It would be serialized with the number of motds (NETuint8_t) and a couple of strings for each motd (NETstring(locale, 8) and NETstring(motd, 256)). There are 35 languages defined in i18n.cpp, maybe the number of motds can be capped to 36 (getLocales() size), so bloating up to nearly 10kB when abusing the network. When received, the client will pick the motd matching their language, or use the default one. So before coding it, I'd like to have some feedback if this way of doing it is acceptable. It will also be inconsistent with challenge name and description which are not translated (yet). |
Instead of sending it along with the game options, it should be a separate one-time message sent post-join (which seems to be what this PR currently does). Especially given the size. (And, since it might be useful in other cases, we could add this as a new NET_I18NTEXTMSG type, restricted to being sent by the host. Also, the fallback should probably always be English - to match the game’s behavior. So perhaps “en” could be required if supplying it as a dictionary, and any other languages could be optional.) As long as they are only sent once, I think we can stomach an (optional) couple of KB on join (if a host really wants to translate their MOTD for all languages - which I suspect most will only do a few anyway). |
Thank you for the feedback. I will take some time to implement all of this but it wouldn't break the current code structure. It could still be merged in the current state if i18n is not ready.
As the message is user-provided from hosters, there's nothing preventing hosters to use their native language in the English entry as the default one (when English is not provided). But duplication with the actual language code is dumb when thinking about it. I'll go for English-as-default at first for simplicity and maybe add a |
It's done for the main parts. But it doesn't work with the system locale yet. And I haven't checked how to restrict message types only for the host. I would appreciate a code review, I don't do much C++ and a lot of this was done through trial and errors. |
A basic motd to display in the chatbox for autohost and challenges.
Would multilingual motd be appreciated? I think I've understood how to do it but it seems to require to update the serialization of the game options to add all motds and let the client pick the right one to display.