Re: messabebox(...) v afxmessanebox
That's a clever idea. You could use constants for the English values (keys)
as well so they don't have to get propagated all over. However, if you're
going to go to all the trouble of duplicating the built in mechanism :o)
Why not just assign IDs as indexes into the vector to add or retrieve the
values:
IDS_WELCOME 1
IDS_COUNTRY 2
IDS_NAME 3
etc.
Then just have a dimension for each language.
IDS_ENGLISH 0
IDS_ITALIAN 1
IDS_SPANISH 2
etc.
Wouldn't that be easier to manage and read?
In my ASP.NET application I use RESX files and I find those to be quite
handy to manage (XML). I don't think it's particularly fast to look up
strings since the key is really another string, but it doesn't seem to be
incredibly slow either so who knows.
This exercise has gotten my brain working :o) I guess I'd still use a
string table in a Unicode based .RC file, but if all you had were error
messages or something like that I could see wanting to keep them in a
separate file to ease the translator's burden... something like the file
resgen can convert (.TXT) which yields:
key1="Some string"
sort of syntax would be a nice way of storing the values. If one ever needs
other resources (dialogs, menus, etc.) then a more robust method would be
more logical IMHO.
Tom
"Giovanni Dicanio" <giovanni.dicanio@invalid.com> wrote in message
news:OVJWn2reIHA.1824@TK2MSFTNGP02.phx.gbl...
"Roger Rabbit" <roger@rabbit.com> ha scritto nel messaggio
news:OfBjM9meIHA.3724@TK2MSFTNGP02.phx.gbl...
Vectors are a Standard Template way of dealing with strings. There are so
many ways to manage strings.
Yes.
I saw code that used std::map to implement string internationalization.
It was kind of map< string, wstring > (i.e. map from a ASCII string to a
Unicode string).
In source code, the strings were written as plain English strings (so
ASCII is fine, so std::string is fine to store them). Using a proper map
(map instance depended on language choosen for localization), the actual
English ASCII string was mapped to the localized (Unicode) string.
This allowed to write code like:
ShowSomeMessage( GLS( "Hello world" ) );
The GLS was a function that went into proper map, passed the input English
string as key, and returned the localized Unicode wstring, e.g. kind of:
std::wstring GLS( const char * s );
This may make the code more readable, at least IMHO I prefer reading
verbose strings like "Hello world" than IDs like IDS_HELLO (particularly
with more complicated and longer messages).
Giovanni