TShock icon indicating copy to clipboard operation
TShock copied to clipboard

fix: /help, /me, and /p commands can't work in non-English languages

Open ACaiCat opened this issue 1 year ago • 1 comments

When TShock runs in a non-English language, vanilla commands prefix will be localized.

eg.(Chinese) /help (English command prefix) => /帮助 (Chinese command prefix)

TShock.OnChat cannot correctly handle vanilla command prefixes

e.g.(Chinese) When a player use /help, TShock will execute /帮助 (causing the command to not be found). image

Invalid command entered. Type /help for a list of valid commands.

This PR add EnglishLanguage.GetCommandPrefixByName to get English vanilla command prefix.

image

ACaiCat avatar Jul 31 '24 11:07 ACaiCat

Solve #2914

ACaiCat avatar Jul 31 '24 12:07 ACaiCat

Could someone review this PR?

ACaiCat avatar Oct 26 '24 11:10 ACaiCat

Can someone else look at this too?

hakusaro avatar Oct 26 '24 12:10 hakusaro

This is requesting the enUS locale as set earlier https://github.com/Pryaxis/TShock/blob/0b6bf9ef4050f39f468d6782ea2992d8ce82e8bb/TShockAPI/Localization/EnglishLanguage.cs#L50

I guess the Clear was done for similar reason like my implementation (but I did set the _localizedCommands back after) https://github.com/sgkoishi/yaaiomni/blob/debf82951dd84bd307fc7bce06a1c03160479976/Core/Enhancements.cs#L129

sgkoishi avatar Oct 28 '24 16:10 sgkoishi

Can someone else look at this too?

I would, but I don't understand the issue very well.. Can you ELI5 what is wrong?

bartico6 avatar Oct 29 '24 17:10 bartico6

Can someone else look at this too?

I would, but I don't understand the issue very well.. Can you ELI5 what is wrong?

Terraria will translate chat commands into command id. TShock translate them back to keep the command working. However, when the server and the client have different locale, a enUS player send /help will be sent as CommandId: Help and a deDE server will translate it back to /hilfe, thus the command is broken.

sgkoishi avatar Oct 30 '24 01:10 sgkoishi