If I would want to create a c# application that support multiple languages, how should I store them?
I’d probably use constants in the application as value holders.
Such as: Console.Write(FILE_NOT_FOUND);
When compiled, it would change into the string determined by the language. I’ll probably stick to 3 languages (Danish, English, Deutsch), not that I think it matters though.
It seems to be a waste to have a class file for each language, which all is processed when the application is compiled. It would also mean that you’d have to re-compile and re-distribute the whole program every time you want to change a string. As far as I know, hardcoded strings is a bad thing.
Maybe a text file? English.txt Line1: FILE_NOT_FOUND=File Not Found. Try Again Line2 Line3 etc.
Danish.txt Line1: FILE_NOT_FOUND=Filen blev ikke fundet. Prøv igen Line2 Line3 etc.
and so on. If the user selects English, it reads the text file and set the different constant values.
The last one I can think of is placing it in a SQL database.
Could you give me some input? 🙂
Also, I tried writing FILE _ NOT _ FOUND (without spaces, but the text editor wouldn’t let me
Use a resource file. That’s the standard way to handle localization.
For details, see this tutorial.
— EDIT —
An alternative tutorial is available here. This one uses much better naming, so it may be more clear how it works.