473,385 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Localization fails with exe.config file

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
8 3698
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Manish Pansiniya | last post by:
Hello to all, we want to update resource online when administrator changes Localization database. can anybody tell me weather it is possible to run localization toolkit in command line or as...
6
by: Rental | last post by:
I'm having the sam problem as described below with the Localization toolkit. Does anyone know if there is a solution to this problem. --->When attempting to generate resource dlls with...
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
8
by: Olivier Matrot | last post by:
I encounter a problem with Localization features in ASP.NET 2.0. Is seems that the framework is not able to manage neutral cultures such as 'fr', or 'de'. Those are the culture sent by default from...
8
by: VB Programmer | last post by:
I would appreciate your assistance on this ASP.NET 2.0 site.... This is the wierd problem: While accessing the built in .NET functions for 'profiling' or 'membership' an error is generated (see...
3
by: jojobar | last post by:
Hello, I am trying to localize an existing application (asp.net 2.0). using implicit as well as explicit localization. Asp.net 2.0 uses App_LocalResources folder for implicit localization....
5
by: CMM | last post by:
I don't seem to "get" ASP.NET 2.0's Localization features. I've read up on everything... and of course, everything is explained in cursory softball terms- not any "real-world" usage way. I hope...
2
by: bruno | last post by:
I need to localize my ASP.NET app and I just used "Tools" --"generate local resources" command and everything works fine in my WebForms. Resource file name is: MyWebForm.aspx.resx under a subDir...
7
by: AmitKu | last post by:
I am trying to do a URL post using HttpWebRequest, but it fails because I am hosting on Network Solutions, and their servers are all medium trust. Apparently HttpWebRequest doesn't work on medium...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.