Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 29th, 2006, 9:51 PM   #1
Prm753
Professional Programmer
 
Prm753's Avatar
 
Join Date: Oct 2005
Location: United States
Posts: 447
Rep Power: 4 Prm753 is on a distinguished road
Send a message via AIM to Prm753 Send a message via MSN to Prm753
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++.
__________________
The world's first athletic computer geek!
The home of PrProgramsStudios
How not to post a question: <-- Please don't reply
Prm753 is offline   Reply With Quote
Old May 30th, 2006, 3:28 AM   #2
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old May 30th, 2006, 5:38 PM   #3
Prm753
Professional Programmer
 
Prm753's Avatar
 
Join Date: Oct 2005
Location: United States
Posts: 447
Rep Power: 4 Prm753 is on a distinguished road
Send a message via AIM to Prm753 Send a message via MSN to Prm753
Ok, thanks, I'll try that.
__________________
The world's first athletic computer geek!
The home of PrProgramsStudios
How not to post a question: <-- Please don't reply
Prm753 is offline   Reply With Quote
Old May 30th, 2006, 5:45 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
change a #define midway through the program.
Ummmm, brush up on the build phases. #defines are subbed into the source before the compiler ever sees it.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:02 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC