Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Majicpanda on February 03, 2014, 02:36:24 PM

Title: Dynamic Localization Possible?
Post by: Majicpanda 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?
Title: Re: Dynamic Localization Possible?
Post by: Ferazel 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.