home recent topics recent posts search faq  

RC-WinTrans Forum



register | lost password | |
Messages in this topic - RSS

Home » RC-WinTrans Support » WPF Translation

For support issues and specific questions related to RC-WinTrans' use, features and functions.
28.02.2011 09:41:19

MichaelTR
MichaelTR
Posts: 15
Hello
I'm trying to translate a WPF program.

There are two options in RC-WinTrans:

1. Use the exe as a source.
This produces a .resources.dll file under a folder called after the choosen language (e.g. "en").
How can I choose this language at program startup?
I tried
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
Thread.CurrentThread.CurrentCulture = new CultureInfo("en");
in the construcor of the App to no avail.
Is there something else I have to do, or is there a sample available to use this method?

2. Use the xaml files as a source (this would be my preferred way, because I already use RC WinTrans to translate the resource files for C++ and Windows Forms apps).
This produces _en.xaml files for each source file.
How can I now integrate these files into my app?
 
BTW: I already took a look at the samples in WPFProjects folder. It's not possible to build these projects, because of missing files.
 
TIA Michael
0 permalink
01.03.2011 16:11:55

Support
Support
Administrator
Posts: 245
Hello MichaelTR,

1. How can I choose this language at program startup?

Use:
System.Globalization.CultureInfo aCultureInfo = new System.Globalization.CultureInfo("en");
System.Threading.Thread.CurrentThread.CurrentUICulture = aCultureInfo;

This is the same as your code I think.

You can test switching the language of your application by using the small LocTester application.
When using LocTester you do not need to implement setting the language with "CurrentUICulture".

LocTester:
http://blogs.microsoft.co.il/blogs/tamir/archive/2007/08/26/How-to-test-localized-application_3F00_.aspx

Download:
http://blogs.microsoft.co.il/files/folders/tamir/entry23129.aspx



2. Use the xaml files as a source

> How can I now integrate these files into my app?

It is not possible to add localized versions of an XAML file to a Visual Studio project like you can with RESX files.
We would also like to have the option of working with translated XAML files directly but unfortunately it can't be done.

3. WPFProjects

> BTW: I already took a look at the samples in WPFProjects folder. It's not possible to build these projects, because of missing files.

These are not sample projects. They are two Visual Studio projects used by RC-WinTrans to create a binary BAML file from an XAML file.
.

Regards,
Support, Schaudin.com
.
edited by Support on 04.03.2011
0 permalink
02.03.2011 14:08:32

Support
Support
Administrator
Posts: 245
Hello MichaelTR,

there is something else...
The XAML elements in your WPF software project (Visual Studio) must have "x:Uid" attributes to be localizable. RC-WinTrans can read (and translate) the WPF resources without having the "x:Uid" attributes but the WPF resources in the target satellite DLL (created by RC-WinTrans) will keep the source text if no "x:Uid" attributes exists.

You can use RC-WinTrans to prepare a Visual Studio WPF project (the XAML files) with the required "x:Uid" attributes.
Use: "Tools" | "WPF" | ".NET Project update "x:Uid" attributes..."
Select your Visual Studio project file (e.g. for C#: .csproj). Then rebuild your WPF project to create the assembly (EXE or DLL) newly.

Regards,
Support, Schaudin.com
.
edited by Support on 04.03.2011
0 permalink
02.03.2011 15:30:11

MichaelTR
MichaelTR
Posts: 15
I now found a problem, which maybe a bug in RCWinTrans.

In AssemblyInfo.cs Microsoft says:
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>.


If I do this, RCWinTrans cannot find any WPF resources in the exe anymore.

If I omit this line the exe crashes immediately.
0 permalink
02.03.2011 15:47:04

MichaelTR
MichaelTR
Posts: 15
Support wrote:
You can use RC-WinTrans to prepare a Visual Studio WPF project (the XAML files) with the required "x:Uid" attributes.
Use: "Tools" | "WPF" | ".NET Project update "x:Uid" attributes..."
Select your Visual Studio project file (e.g. for C#: .csproj) . Then rebuild your WPF project to create the assembly (EXE or DLL) newly.


Doesn't do anything.

Running MSBuild.exe ...
C:\Programme\RC-WinTrans\RC-WinTrans 9 Global\WPFProjects\BAMLBuild2010\MSBuild.exe /t:updateuid C:\mist\WpfSprachumschaltung\WpfSprachumschaltung\WpfSprachumschaltung.csproj
Output:
0 permalink
02.03.2011 19:55:10

Support
Support
Administrator
Posts: 245
Hello MichaelTR,

1.
> <UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
> I now found a problem, which maybe a bug in RCWinTrans.
> If I do this, RCWinTrans cannot find any WPF resources in the exe anymore

No, not a bug. This is correct.

When using the <UICulture> in the project file (.csproj) Visual Studio builds a satellite DLL and puts the resources into it. The application assembly no longer contains the resources.
When using a satellite DLL for the default resources you must translate this satellite DLL with RC-WinTrans- not the EXE.
My suggestion: leave the default resource in the EXE. Do not use the <UICulture>.

See also (at Microsoft): "Localize a WPF Application"
http://msdn.microsoft.com/en-us/library/ms788718.aspx#workflow_to_localize
.

2.
> "Tools" | "WPF" | ".NET Project update "x:Uid" attributes..."
> Doesn't do anything.

Nothing happens in RC-WinTrans but for your Visual Studio project. RC-WinTrans call the msbuild.exe (Microsoft command line tool) to add the "x:Uid" attributes to your VS project's source XAML files. Check the XAML files -- the elements should have "x:Uid" attribute now.

See at Microsoft: "Best Practice for WPF Localization"
http://msdn.microsoft.com/en-us/library/ms788718.aspx

.

Regards,
Support, Schaudin.com
.
edited by Support on 04.03.2011
0 permalink
03.03.2011 09:33:11

MichaelTR
MichaelTR
Posts: 15
Support wrote:

Nothing happens in RC-WinTrans but for your Visual Studio project. RC-WinTrans call the msbuild.exe (Microsoft command line tool) to add the "x:Uid" attributes to your VS project's source XAML files. Check the XAML files -- the elements should have "x:Uid" attribute now.


No, it doesn't add any x:Uid to the elements in xaml.

Shouldn't there be any output message in the RCWinTrans output?
0 permalink
04.03.2011 10:00:58

Support
Support
Administrator
Posts: 245
RC-WinTrans writes the output from the msbuild.exe tool to the RC-WinTrans Output window.

Example:
-------------------------------------------------------------------
Running MSBuild.exe ...
MSBuild.exe /t:updateuid U:\Test\WPFAppl.csproj
Output:
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
.
Build started 3/4/2011 9:46:44 AM.
Project "U:\Test\WPFAppl.csproj" on node 1 (updateuid target(s)).
UpdateUid:
Checking Uids in file 'Window1.xaml' ...
Checking Uids in file 'App.xaml' ...
Uids updated in 2 files.
Done Building Project "U:\Test\WPFAppl.csproj" (updateuid target(s)).
.
Build succeeded.
0 Warning(s)
0 Error(s)
-------------------------------------------------------------------

Open a command box and run the MSBuild tool directly for your project (.csproj):
MSBuild.exe /t:updateuid U:\Test\WPFAppl.csproj

See also (at Microsoft): "Best Practices for WPF Localization"
http://msdn.microsoft.com/en-us/library/ms788718.asp

Regards,
Support, Schaudin.com
.
edited by Support on 04.03.2011
0 permalink
04.03.2011 11:41:44

MichaelTR
MichaelTR
Posts: 15
It seems that RC-WinTrans is not able to start msbuild.exe. => no output and no uids

But putting the following lines into the prebuild event for the project did the trick:
$(MSBuildBinPath)\msbuild /t:updateuid $(ProjectPath)
$(MSBuildBinPath)\msbuild /t:checkuid $(ProjectPath)
0 permalink
29.03.2011 13:40:10

rboutilier
rboutilier
Posts: 11
One issue that I've noticed with the Tools | WPF | .NET Project update "x:Uid" attributes... command is that it does not quote the project name in the msbuild command line. Consequently, if the path to the project contains a space the command fails with the message

MSBUILD : error MSB1008: Only one project can be specified.
Switch: Release

The current workaround appears to be changing the project path so that it does not contain spaces, or running the msbuild command manually from the command line and include the quotation marks around the project path.
0 permalink
29.03.2011 22:09:24

Support
Support
Administrator
Posts: 245
Thank you rboutilier for reporting this.
We've fixed it so that the project name will be quoted -- it works now.
The fix will be included in the build version following "9.1.0.993 March 2011".
0 permalink

Home » RC-WinTrans Support » WPF Translation





Powered by AspNetForum 6.9.6.0 © 2006-2010 Jitbit Software