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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

App Using Localization

Status
Not open for further replies.

lucyv

Programmer
Mar 11, 2002
152
US
I'm writing a small application that needs to display text in different languages (english, spanish and french). I'm torn between using the Localization object and writing my own procedures (storing the appropriate text in outside .ini files).

I know I would be "re-inventing the wheel" if I write my own procedures, but I feel more comfortable controlling what is displayed in my app then depending on the Localization/Culture objects. Does anyone have any input on this? Would this be a totally bad thing to do?

-lucyv
 
Do you have limited words, phrases, sentences, or could it be unlimited somehow? If it is limited, test it for what you want. If it works, use it, otherwise do your own thing. :)
 
My initial thought was that is was going to be limited (small/easy). But as the application is growning I'm seeing that the words and phrases would be very large. That is why I was thinking about writing my own thing.

-lucyv
 
My advice would be to use the .net provided localization support, as it's integrated into the framework and works pretty much transparently.

That being said, the default editor for .resx files in VS.NET is really awkward to use (stupid columns keep resizing themselves when you ctrl+tab away). You're probably better off using an XML editor on those files, once you've set up a few types of resources (strings, icons, etc) to provide a pattern.

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks for the advice Chip. Do you know of any good sites that help illustrate this? I've done some searching on the web and in text books but I haven't found too much.

-lucyv
 
I dont' like to say it but I disagree with chiph. I tried localization and I think it creates way to much ballast, as a matter of fact it creates every form for every language you put in to it. And I don't know if you can really say it is flexible. My system uses sql-server tables wich can be altered by users that speak the language better then me and that way the app gets the right words withot having to update it. And I never seemed to be able to change the language at runtime. And what about messagebox messages? Exceptions?

But of course it all depends on your needs and wishes.

I think you would be better of creating your own procedures. But that is just my opinion.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Thanks for your opinion Chrissie. Last night I play around with creating my own procedures and its not as bad as I thought. I like your suggestion about storing the words/phrases in sql tables, but unfortunately, because of the nature of my app, this would not be feasible. That is why I think storing the words/phrases in outside files would be best for me. I would make updates a whole lot easier.

Thanks!!!

-lucyv
 
Once you get past all the boilerplate stuff in the .resx files, adding strings is a matter of inserting values in <data/> tags:
Code:
<data name="CantPassTwoZeros" type="System.String">
	<value>Can't pass two zeros</value>
</data>
The name attribute is what you pass to your instance of the ResourceManager class.
Code:
if (filteredArray.Length < 2) then
    throw new ArgumentException(rm.GetString("NeedTwoValues"), "array")
end if
You get an instance of a ResourceManager by doing something like this:
Code:
private shared ResourceManager rm = new ResourceManager("defaultnamespace.resourcefilename", 
            Assembly.GetExecutingAssembly())
Hope this helps.

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Whoops - the parameter to rm.GetString is supposed to match the name attribute of the data tag in the resx file. Sorry!

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top