Author Topic: Localizing formatted strings  (Read 1814 times)

capitalj

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 88
    • View Profile
Localizing formatted strings
« on: July 18, 2013, 05:40:21 PM »
Hi,

I'm trying to localize strings with {0} type of formatting. If I inspect the code with breaks the text gets properly formatted, but in the editor the text either doesn't get replaced or reverts back to the original localization:

Localization text file:
weaponRange = Range: {0}

Script:
  1. rangeLocalize.key = "weaponRange";
  2. rangeLocalize.Localize();
  3. rangeLabel.text = string.Format(rangeLabel.text, stats.range);

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Localizing formatted strings
« Reply #1 on: July 19, 2013, 01:44:45 AM »
rangeLabel.text = string.Format(Localization.Localize("weaponRange"), stats.range);

capitalj

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 88
    • View Profile
Re: Localizing formatted strings
« Reply #2 on: July 19, 2013, 02:37:46 PM »
That worked! thank you.

-JJ