Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internationalize a program

Status
Not open for further replies.

Totte

Programmer
Jun 6, 2001
317
SE
by chancing the captions and hints and such would be usefull to me as i'm a danish living in sweden and fiddling a little with windows-softwar that my friends use now and then but to make a program, debug it and then make different versions with different languages......
I'm CERTAIN that there are others that has used an FAR MORE sensible approach....so please give me a hint. Is there a ultra-simple way of doing it, maybe by supplying a language file or something like that?
It would be nice to have a program that i send to my friends and i only has to supply some setting/file to make it in their native language....and it would look highly professional! (Hey, it's not illegal to try to look clever) Totte
 
I think there is a topic in the help file about this very subject. Have you checked there?
James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
There is something about how to reserve space and such but nothing about some clever way of doing it which is what i hoped for. It seems to me that there could be a better way than do a set-text on all buttons and hints and such at startup but maybe i'm wrong? Totte
 
I found this in DevGuide: Programming with C++Builder help guide:
It is not difficult to create internationalized applications. You need to complete the following steps:

1 You must enable your code to handle strings from international character sets.
2 You need to design your user interface so that it can accommodate the changes that result from localization.
3 You need to isolate all resources that need to be localized.


There are links in each step to more help files. James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
Yeah, i did read that and basically it tells me to allocate enough room for texts and such, what i'm looking for is a clever way of linking all the button-captions, hints and comments in a simple way to some kind of text-select. Currently i rewrite the program and puts at couple of speedbuttons on with the different flags on and use a press on a flag doing a language select and then do a serious ButtonX->Caption = SomeTextForTheButton[Index] with hints and all but i can't help thinking that there ought to be a smarter way....... Totte
 
If you develop it in VC++, I wrote up an FAQ on it. I know this is the borland forum and Microsoft VC++ is pooped on but hey, i gotta work with how my company develps :p

Matt
 
Downloading, will look hard, thx! Totte
 
Due to lack of time i chose to do it the dirty way: Defining a lot of constants (i.e. const char * Lan_ButtonConnect[] = {"Text Swedish","Text Danish","Text English"};), one for each Caption, then have a function that fills in the correct version depending upon what language that is selected, this enables me to change language in the whole program at runtime, it's dirty but it works! Totte
 
yea, if you get your handsa on the rare and illusive "C++ Builder How To: The Definitive something something something..." It's got a whole chapter on internationalizing. It was too much work for me, but you gotta do waht you've gotta do. I'm fairly sure it had something to do with .RC files and you put strings in them, etc. Cyprus
 
The usual way of doing what you're trying to do is to not define the messages in the program at all, but in a separate data file. You then have a data file for each language you want to support. At some point in the program, you select one of these files (probably on a "Select Language" screen or option). When you want to display a message, you just say "display message #5 in the data file."

Here are 3 sample data files:

Hello!
Where's the cheese?
Goodbye!

Bonjour!
Ou est le fromage?
Au revoir!

Hola!
Donde esta el queso?
Adios!


When you want to greet someone, you say "print the first line in the data file." When you wish to inquire about the whereabouts of their dairy products, say "print the second line in the data file." When you're done, say "print the third line in the data file."

This gets you the correct message based on the previously chosen data file (i.e. language).


Now, what you described was basically a way of doing this completely within your program. That's fine, but if you choose to support a new language, you'd have to change your code and recompile. This way, you can just write a new message file and leave your program untouched.

I think C++ has support for this kind of thing in its standard locale class. If not, it has support for internationalization of stuff like currency, time, and number representations, so you might want to take a look at locale anyway.
 
I can only agree with You and i had the thought of using approximately that approach, what i would like was to be able to supply a language-file and then it would load all captions, hints and such in a simple way. As of now the REAL problem is that i have to do a !whole! lot of:
ButtonConnect->Caption = blabla;
ButtonConnect->Hint = blablabla;
This makes it highly impractical to have hints and such at all (yes, i'm lazy). I Would love to have a way of defining things so that i just could load in a hunk and then the captions and such were set, this would require that the texts are justified to the longest text for each language but i can live with that. Another way could be to define an array of pointers to set and then make a simple function reading the lines in a language-file and setting the pointers accordingly in sequence. That way a language file could look like:
Caption-of-first-button,
Hint-Of-First-Button,
and so forth. It could be neath with a for(;;) loop to do that! Totte
 
That's what I was talking about. I tried it last night after reading the thread and getting kind of curious... and all I did was go to the bcbdev.com page, grabbed the FAQ on how to make an RC file, stuck the english text in one RC, and the spanish in a second and when they chose a language I switched up the RCs.
It was a simple foreward approach. The worst part was having to go through each one of thse stupid buttons and labels and changing each one's text. and on top of that I had to go through and tanslate all that text. Thank God for freetranslation.com

Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top