![]() |
Language display in program
Hi all.
I thought a good challenge for me and something useful for me to implement in ViewpointKiller (Win32 API C) would be different languages, as I see that the program is mirrored off of sites that have Russian or Dutch or French (and English) languages on them. I thought I could write in the languages doing something similar to an example in my Programming Windows book, which showed how to make a program that read a .txt file and displayed it on the client area. So while I was running my 3 miles tonight, I thought of three ways I might implement a different language in the program. By the way, I wanted to put French, German, Dutch, and Russian (or something similar to Russian) as well as English (duh) (and maybe Spanish) in the program. I'll need translators, but I can think about that later. The first way I might display a language would be to have a drop down menu that let you choose your native language. I would "hard-code" the text into the program, and then paint over everything with the new language. Several problems arise when I think about doing it this way, however. I have a client area that I draw text on using DrawText(). I also have three buttons on that same client area. If a user chose to change the language, I would have to clear the client area and erase the button text, and then re-draw the client area and buttons with the new text, right? Not to mention that I have loads of MessageBox()'s and menus that would have to be changed. I could just have those functions define a string and change the string according to what language was specified. But doing it this way might eat up RAM like there's no tommorow, and it might bloat the program with all of that extra text. Plus, I have no way to change the Yes No buttons in my MessageBox()'s to Oui Non or whatever, except for by #define (ing) the English language set or the French language set, etc. If a user decided he wanted to change languages halfway through the program, I don't know if it would be possible (or even advisable) to change a #define midway through the program. Second way I might display a language would be to have the program read a .txt file in the same directory and push it to the client area and buttons. I would call LoadResource() (I think) the way the book shows me how. But if I specified just one language at a time must be loaded, what happens when a user decides he wants the program to speak Spanglish? (by putting two or more language packs in the directory at the same time and starting the program) Will the program crash, or should I scream at the user how stupid he was to do that? What if a user decides that he wants to start the program without a language pack? Problems arise with this one as well. The third way I might display a language would be to have a dialog box pop up on the start of the program with radio buttons asking what language to load. Problem with this is, I would have to either code all of the language into the program like in the first idea, or I would have to have .txt files in the same directory as my program that the dialog box could call to be loaded into the program. Or, I could have a .ini type of file that had all of the languages in one file and the program could read from the appropriate section in the file. What do you think is the best way to go? I think the third way would be the most stable and least possible to break, but the first would probably be the easiest to write. Any other suggestions as to what I might do would be great. Thanks for taking the time to read this. :) EDIT: Looks like I accidentally put this in the wrong forum, my bad. Should be C instead of C++. |
Just make a config file that specifies the language. Then read a directory and put all language files in there, just read a file (the file with the specified language) and load it into your program, if a language is not specified in the config file, just use the English language which you could hard code in your resources.
|
Ok, thanks, I'll try that. :)
|
Quote:
|
| All times are GMT -5. The time now is 7:59 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC