punteroo / TF2-Item-Plugins

SourceMod plugins for TF2 that allow players to manage their weapons (australium, festivizer, unusuals, spells, war paints) and cosmetics (unusuals, paints, spell paints, halloween spells). Now with SQLite support.
GNU General Public License v3.0
30 stars 4 forks source link

[Suggestion] Use Valve translations for names? #10

Open ghost opened 2 years ago

ghost commented 2 years ago

Instead of manually entering them or only English, maybe you could use TF2Econ_GetLocalizedItemName? https://forums.alliedmods.net/showpost.php?p=2646354&postcount=10

punteroo commented 2 years ago

By having a quick read on your suggestion, seems like getting localized token IDs through TFEconData won't be eligible for use in menus, as stated in the linked post by @nosoop the same creator of said TFEconData.

Item names are not manually entered, they are dynamically obtained through memory.

For localizing menus, you'll need to translate them server-side, either by maintaining an SQLite database like TF2IDB, creating your own translation file, or internally parsing the translation files.

  1. Maintaining an SQLite Database for translations would be a solution, but would require updating constantly on each update which beats the purpose of this plugin being entirely made with TFEconData. Yes, there are still some updates needed such as Unusual Effect names and War Paint names, but this is nothing in comparison to updating an entire database. Even then this is something I'm looking to turn dynamic and let the plugin entirely update translations on runtime, but I do not have time to do this for now. (Again, PRs are welcome).
  2. Personal translation files already exist for this. Just not for item names.
  3. Internally parsing the entirety of tf_english.txt or other languages would be a really difficult and intensive task. There's too much memory to keep in mind when doing this, and would require some sort of technique to save this data somewhere as to not have the plugin eat up the entire server's memory space just for translation names. This is even stated by Dr. McKay on his parser as linked in the post

For now, I cannot include this sort of functionality for 2 reasons; I have tried in the past and don't really know or have the knowledge to do so at the moment, and even if I had I currently do not have time to actively work on it.

nosoop commented 2 years ago

🏓

These days there's also the langparser extension, but as far as I can tell it just exposes an interface for it over C++ — it currently doesn't have any SourcePawn-native bindings, and anyone interested in tackling this would need to handle the parsing events themselves.

The server doesn't load translations into memory, so there's no way to access them short of reading the files.