Repository navigation
fix(i18n): translate the chat prefix in each recipient's language - #119
Merged
Merged
Conversation
The chat line was formatted once in the author's language and sent to everyone, so a Chinese player's team message showed "(反恐精英)" to every player. Event_PlayerSay now groups the recipients by language and formats and sends one copy per language.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The prefix of a chat message (
(Counter-Terrorist),(Terrorist),*DEAD*...) was translated in the language of the player who sent it, not of the player who reads it. Seen on Z.ESCAPE: a team message from a player using Chinese showed(反恐精英)to every Counter-Terrorist.Cause
Hook_UserMessagebuilt the final line once, withSetGlobalTransTarget(g_msgAuthor)and%ton theallchat.phrasesformat.Event_PlayerSaythen sent that single string to all recipients in oneSayText2.Change
Hook_UserMessagestill prepares the colored sender and text once per message (the per-tick cache is unchanged), but no longer builds the final line.Event_PlayerSaygroups the recipients byGetClientLanguageand sends oneSayText2per language. Each copy is formatted with%Tfor a client of that group.FormatChatMessageandSendChatMessage;g_msgFinalis gone.Compiles with SourceMod 1.13 (spcomp 1.13.0.7427), no warning.
Test
Two clients with different
cl_language(for exampleenglishandschinese) in the same team. A team message should show(Counter-Terrorist)to the first and(反恐精英)to the second. A dead player's message should show*DEAD*in each reader's language.