Translator errors are misleading when entry named parameters are not provided

When you call FormatByKey on an entry with named parameters, if the parameters are not provided. The error is

Key "%s" for locale "en-us" not found in any active LocalizationTable

Expected behavior is to notice the unprovided parameters and then provide appropriate errors on the missing information.

Reproduction

  1. Create a new localization table. You can use this
Key,Context,Example,Source,es-es
BoatSelection_SubToolTip_Owner,,,{ownerName}'s boat with {propCount:int} props,{ownerName}'s barco on {propCount:int} puntales
BoatSelection_SubToolTip_PlayerBoatCount,,,Your boat with {propCount:int} props,Tu bote con {propCount:int} puntales
BoatSelection_UnnamedBoat,,,Unnamed boat,Barco sin nombre
  1. Attempt to localize a normal string
> game.LocalizationService:GetTranslatorForPlayer(game.Players.LocalPlayer):FormatByKey("BoatSelection_UnnamedBoat")

This will work fine. Try this:

> game.LocalizationService:GetTranslatorForPlayer(game.Players.LocalPlayer):FormatByKey("BoatSelection_SubToolTip_PlayerBoatCount")

You’ll see it error with this:

17:35:10.863 - Key "BoatSelection_SubToolTip_PlayerBoatCount" for locale "en-us" not found in any active LocalizationTable
17:35:10.866 - Stack Begin
17:35:10.868 - Script 'game.LocalizationService:GetTranslatorForPlayer(game.Players.LocalPlayer):FormatByKey("BoatSelection_SubToolTip_PlayerBoatCount")', Line 1
17:35:10.869 - Stack End

Then try this:

> game.LocalizationService:GetTranslatorForPlayer(game.Players.LocalPlayer):FormatByKey("BoatSelection_SubToolTip_PlayerBoatCount", {propCount = 3})

You can see it works fine.

4 Likes