Localization / Globalization / language versions - Where to start?

O

Ole

Hi,

I'm about to localize my C# Framework and Compact Framework applications
into severel different languages but I'm a total novice regarding that, so
where can I find some good information about the subject on the internet?
What is the difference between Localization, Globalization and language
versions ???

Thanks
Ole
 
J

Janos

Hi Ole,

if you go to amazon.com you find some books with the search
net internationalization
net localization

Above that please find below the info I have collected around i18n,
l10n, g???n and so on, (mainly in this group):


Encoding and Localization:
http://msdn2.microsoft.com/en-us/library/h6270d0z.aspx


Localization tutorial?

I've always found CodeProject to be full of useful info (even for
things I'm
not looking for haha) - try this link[1];
[1]http://www.codeproject.com/dotnet/Localization.asp
'Walkthrough: Localizing Windows Forms'
http://msdn2.microsoft.com/en- us/library/y99d1cd3(VS.80).aspx

In fact, the best practice of localizing a WinForm application is
like the
following:
1. Use VS IDE to create WinForms in the application and make each
form
localizable, i.e. set the Localizable property of the form to true
and
build the WinForm application project.
2. When you want the application support another culture later, you
can use
Windows Forms Resource Editor(Winres.exe) to edit the .resx files,
e.g.
Form1.resx. Translate the resource text into another language, e.g.
German,
and save this resx file in German culture, which produces a
Form1.de.resx
file in the same folder where the Form1.resx resides.
3. Use Resgen.exe tool to convert Form1.de.resx file to
ProjectNamespace.Form1.de.resources file(Note, the .resources file
should
have a full name so that the resource could be accessed by the
executable
later). For example, type the following command in the VS2005
command
prompt:
Resgen Form1.de.resx WindowsApplication1.Form1.de.resources
4. Bind all .resources files for a specified culture into a
statellite
assembly using AL.exe tool. For example, you create
Form1.de.resources and
Form2.de.resources files, then you need to bind both the two
*.de.resources
files into a statellite assembly for the culture German. For example,
type
the following command in the VS2005 command prompt:
AL /t:lib /embed:WindowsApplication1.Form1.de.resources
/embed:WindowsApplication1.Form2.de.resources /culture:de
/out:WindowsApplication1.resources.dll
5. Copy the generated satellite assembly
'WindowsApplication1.resources.dll' into a subdirectory named 'de'
under
the folder that the executable resides.
As you can see, we needn't re-compile the existing WinForm
application
project to support another culture.
From Linda Liu
Microsoft Online Community Support

A few precision for beginners like me not to search too long :
Linda Liu said:
2. When you want the application support another culture later, you can use
Windows Forms Resource Editor(Winres.exe) to edit the .resx files

This tool can be found in the .NET Framework 2.0 SDK shortcuts
folder
("Start" menu).
It is labeled "Windows Resource Localization Editor".
3. Use Resgen.exe tool to convert Form1.de.resx file to
ProjectNamespace.Form1.de.resources file(Note, the .resources file should
have a full name so that the resource could be accessed by the executable
later). For example, type the following command in the VS2005 command
prompt:
Resgen Form1.de.resx WindowsApplication1.Form1.de.resources

To run this command first open the command prompt from another
shortcut in
the .NET Framework 2.0 SDK named "SDK Command Prompt".
Otherwise the "resgen" command may not be known (PATH problem).
4. Bind all .resources files for a specified culture into a statellite
assembly using AL.exe tool. For example, you create Form1.de.resources and
Form2.de.resources files, then you need to bind both the two *.de.resources
files into a statellite assembly for the culture German. For example, type
the following command in the VS2005 command prompt:
AL /t:lib /embed:WindowsApplication1.Form1.de.resources
/embed:WindowsApplication1.Form2.de.resources /culture:de
/out:WindowsApplication1.resources.dll

This command should also be executed from the SDL prompt.

see here
http://urenjoy.blogspot.com/2008/11/windows-form-localization-in-net....

Changing Localization on the fly
I've got a windows forms application that uses french and english.
We're
localizing it right now. It does appear to work if I set the
language
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-CA");
Just before we run it.
How can I setup a button that will toggle the language while the
program is
running? It seems once it's running, changing the language has no
effect.
Hi Greg,
you can change it, look how it's done in
Windows Form Designer generated code.
Basically it's working like this:
private void localize(CultureInfo culture)
{
Thread.CurrentThread.CurrentUICulture = culture;
foreach (Form form in Application.OpenForms)
ApplyControlResources(new
ComponentResourceManager(form.GetType()), form);
}

private void ApplyControlResources
(ComponentResourceManager resourceManager, Control control)
{
if (control is Form)
resourceManager.ApplyResources(control, "$this");
else
resourceManager.ApplyResources(control, control.Name);
if (control is IContainerControl)
{
foreach (Control childControl in control.Controls)
{
ApplyControlResources(resourceManager, childControl);
}
}
}

Additional, you have to iterate through each forms menus and do the
same.
Walter
Walter has provided a great solution to this question.
This solution works because the
ComponentResourceManager.ApplyResources
will load the resource dll at runtime. It will not impact the
performance
because the loading will only happen in the first time to apply the
resource and later the resource dll will stay in memory.

..NET 3.5 - how to change default number separator
how to change a default number separator from a colon to comma (I
have
1,23 , I want 1.23) - used in Double.ToString and Double.Parse. I
can
change it by:
Application.CurrentCulture = new CultureInfo("en-US");
, but it changes many other things... I want just to change a
separator.

double ToString has overload that takes a CultueInfo as
argument - in that case it only effects the one conversion.

I hope this helps,
Janos
 
O

Ole

Hi Janos,

Thank you very much!

BR
Ole

Janos said:
Hi Ole,

if you go to amazon.com you find some books with the search
net internationalization
net localization

Above that please find below the info I have collected around i18n,
l10n, g???n and so on, (mainly in this group):


Encoding and Localization:
http://msdn2.microsoft.com/en-us/library/h6270d0z.aspx


Localization tutorial?

I've always found CodeProject to be full of useful info (even for
things I'm
not looking for haha) - try this link[1];
[1]http://www.codeproject.com/dotnet/Localization.asp
'Walkthrough: Localizing Windows Forms'
http://msdn2.microsoft.com/en- us/library/y99d1cd3(VS.80).aspx

In fact, the best practice of localizing a WinForm application is
like the
following:
1. Use VS IDE to create WinForms in the application and make each
form
localizable, i.e. set the Localizable property of the form to true
and
build the WinForm application project.
2. When you want the application support another culture later, you
can use
Windows Forms Resource Editor(Winres.exe) to edit the .resx files,
e.g.
Form1.resx. Translate the resource text into another language, e.g.
German,
and save this resx file in German culture, which produces a
Form1.de.resx
file in the same folder where the Form1.resx resides.
3. Use Resgen.exe tool to convert Form1.de.resx file to
ProjectNamespace.Form1.de.resources file(Note, the .resources file
should
have a full name so that the resource could be accessed by the
executable
later). For example, type the following command in the VS2005
command
prompt:
Resgen Form1.de.resx WindowsApplication1.Form1.de.resources
4. Bind all .resources files for a specified culture into a
statellite
assembly using AL.exe tool. For example, you create
Form1.de.resources and
Form2.de.resources files, then you need to bind both the two
*.de.resources
files into a statellite assembly for the culture German. For example,
type
the following command in the VS2005 command prompt:
AL /t:lib /embed:WindowsApplication1.Form1.de.resources
/embed:WindowsApplication1.Form2.de.resources /culture:de
/out:WindowsApplication1.resources.dll
5. Copy the generated satellite assembly
'WindowsApplication1.resources.dll' into a subdirectory named 'de'
under
the folder that the executable resides.
As you can see, we needn't re-compile the existing WinForm
application
project to support another culture.
From Linda Liu
Microsoft Online Community Support

A few precision for beginners like me not to search too long :
Linda Liu said:
2. When you want the application support another culture later, you can
use
Windows Forms Resource Editor(Winres.exe) to edit the .resx files

This tool can be found in the .NET Framework 2.0 SDK shortcuts
folder
("Start" menu).
It is labeled "Windows Resource Localization Editor".
3. Use Resgen.exe tool to convert Form1.de.resx file to
ProjectNamespace.Form1.de.resources file(Note, the .resources file
should
have a full name so that the resource could be accessed by the
executable
later). For example, type the following command in the VS2005 command
prompt:
Resgen Form1.de.resx WindowsApplication1.Form1.de.resources

To run this command first open the command prompt from another
shortcut in
the .NET Framework 2.0 SDK named "SDK Command Prompt".
Otherwise the "resgen" command may not be known (PATH problem).
4. Bind all .resources files for a specified culture into a statellite
assembly using AL.exe tool. For example, you create Form1.de.resources
and
Form2.de.resources files, then you need to bind both the two
*.de.resources
files into a statellite assembly for the culture German. For example,
type
the following command in the VS2005 command prompt:
AL /t:lib /embed:WindowsApplication1.Form1.de.resources
/embed:WindowsApplication1.Form2.de.resources /culture:de
/out:WindowsApplication1.resources.dll

This command should also be executed from the SDL prompt.

see here
http://urenjoy.blogspot.com/2008/11/windows-form-localization-in-net....

Changing Localization on the fly
I've got a windows forms application that uses french and english.
We're
localizing it right now. It does appear to work if I set the
language
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-CA");
Just before we run it.
How can I setup a button that will toggle the language while the
program is
running? It seems once it's running, changing the language has no
effect.
Hi Greg,
you can change it, look how it's done in
Windows Form Designer generated code.
Basically it's working like this:
private void localize(CultureInfo culture)
{
Thread.CurrentThread.CurrentUICulture = culture;
foreach (Form form in Application.OpenForms)
ApplyControlResources(new
ComponentResourceManager(form.GetType()), form);
}

private void ApplyControlResources
(ComponentResourceManager resourceManager, Control control)
{
if (control is Form)
resourceManager.ApplyResources(control, "$this");
else
resourceManager.ApplyResources(control, control.Name);
if (control is IContainerControl)
{
foreach (Control childControl in control.Controls)
{
ApplyControlResources(resourceManager, childControl);
}
}
}

Additional, you have to iterate through each forms menus and do the
same.
Walter
Walter has provided a great solution to this question.
This solution works because the
ComponentResourceManager.ApplyResources
will load the resource dll at runtime. It will not impact the
performance
because the loading will only happen in the first time to apply the
resource and later the resource dll will stay in memory.

.NET 3.5 - how to change default number separator
how to change a default number separator from a colon to comma (I
have
1,23 , I want 1.23) - used in Double.ToString and Double.Parse. I
can
change it by:
Application.CurrentCulture = new CultureInfo("en-US");
, but it changes many other things... I want just to change a
separator.

double ToString has overload that takes a CultueInfo as
argument - in that case it only effects the one conversion.

I hope this helps,
Janos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top