|
You should start by reading Developing World-Ready Applications[^] in the .NET Framework SDK.
You should also understand the difference between globalization and localization, the former being how dates, times, and numbers are formatted, while the latter is how text is read according to the current language. Respectively, each is represented by CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture , which could easily be different.
Developing a world-ready application using VS.NET is very easy. Develop your user interface, then use the PropertyGrid with the entire Form selected to set "Localizable" to true , then select the language. The neutral language is in whatever language you've developed the application (like "en-US" for U.S. English), so do not use that language. The neutral text will be compiled into resource files and embedded into your primary assembly (the assembly with the IL module(s) that is your compiled code), while any other languages are compiled into satellite assemblies. To make look-ups faster, you should define for your assembly an assembly-level attribute named NeutralResourcesLanguageAttributE using the locale/language in which you developed your application originally, like so:
[assembly: NeutralResourcesLanguage("en-US")] This will save a separate look-up for satellite assemblies when that particular language is the current locale and language. This is especially important if you're deploying your managed code via touchless deployment over the web.
I architected a solution using this concept, though I didn't use VS.NET because it's rather inefficient for enterprise applications. This will be greatly improved in Visual Studio 2005 using the ComponentResourceManager instead of the ResourceManager at design-time. Both classes have been defined since .NET 1.0, but the designer - up until VS 2005 - has been using the ResourceManager which can bloat your codebase by localizing every property attributed with the LocalizableAttribute , which is quite a few.
Even after compiling, either you or your clients can use the Winres.exe[^] tool. This only works if you use VS.NET's localization designer, or hack your .ResX files to make it look like VS.NET created the files.
There are a few articles on localization here on CodeProject, so I urge you to also search for them. For just localizing an application, however, it's quite easy. Use the VS.NET designer to localize an application and view what the designer did (it is, after all, just code and XML files (.ResX files, which are compiled into .resources files using the same functionality as the command-line tool resgen.exe). To make it easier, show all hidden files by clicking on the "Project" menu, then "Show Hidden Files" (or something similar to that).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi Heath,
Thank you very much for replying to my post, I really appreciate it.
Do you have any thoughts on whether it is better to put cultural resource strings for each language into 1 xml file? I haven't written a multi-lingual app yet, but I would imagine it would be easier to send 1 xml file per language to a translater rather than 1 form resource file that .NET normally uses....
However if this was done then it would be more work and a custom resource load routine would be required for each form.
The normal .NET way is to set the form localizable property to true and then select the language and go off and enter all of the labels for that language... To me that seems problematic because:
1. The same caption might be used on more than one form. If one developer has to update all of the "Name" captions on every form, then the chances of them missing one or more could be high for an application with many forms.
2. How does that work in practice for a translater? Does the translater need a copy of VS.NET installed and they go through each and every form in the designer? Or do you set the default language for each form. And if your application has 50 forms, then you send 50 resource files to a translater?
Did you face any of these issues when you did your multi-ligual application?
Cheers,
Daffrey
|
|
|
|
|
Normally you should have one resource file for each language. So when having three languages, you should have 3 resource files.
For your other question, I think (but I'm not sure) you can use the same caption for more than 1 form. So this should be no problem.
For the translator, you don't have to send 50 resource files but only the number of your languages. In these resource files everything is kept together for that language and as far as I know, your translator doesn't need a copy of VS.Net. As long as you give him the not compiled resource files, because these are XML files.
|
|
|
|
|
What you send to the translators doesn't necessarily have to be what you compile into resource files, so do whatever makes it easier. Since they are XML files (and you can also use plain text files using key=value pairs, but then you can only localize strings and not any Type that is attrbuted with a specific TypeConverter ), you can do just about whatever you want.
When you compile the resource files, however, they must be compiled into separate satellite assemblies. These satellite assemblies are identified by a specific culture.
Take a fully-qualified assembly name:
System, culture=neutral, version=1.0.5000.0, publicKeyToken=b77a5c561934e089 Notice the neutral? Primary assemblies (those assemblies that contain the IL module(s)) must always be neutral (but can contain your neutral language, which is why I mentioned using the assembly-level attribute NeutralResourcesLanguageAttribute for faster look-ups). Satellite assemblies replace "neutral" with whatever locale/language for which they were compiled.
Both the ResourceManager and the ComponentResourceManager (which extends the former) look-up resources in satellite assemblies using this information. You could create your own resource manager classes to look for resources in a single assembly, but there's so many problems with that.
It's inflexible and bloats the size of your assemblies when N-1..3 languages are necessary for any particular user (1..3 denotes cases when have locale-specific resources, which fallback to language-specific resources, which fallback to neutral resources). You also loose the ability to integrate with visual designers, unless you plan on implementing your own plugins for each designer instead of making the designers work for you (which is how the ComponentModel currently works).
Be sure to read-up on the classes I've mentioned as well as the links I gave you. It explains a lot of information.
Just going through an example of localizing a simple sample application and examining the code really helps, too. Create a new project, throw some controls on the form, assign some text, then localize it using the steps I've mentioned. Examine the source, compile the project, and examine the output. You can learn a lot from such an example.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi all,
Do the SQL Server CE on Pocket PC have the capability of recording locking ?
Thanks
|
|
|
|
|
From the documentation, locking is used by the engine which does not accept hints like with SQL Server 2000 and other mature RDBMS's. SQL Server CE is lightweight and does not implement many features.
For specific information on locking, please see the documentation listed above - especially the second item.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi~
I have encountered a very difficult problem and worked for a long time but still can't solve it. Pls help it.
The problem is :
There are two cases. One is for .net full vesion, one is for .net compact framework.
For the .net full version, "ListViewEx" is a class which extend listView.
class ListViewEx : ListView
{
ListViewEx()
{
}
protected override OnPaint(PaintEventArg e)
{
MessageBox.Show("ABC");
base.OnPaint();
}
The problem is the overriding OnPaint not be executed if a instance of this class newly be created but the base class (I don't know the method (OnPaint()) of the class "Control" or class "ListView" will be called and draw the listview only without showing message box.
However, the overriding OnPaint method seems works if the extended window control is not listview but button or panel. (Other control also not work). What is the problem?
For the CF case,
The case is that the if Class for example "ListViewEx2" extend the class ListView, the overriding Method OnPaint() still not work since the virtual void OnPaint method in the ListView Class is not supported.
However, as the ListView extend Control, and the control also got the virtual method OnPaint(), that mean the ListViewEx2 also got the virtual OnPaint method and which can be overrided by ListViewEx2. Then why the overrided method in ListViewEx2 does not executed?
Thanks
}
|
|
|
|
|
OnPaint is not used by the ListView control, as you could see by disassembling or decompiling the System.Windows.Forms.dll assembly.
Almost every control in Windows Forms simply encapsulates the Winodws Common Controls. In the case of some controls like ListView owner drawing the control simply by overriding OnPaint is not possible. To owner draw a List-View common control you need to override WndProc , define several custom drawing structures, and P/Invoke several native APIs.
For more information about the native List-View common control that is encapsulated by the ListView managed control, see http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/listview/reflist.asp[^].
For examples on this site about owner-drawing a ListView control, see the search http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=ListView[^].
You could also try searching this forum for "ListView" by clicking "Search comments" directly above this message area. We've talked about custom drawing a ListView quite a bit, and I know that I personally have posted several snippets of code that show how to draw certain parts through the custom drawing routines that the native Common Controls use.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Sorry - stupid question most probably - is C# platform independant like C++ or is it Microsoft based (like VC++)?
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
The language itself has been submitted for ECMA, the language specification is available here: C# Language Specification[^]. You can actually download (from Microsoft) the Shared Source CLI which is the ECMA CLI and C# language specification here: Shared Source Common Language Infrastructure 1.0 Release[^]. You will find specific namespaces such as System.Windows.Forms that have been written to wrap specific Windows functionality that is meant to target Windows, controls specifically for that namespace. There is also a port that will run under Linux called Mono which can be found here[^], this is targetting the ECMA standard.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Can we Serialize an enter Form?
|
|
|
|
|
And what do you mean by an "enter Form". It's rather ambiquous, and serialization doesn't really care what kind of object you're serializing so long as its attributed directly with SerializableAttribute . That attribute is not inheritted. Since the Form class is not attributed with SerializableAttribute , then you need to attribute your derivative class.
But ask yourself why you need to serialize it and what, specifically, you need to serialize. Much of the form is specific to that instance and should not be serialized (like the Handle ) if you plan on either re-creating it or saving it across multiple sessions (a session being separate logins, processes, etc.).
To control how your form (or any object) is serialized, implement ISerializable .
For more information on serialization, read Serializing Objects[^] in the .NET Framework SDK online. The SDK is also installed by default with VS.NET and can be installed stand-alone from http://msdn.microsoft.com/netframework[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi everybody I have a problem with DataGrid Control, That is:
I try to extract the column number and the row number by double click anywhere on the Datagrid
But there is no response by DoubleClick event when I try to DoublClick any Cell in the DataGrid ,the response occurs when I just click the Header Column or Header Row please can I get some help.
|
|
|
|
|
1.Firstly, DoubleClick event should fire, without any doubt. I do not find any problem in it.
2.Click or DoubleClick Event Handler of the DataGrid or other Controls has EventArg argument, you would not be getting the colum number / row number information from the EventArg . You should use either
MouseDown or MouseUp event Handler which has MouseEventArgs in the arguments.
MouseDown Event and HitTest method will get you the desired.
Refer the below link for details.
DataGrid HitTest Method[^]
|
|
|
|
|
sir,
i need to get system informations such as number of services,etc.i write queries such as select * from Win 32_service etc.But i don't know more about this table.I want to use some where clause also in the above query.for eg: i want to get all services whose mode is manual.I need column names for Win32_service
help mee
|
|
|
|
|
|
thank you very much,Mr.Nick Parker.You gave me the correct link
|
|
|
|
|
|
Hi,
I am writing a forms based application, which has been working fine, until I moved my project to another computer with the same version of Visual studio. Now my initial form does not show up at all.
This is what I have done:
I have a console application that starts three forms, one after the other. Each form implements two methods invloved in starting the form in its own separate thread.
class UIForm : ....
{
Thread formThread = null;
public void OpenForm()
{
// formThread is a private member of the current form
formThread = new Thread( new ThreadStart( this.ShowForm ) );
formThread.Start();
}
private void ShowForm()
{
Application.Run( this );
}
.
.
.
}
The console application then starts the form like this:
UIForm theForm = new UIForm();
theForm.OpenForm();
This worked fine until I moved my project to another machine.
Any help, comments or advise is much appreciated!!
Thanks!
|
|
|
|
|
Given my limited understanding of all things .Net, take what I say with a grain of salt.
The thread that creates the window must be the one that updates the window. The thread that creates the window must also participate in a message loop. Although you may get away with violating these rules some of the time, it is guarenteed to bite you in the butt sometime in the future.
Unless you are doing something really special, I would have one thread handle all of the UI and have the other threads doing non-UI stuff. Use Form.Invoke() to handle communication between the threads.
|
|
|
|
|
I agree to what you say, but I don't see how I violate any of the rules in the startup phase. The form is started in its own thread, which should then be bound to the message loop. Or have I misunderstood things?
|
|
|
|
|
You created the window using one thread then executed another to make it visible. This violates the first principle I stated above.
Try creating the window with the new thread.
|
|
|
|
|
Thank you very much! I discovered your solution by trial and error, but I did not understand why. Now I now that there is something behind it. Again, thank you.
|
|
|
|
|
Hello, i'm having a problem getting an byte[] out of an arraylist...
I use an enumerator so the code is as followed:
bIpAdres = Convert.ToByte(ipsEnum.Current);
bIpAdres however is a byte[], and the values in the collection are also arrays, but writing
Convert.ToByte[]
doesn't work.
How should I do this?
Grtz, Bert
|
|
|
|
|
While the answer is in the documentation, the name should say enough: Convert.ToByte converts an argument to a single byte . Notice how it's singular?
If ipsEnum.Current represents a byte[] array, then simply cast it:
bIpAdres = (byte[])ipsEnum.Current;
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|