Extract string from labels in xaml to resource files - silverlight

I can't find any method of extracting string values from xaml (Silverlight) to a resource file. Do I really have to do this manually?
If this is not supported in VS2010, are there any 3rd party tools which offers help on this issue?
Building and maintaining resource files for localization purposes is quite tedious if you have to do this manually.

This should do the trick: http://wpflocalizeaddin.codeplex.com/

XAML is just XML, so you can write an XML parser in a Winforms app to find all the strings.
We did away with the need for the resources using a different technique (based on attached properties):
Link: Localisation of Silverlight projects after completion

Related

Is it Possible to Reflect the XAML Markup for VS2012?

I have been looking at some components Microsoft use for VS2012, attempting to learn and use there approaches to extensible component design. Despite being able to decompile the C#, I cannot seem to find any way of looking at the XAML mark-up, is this possible?
Note. I have attempted using Snoop but this does not seem to be able to provide the relevant XAML.
Thanks for your time.
You could use a commercial Reflector with BAML Viewer to convert BAML resource of assembly to XAML.
Also you could use a free dotPeek decompiler. Since 1.1 version it has a feature to view BAML resources without any additional plug-ins.
At last you could use a open source ILSpy decompiler to solve the same problem.

Best practice for using resources in a WPF project

I know and use two methods to store and access resources on application scope:
Properties\Resources.resx
create a folder and place for example images there, setting their build mode to Resource
What is the difference between the two methods in terms of performance and complexity, when should each be used and how are the resources best consumed in WPF and VB or C# code in each way?
Thanks in advance,
Julian
The "natural" way of referencing resources like images in a WPF project is your second option. You can use a relative URI to point to the image and WPF will lazy load it. You can reference resources in other assemblies using pack URI syntax.
Using Resources.resx will code-generate properties that loads resources when referenced. Resources can be strings, images, icons or a byte arrays. Using {x:Static} in XAML allows you to reference the static properties generated by the code-generator but often you will need a converter to convert the resource type into a type usable by WPF.
There is some support for localization using Resources.resx and if you want to provide a multi-lingual application you could store the translated strings in Resources.resx. However, WPF localization as described by Microsoft is not based on Resources.resx.
For images, the second option is much easier. For strings, the first option is probably easier but instead you could stay in XAML and create a ResourceDictionary.

Is it possible to localize a string inside cs file in WPF project using LocBalm method?

In our WPF plugin project we use LocBaml tool to localize UI. But now it is needed to localize a string inside a cs file:
ToolInfo.MenuCaption = "&Toggle console";
I've found some localization topics:
WPF Localization - On-the-fly Language Selection
WPF Application Framework (WAF)
WPF Localization Extension
It seems that for using these 3rd party tools it is needed to remove LocBalm implementation and write a new one.
Is it possible to stay with LocBaml tool and add a translation just for this string in cs file?
If the custom localization is taking place only in codebehind (cs file(s)), there's no reason that I can see for it to not work with LocBaml.
You could always use a hack to use LocBaml for this localized string as well, something like this :
<TextBlock x:Uid="HiddenText" Name="HiddenText" Text="&Toggle console" Visibility="Collapsed" />
And in codebehind :
ToolInfo.MenuCaption = HiddenText.Text;
This is kind of mildly awful, but you should be able to still localize the string with LocBaml this way.
Otherwise, you'll have to string together a separate system yourself - something with resource strings and a resource manager, most likely - or try to get one of the localization platforms to play nice with LocBaml.

What is the best way of localization LOCBaml or Resx based localization?

I came through this What is the best way to localize a WPF application, sans LocBAML? . But, this didn't answer what I'm looking for.
I'm creating a CustomControl in WPF. I would like to provide localization support. The control contains, images, strings etc.,
Any help would be greatly appreciated.
Thanks
I think the document linked in this post contains a lot of information about localization in WPF. In the end, it is up to you to decide which mechanism to use.
Since you are talking about a custom control, I would consider to give it a Culture dependency property which the consumer of your control can use to specify the desired culture. This way, the consumer can use your localized control, relatively independent of the localization strategy he/she chose.
I'd suggest using Resx, try integrating into a WPF application with the TranslationByMarkupExtension example. http://www.wpftutorial.net/LocalizeMarkupExtension.html
LocBaml was a very odd thing for Microsoft to put out there and isn't better, or even complete.

Is it possible to use Kit3D in WPF? If so, how?

I have a Silverlight application that uses Kit3D and I want to convert it to WPF.
How would I do that?
Should I do that?
You could try downloading the source code from its Codeplex repository and recompiling with WPF as the target. No guarantees this will work without modifications, though, since WPF is not a complete superset of Silverlight. But according to the author's description on his web page, Kit3D is modeled after WPF's built-in Media3D namespace, so you could just use that directly rather than bother with a 3rd-party library.

Resources