1

Hi I'm creating a MVC project, with localisation. The project also consists of a small quiz

The questions and answers are in a localisation file (resx), but I need to add points to the answers.

Is there an easy way to add (map) an extra parameter (points) to the translated content?

1 Answer 1

3

You could put string formatter tokens into the text in your resource files. So your text would be:

Question10 | "This question is worth {0} points." 

Then in your code you could do:

string.Format(Resources.QuizQuestions.Question10, 15);
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the answer, altough this is not what I meant. I need to map the points to the answer. Every answer gives different points
Ahh, I see. There's no way to add an extra property in the resource file itself. There's only the Key and the Value. What you describe sounds like it would be best stored in a database. You could store the key of the resource item in the database as well and still use the localization framework.
I Should take a look at the resourceprovider and factory, but well I don't have the time atm :). So I just made a mappting table in the database with the points. It's dirty but hey. Thanks for the answer anyway

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.