By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,028 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,028 IT Pros & Developers. It's quick & easy.

Localization fails with exe.config file

P: n/a
Hi,
in a Windows form VB.Net project I use localization for all texts.
In App.Config I added:

<appSettings>
<add key="locale" value="de"/>
</appSettings>

In the project I have ressource files strings.resx (English text) and
strings.de.resx for the German texts.

In the Main Module I use the follwow√*ng code:
Imports System.Configuration
Imports System.Resources
Imports System.Globalization
Imports System.Threading
.......

Friend M_LocRM As ResourceManager
Friend M_Locale As String
......

Sub Main()
M_Locale = ConfigurationSettings.AppSettings.Get("locale")

Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(M_Locale)
Thread.CurrentThread.CurrentUICulture = New CultureInfo(M_Locale)

M_LocRM = New ResourceManager("MyNamespace.Strings",
GetType(MyMainModule).Assembly)
......

For all texts I then use the GetString method of the ResourceManager M_LocRM.

This works fine, as long as I debug the project: changing the value of
'locale' in app.config from 'en' to 'de' (and vice versa) gives all the texts
in German or English like it should be.

When I install MyFunction.exe in a different folder (say c:\program
files\MyFunction) together with the config file MyFunction.exe.config it does
not work any more:

Changing the value of 'locale' in the config file has no effect, as only the
entries of the ressource file 'strings.resx' are used. Changing the locale
from 'en' to 'de' has not the effect that the entries of 'strings.de.resx'
are used.

Why? Can anybody give me some hint, as the above described implementation
works fine in any of my ASP.Net projects but not in my Windows form projects.

--
Best regards

Henry
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Henry,

I dont, know however is this one not easier
(I dont know how it acts with multithreading for a complete application so
that you have to check)

Threading.Thread.CurrentThread.CurrentCulture = New _
Globalization.CultureInfo("en-US")

And than this one when you need to set it back in the program, what I doubt
that that is needed.
Threading.Thread.CurrentThread.CurrentCulture = _
Globalization.CultureInfo.InstalledUICulture

I hope this helps

Cor
Nov 21 '05 #2

P: n/a
Henry,
When I install MyFunction.exe in a different folder (say c:\program
files\MyFunction) together with the config file MyFunction.exe.config it
does
not work any more: Do you also remember to install the respective language DLLs to c:\program
files\MyFunction also?

You should be able to copy the folder structure under the bin folder in
VS.NET.

Hope this helps
Jay

"Henry" <he********@nospam.nospam> wrote in message
news:25**********************************@microsof t.com... Hi,
in a Windows form VB.Net project I use localization for all texts.
In App.Config I added:

<appSettings>
<add key="locale" value="de"/>
</appSettings>

In the project I have ressource files strings.resx (English text) and
strings.de.resx for the German texts.

In the Main Module I use the follwowŪng code:
Imports System.Configuration
Imports System.Resources
Imports System.Globalization
Imports System.Threading
......

Friend M_LocRM As ResourceManager
Friend M_Locale As String
.....

Sub Main()
M_Locale = ConfigurationSettings.AppSettings.Get("locale")

Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(M_Locale)
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(M_Locale)

M_LocRM = New ResourceManager("MyNamespace.Strings",
GetType(MyMainModule).Assembly)
.....

For all texts I then use the GetString method of the ResourceManager
M_LocRM.

This works fine, as long as I debug the project: changing the value of
'locale' in app.config from 'en' to 'de' (and vice versa) gives all the
texts
in German or English like it should be.

When I install MyFunction.exe in a different folder (say c:\program
files\MyFunction) together with the config file MyFunction.exe.config it
does
not work any more:

Changing the value of 'locale' in the config file has no effect, as only
the
entries of the ressource file 'strings.resx' are used. Changing the locale
from 'en' to 'de' has not the effect that the entries of 'strings.de.resx'
are used.

Why? Can anybody give me some hint, as the above described implementation
works fine in any of my ASP.Net projects but not in my Windows form
projects.

--
Best regards

Henry

Nov 21 '05 #3

P: n/a
Henry,

I took the wrong one sorry
Threading.Thread.CurrentThread.CurrentUICulture = New
Globalization.CultureInfo("en-US")

And that than direct in the New sub

Cor
Nov 21 '05 #4

P: n/a
Jay,
Do you also remember to install the respective language DLLs to c:\program
files\MyFunction also?


Edify me?

:-)

I know that I can use different framework versions depending on the OS that
is used.

However language dll's?

Cor
Nov 21 '05 #5

P: n/a
Cor,
http://msdn.microsoft.com/library/de...nalization.asp

http://msdn.microsoft.com/library/de...gresources.asp

The directory structure itself is shown at the bottom of:

http://msdn.microsoft.com/library/de...assemblies.asp

When you use VS.NET to create your international resources VS.NET create the
folder structure needed in the bin (output) folder.

Hope this helps
Jay

"Cor Ligthert" <no************@planet.nl> wrote in message
news:em**************@TK2MSFTNGP15.phx.gbl...
Jay,
Do you also remember to install the respective language DLLs to
c:\program files\MyFunction also?


Edify me?

:-)

I know that I can use different framework versions depending on the OS
that is used.

However language dll's?

Cor

Nov 21 '05 #6

P: n/a
Jay,

Thanks, I did make an application which is more global, however did not use
the resx for that however an xml. (I still find the RESX a lot of work
although I have now that C# program to edit it).

But now I see what you mean with that dll.

(The links where not needed by the way, your text was enough)

Cor
Nov 21 '05 #7

P: n/a
Hi Jay,

that was of course the fault: I forgot to include the 'en' subfolder of the
bin folder in my setup projet ... Thanks a lot

Regards

Henry

"Jay B. Harlow [MVP - Outlook]" wrote:
Henry,
When I install MyFunction.exe in a different folder (say c:\program
files\MyFunction) together with the config file MyFunction.exe.config it
does
not work any more:

Do you also remember to install the respective language DLLs to c:\program
files\MyFunction also?

You should be able to copy the folder structure under the bin folder in
VS.NET.

Hope this helps
Jay

"Henry" <he********@nospam.nospam> wrote in message
news:25**********************************@microsof t.com...
Hi,
in a Windows form VB.Net project I use localization for all texts.
In App.Config I added:

<appSettings>
<add key="locale" value="de"/>
</appSettings>

In the project I have ressource files strings.resx (English text) and
strings.de.resx for the German texts.

In the Main Module I use the follwow√*ng code:
Imports System.Configuration
Imports System.Resources
Imports System.Globalization
Imports System.Threading
......

Friend M_LocRM As ResourceManager
Friend M_Locale As String
.....

Sub Main()
M_Locale = ConfigurationSettings.AppSettings.Get("locale")

Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(M_Locale)
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(M_Locale)

M_LocRM = New ResourceManager("MyNamespace.Strings",
GetType(MyMainModule).Assembly)
.....

For all texts I then use the GetString method of the ResourceManager
M_LocRM.

This works fine, as long as I debug the project: changing the value of
'locale' in app.config from 'en' to 'de' (and vice versa) gives all the
texts
in German or English like it should be.

When I install MyFunction.exe in a different folder (say c:\program
files\MyFunction) together with the config file MyFunction.exe.config it
does
not work any more:

Changing the value of 'locale' in the config file has no effect, as only
the
entries of the ressource file 'strings.resx' are used. Changing the locale
from 'en' to 'de' has not the effect that the entries of 'strings.de.resx'
are used.

Why? Can anybody give me some hint, as the above described implementation
works fine in any of my ASP.Net projects but not in my Windows form
projects.

--
Best regards

Henry


Nov 21 '05 #8

P: n/a
Henry,
If you are using a Setup Project to deploy your app (as opposed to coping
the files). You should add the localized resources to your setup project (as
opposed to adding the "bin/en" or "bin/de" folders directly. As this will
allow new localized languages to automatically be included in the setup!
(for example "bin/fr" for French support).

Use "Project - Add - Project Output", then select the project with the
localized resources under Project, select "Localized resources" in this list
box, and click OK. I normally include localized resources for all my
projects in a solution, even if those projects are not yet localized...

The setup project will then put create the language folders & deploy the
language dll's for you...

Hope this helps
Jay

"Henry" <he********@nospam.nospam> wrote in message
news:37**********************************@microsof t.com...
Hi Jay,

that was of course the fault: I forgot to include the 'en' subfolder of
the
bin folder in my setup projet ... Thanks a lot

Regards

Henry

"Jay B. Harlow [MVP - Outlook]" wrote:
Henry,
> When I install MyFunction.exe in a different folder (say c:\program
> files\MyFunction) together with the config file MyFunction.exe.config
> it
> does
> not work any more:

Do you also remember to install the respective language DLLs to
c:\program
files\MyFunction also?

You should be able to copy the folder structure under the bin folder in
VS.NET.

Hope this helps
Jay

"Henry" <he********@nospam.nospam> wrote in message
news:25**********************************@microsof t.com...
> Hi,
> in a Windows form VB.Net project I use localization for all texts.
> In App.Config I added:
>
> <appSettings>
> <add key="locale" value="de"/>
> </appSettings>
>
> In the project I have ressource files strings.resx (English text) and
> strings.de.resx for the German texts.
>
> In the Main Module I use the follwowŪng code:
>
>
> Imports System.Configuration
> Imports System.Resources
> Imports System.Globalization
> Imports System.Threading
> ......
>
> Friend M_LocRM As ResourceManager
> Friend M_Locale As String
> .....
>
> Sub Main()
> M_Locale = ConfigurationSettings.AppSettings.Get("locale")
>
> Thread.CurrentThread.CurrentCulture =
> CultureInfo.CreateSpecificCulture(M_Locale)
> Thread.CurrentThread.CurrentUICulture = New
> CultureInfo(M_Locale)
>
> M_LocRM = New ResourceManager("MyNamespace.Strings",
> GetType(MyMainModule).Assembly)
> .....
>
> For all texts I then use the GetString method of the ResourceManager
> M_LocRM.
>
> This works fine, as long as I debug the project: changing the value of
> 'locale' in app.config from 'en' to 'de' (and vice versa) gives all the
> texts
> in German or English like it should be.
>
> When I install MyFunction.exe in a different folder (say c:\program
> files\MyFunction) together with the config file MyFunction.exe.config
> it
> does
> not work any more:
>
> Changing the value of 'locale' in the config file has no effect, as
> only
> the
> entries of the ressource file 'strings.resx' are used. Changing the
> locale
> from 'en' to 'de' has not the effect that the entries of
> 'strings.de.resx'
> are used.
>
> Why? Can anybody give me some hint, as the above described
> implementation
> works fine in any of my ASP.Net projects but not in my Windows form
> projects.
>
> --
> Best regards
>
> Henry


Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.