Globalization & Localization

Hello,

I'm working through the WPF Globalization & Localization tutorials. This is a very powerful feature. And pretty easy to use. I was able to Globalize my application.

I also followed the instruction to localize my application (with culture de-DE). But when I change my regional and langauge options I still see the english text (from culter en-US)?

Here is how I'm doing it:

* Add <UICulture>en-US</UICulture> to MyApp.csproj

* Build the app.

* Use LocBaml.exe to generate csv file.

* I change the csv file.

* Use LocBaml to generate a new MyApp.resources.dll

* Create a directory in my bin\debug foder and call it 'de-DE'.

* Copy the generated MyApp.resources.dll into the de-DE

* Go to control panel and change regional and language options to German(Germany).

* Start MyApp.exe...it still shows the english text. But at this pointsome of the labels in Outlook have changed to german. So I think the my OS culture is changing. But my application doesn't recognize the change.

Thanks in advance

Houman

[1128 byte] By [Houmanb] at [2007-12-24]
# 1

Hello Houman,

The resource loading is based on UICulture - the localization of the operating system, and cannot be affected by changes in Control Panel regional settings. You have two options to load your localized resources:

1. Install a localized German operating system and run your localized app from there.

2. Inside your app change Thread UICulture to de-DE to imitate localized OS.

I hope this helps,

-Alik

AlikKhavin-MSFT at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

Thanks Alik, for the quick response.

I tried option 2:

In my window's constructor I put the following line of code:

System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture("de-DE");

It still showed the english text.

Then I inserted the same line of code into the App constructor...it gave me a runtime error: Cannot locate resource 'window1.xaml'.

Thanks again,

Houman

Houmanb at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3

I usually use System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE"); to set this.

Make sure you build your resource correctly with de-DE culture and output it into a correct folder. If you still can't get it to work, please share your sample so that I can help you further.

AlikKhavin-MSFT at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 4

Thanks Alilk,

I tried that it still gives me the same runtime exception.

Here is the constructor for my app:

public partial class App : System.Windows.Application
{
public App() : base()
{
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("de-DE");

System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
}
}

To be honest, I'm not sure if I'm creating the my resources.dll peroperly...I'm just taking the output of LocBalm (MyApp.resources.dll ) and putting it in ..\bin\Debug\de-DE.

Moreover, I'm not sure why after I put in the above code I get the runtime error:

System.IO.IOException was unhandled
Message="Cannot locate resource 'window1.xaml'."
Source="PresentationFramework"
StackTrace:
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.get_ContentType()
at System.Windows.Navigation.BaseUriHelper.GetContentType(WebResponse response)
at System.Windows.Navigation.NavigationService.GetObjectFromResponse(WebRequest request, WebResponse response, Uri destinationUri, Object navState)
at System.Windows.Navigation.NavigationService.DoNavigate(Uri source, NavigationMode f, Object navState)
at System.Windows.Navigation.NavigateQueueItem.Dispatch(Object obj)

Thanks for all your help.

Houman

Houmanb at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 5

Sounds like you did everything correctly. See if any suggestions in the post below are relevant to your case: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=437085&SiteID=1

The reason you are getting this exception message is that during resource loading the window1.baml resource that is matching the currentUI culture on the thread cannot be accessed or located.

If you can share your sample, I can help you figure out what the problem is.

AlikKhavin-MSFT at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 6

hi ......

i need to help to implementation of localization in my application.

i have many forms and user controls in my application.

i don't want create .resx file for all forms or user controls,in case if i have handle like that i have to many .resx file in my application.

like if i 30 forms and 20 user controls and i want use 10 language in my application for that i have to handle (30+20)*10=500 files in extra.

so please give me proper solution and suggesstion for that

thanks

genious at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified