sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

Case sensitivity of translation file phrases

Open dragokas opened this issue 3 years ago • 3 comments

Help us help you

  • [x] I have checked that my issue doesn't exist yet.
  • [x] I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • [ ] I can always reproduce the issue with the provided description below.

Environment

  • Operating System version: Linux (unknown)
  • Game/AppID (with version if applicable): 500
  • Current SourceMod version: 1.11.0.6648
  • Current SourceMod snapshot: 1.11.0.6648
  • Current Metamod: Source snapshot: 1.10.7-dev
  • [ ] I have updated SourceMod to the latest version and it still happens.
  • [ ] I have updated SourceMod to the latest snapshot and it still happens.
  • [ ] I have updated SourceMM to the latest snapshot and it still happens.

Description

I have a very rare error saying that phrase "easy" is not exist in translation file, however, source code contains phrase "Easy" (with capital "E"). I dunno, how to reproduce this problem. However, is it possible to do something like introducing case insensitive mode to prevent such cases in future?

Problematic Code (or Steps to Reproduce)

LoadTranslations("player_menu.phrases");
...
PrintToChat(client, "%t", "Easy");

Actual source code (of error line) had been simplified.

Logs

L 04/10/2022 - 09:29:37: [SM] Exception reported: Language phrase "easy" not found (arg 8)
L 04/10/2022 - 09:29:37: [SM] Blaming: player_menu.smx
L 04/10/2022 - 09:29:37: [SM] Call stack trace:
L 04/10/2022 - 09:29:37: [SM]   [0] Format
L 04/10/2022 - 09:29:37: [SM]   [1] Line 308, H:\_To_games\Left4Dead_2\My_mods\Menu\FREEZONE\menu_1.6\scripting\player_menu.sp::Handle_VoteDifficulty
L 04/10/2022 - 09:29:37: [SM]   [3] Menu.DisplayVote

dragokas avatar Apr 15 '22 16:04 dragokas

Sorry, looks like simplified code totally lose context. Perhaps, "easy" -> "Easy" transformation could be related to menu items read/write problem. Original code:

VoteDifficulty(1, "Easy");
// ...

void VoteDifficulty(int client, char[] sDifficulty)
{
	Menu menu = new Menu(Handle_VoteDifficulty, MenuAction_DisplayItem | MenuAction_Display);
	menu.AddItem(sDifficulty, "Yes");
	menu.AddItem("", "No");
	menu.DisplayVoteToAll(10);
}

public int Handle_VoteDifficulty(Menu menu, MenuAction action, int param1, int param2)
{
	switch (action)
	{
		// ...
		
		case MenuAction_Display:
		{
			char buffer[255], sDif[32];
			Panel panel = view_as<Panel>(param2);
			menu.GetItem(0, sDif, sizeof(sDif));
			Format(buffer, sizeof(buffer), "%T? %T", "MenuVoteDifficulty", param1, sDif, param1); // error here
			panel.SetTitle(buffer);
		}
	}
}```

dragokas avatar Apr 15 '22 16:04 dragokas

Please at least attach the full plugin if you don't have a reliable reproduction.

asherkin avatar Apr 15 '22 17:04 asherkin

Ok, shorten version of original plugin is attached. Error was in line 124. demo.zip

dragokas avatar Apr 16 '22 14:04 dragokas