Author Topic: Dynamic Localization Possible?  (Read 4399 times)

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Dynamic Localization Possible?
« on: February 03, 2014, 02:36:24 PM »
I have a game where the .text of labels is generated from a long string with several blanks and then the blanks are filled with random words chosen by a generator.

I also have many other strings in the game that are randomly generated based on what is going on at the time.

How do you create the localization file for something like this when there's no key/value pair which seems to be how the localization works?

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: Dynamic Localization Possible?
« Reply #1 on: February 03, 2014, 05:49:10 PM »
In your localization file make the string something like this:
StringKey = {0} attacks for {1} damage!

Then when you use that string use something like the following:
LabelText.text = string.format(Localization.Localize("StringKey"), Attacker.Name, amtDamage);

This should produce something like "Ranger attacks for 3 damage!" if the name was Ranger and the amtDamage variable was 3.