I have an application that uses multiple different phrases, given a certain situation. I want to put these phrases into a resource file to enable localization. At runtime, I want to be able to pick one of the N strings to display, randomly.
As an example, say i was displaying a greeting phrase to the user. I might have the following phrases as a greeting variant.
- Hello
- Hey there
- Welcome
Now i know i can store them in my resource file, given it is a key/value pair.
- GreetingVariant0
- GreetingVariant1
- GreetingVariant2
How can i pick one of these randomly at run time?
Do i need to have a config file, store the number of "Greeting Variants", read in that config file, and then pick a random number, and then pull that resource?
Is there a better way?