Author Topic: NGUI Localization and Composite Formatting  (Read 3438 times)

Aethelwulf

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
NGUI Localization and Composite Formatting
« on: August 08, 2016, 05:56:18 PM »
Does NGUI UILabel support composite formatting?

For example, if I have a label that says "Hello, the time is {0} and {1}" with UILocalization attached, key set to "TimeLabel" with localization.txt as follows:

  1. Language,English,Français
  2. TimeLabel,Hello, the time is {0} and {1}, Bonjour, le temps est {0} et {1}

Is there a function within NGUI that I can access in a label to catch each position in the curly brackets above to replace rather than replace the entire string? Reason I ask is if the language is changed, I'd have to update each label variable or make separate labels for data vs static labels.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Localization and Composite Formatting
« Reply #1 on: August 08, 2016, 06:08:31 PM »
Only like this:
  1. void OnLocalize ()
  2. {
  3.     GetComponent<UILabel>().text = Localization.Format("TimeLabel", a, b);
  4. }
  5.