Author Topic: UILocalize: best practice for replacing/inserting variables  (Read 2954 times)

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
UILocalize: best practice for replacing/inserting variables
« on: November 15, 2013, 12:19:16 AM »
How would you go about inserting dynamic values on a label with UILocalize?

Let's say the text should read: "You got 400 points" where 400 is dynamic.

Would you make a class that replaces text in OnLocalize? Will script order endure it's being called after OnLocaluze in UILocalize?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILocalize: best practice for replacing/inserting variables
« Reply #1 on: November 15, 2013, 04:31:48 AM »
If your localization string is:
Quote
My Key = You got {0} points
Then you can set the label's text like so:
  1. label.text = string.Format(Localization.Get("My Key"), 400);