Skip to content

fix(i18n): translate the chat prefix in each recipient's language - #119

Merged
Rushaway merged 1 commit into
masterfrom
fix/chat-prefix-recipient-language
Nov 5, 2026
Merged

Rushaway merged 1 commit into
masterfrom
fix/chat-prefix-recipient-language

Conversation

@Rushaway

@Rushaway Rushaway commented Nov 4, 2026

Copy link
Copy Markdown
Member

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_UserMessage built the final line once, with SetGlobalTransTarget(g_msgAuthor) and %t on the allchat.phrases format. Event_PlayerSay then sent that single string to all recipients in one SayText2.

Change

  • Hook_UserMessage still prepares the colored sender and text once per message (the per-tick cache is unchanged), but no longer builds the final line.
  • Event_PlayerSay groups the recipients by GetClientLanguage and sends one SayText2 per language. Each copy is formatted with %T for a client of that group.
  • The formatting and sending moved to FormatChatMessage and SendChatMessage; g_msgFinal is gone.
  • Version 8.1.6 → 8.1.7.

Compiles with SourceMod 1.13 (spcomp 1.13.0.7427), no warning.

Test

Two clients with different cl_language (for example english and schinese) 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.

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.
@Rushaway
Rushaway merged commit 2de41db into master Nov 5, 2026
9 checks passed
@Rushaway
Rushaway deleted the fix/chat-prefix-recipient-language branch November 5, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant