Amaroq7 / SPMod

SourcePawn Scripting Engine for Half-Life 1 based games
GNU General Public License v3.0
27 stars 12 forks source link

Python-like localization support #19

Open WPMGPRoSToTeMa opened 6 years ago

WPMGPRoSToTeMa commented 6 years ago

Not really python-like, but inspired by it and by #18 of course.

First of all instead of capsing, like DID_DMG_HITS, we can use some default translation text (e.g. english text). Secondly instead of %L we can use function style: L(player, "He did {damage:d} damage to you with {hits:d} hit(s)\nand still has {health:d}hp and {armor:d}ap.")

This simplifies localization process of plugin that doesn't support it. Look:

Format("He did {damage:d} damage to you with {hits:d} hit(s)\nand still has {health:d}hp and {armor:d}ap."
  , FmtArg("damage", damage)
  , FmtArg("hits", hits)
  , FmtArg("health", player.Health)
  , FmtArg("armor", player.Armor)
);

Becomes:

Format(L(player, "He did {damage:d} damage to you with {hits:d} hit(s)\nand still has {health:d}hp and {armor:d}ap.")
  , FmtArg("damage", damage)
  , FmtArg("hits", hits)
  , FmtArg("health", player.Health)
  , FmtArg("armor", player.Armor)
);

Just adding L(player, and )!

TODO: