-
Notifications
You must be signed in to change notification settings - Fork 710
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
Fix: Workaround for localized texts in DarkRP not loading correctly #3262
Conversation
I just noticed that all pose names in animation menu are not translated as well. DarkRP/gamemode/modules/animations/sh_animations.lua Lines 4 to 14 in c7312a4
I modified the event name to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I have to be honest, this is the first time I hear of this bug, and the language system has not changed in a long time. I think perhaps there may be something off in your setup. Maybe your server.cfg
sets it, but some other config or script unsets it.
@@ -1,7 +1,7 @@ | |||
local Anims = {} | |||
|
|||
-- Load animations after the languages for translation purposes | |||
hook.Add("loadCustomDarkRPItems", "loadAnimations", function() | |||
hook.Add("Think", "loadAnimations", function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the problem. Looking quickly at the rest of the file, it seems that the server only uses Anims
to see whether an animation is registered. It ignores the actual translation. The client does show the animation in the menu.
Other than that, instead of creating and removing a think hook, on can run a timer.Simple(0,...)
. Note that either option will run the code quite a bit later than now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I'm not able to reproduce this issue. This may be due to my misconfiguration on my part. I'll revert this change.
|
||
cvars.AddChangeCallback("gmod_language", function(cv, old, new) | ||
selectedLanguage = new | ||
end) | ||
|
||
hook.Add("Think", "DarkRPSetLanguage", function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be covered by the cvars.AddChangeCallback
call above? After all, the moment the car goes from empty to set, that function should trigger.
Maybe the empty string check can be moved there instead. That would remove the need of the separate hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the cvars.AddChangeCallback
above doesn't work at all no matter what language codes I changed from dedicated server-side. This could be the bug directly from Facepunch...
However, I could make it work by starting the server from the main game.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems gmod_language
only works for client side by design.
I haven't managed to make cvars.AddChangeCallback("gmod_language", ...)
work on server side.
@@ -1,10 +1,18 @@ | |||
local rp_languages = {} | |||
local selectedLanguage = GetConVar("gmod_language"):GetString() -- Switch language by setting gmod_language to another language | |||
local selectedLanguage = "en" -- Switch language by setting gmod_language to another language |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think even if the convar is empty, we should still try to use it. That way it will still work if some other server managed to configure it differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll revert this back too.
To confirm this, I have reinstalled the dedicated server on my non-English Windows. Despite only enabling DarkRP and my language file and setting my |
This reverts commit 0db4ac0.
I've been running a French DarkRP server for a decade and have strangely never experienced this issue, is your dedicated server on the stable branch or on a development branch? |
I'm using the stable branch. What operating system and locale does your server use? |
My dedicated server uses Debian 12 configured in French. My Gmod server isn't virtualized or otherwise using Docker.
|
@@ -5,6 +5,14 @@ cvars.AddChangeCallback("gmod_language", function(cv, old, new) | |||
selectedLanguage = new | |||
end) | |||
|
|||
hook.Add("Think", "DarkRPSetLanguage", function() | |||
gmodLanguage = GetConVar("gmod_language"):GetString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this introduces a new global variable, by the way.
The language setting probably works for most people without this pull request, since @FlorianLeChat mentioned it working for them. However, I also think this workaround is harmful for those where it does not work. I just pushed some changes, so this is good for merging. Thanks! |
In DarkRP, some in-game notifications are localized and sent from the server.
However, during server initialization, the convar
gmod_language
doesn't get read correctly. Even if we setgmod_language [geo code]
in server.cfg, it returns an empty string at that time, causing all server-side localized texts to be in English instead of the desired language.To fix this, I've proposed a workaround that delays reading the convar until the server is fully loaded.
And there's a minor concern that the client's language might still be different from the server, leading to incorrect localized texts. I think all localized texts should be handled on the client-side, not the server.