Windows Ribbon Framework: Load resource strings from different file - winapi

I wonder if anyone knows a possibility to tell the Windows Ribbon Framework to load its resource strings from a different file (or resource handle) than the rest of the ribbon resources.
That would be important for localizing the Ribbon UI. I am aware that I can specify a different resource file at runtime dependent on the user's language, but that would mean that I need to have a copy of the ribbon markup and of all images in every localized resource DLL, although they do not change in other languages in my case. This would bloat the setup and produce extra work in keeping all those resources in sync.

Related

Multiple DLL Resource Management

I have an existing MFC product and am planning on supporting a couple of other national languages thru the use of resource-only DLLs. I've read a number of articles and tutorials on how to go about this, but admit that I don't have a lot of in-depth knowledge of Windows resources (mostly just use VS 2008's graphical interface).
The major area that I am trying to understand is that it seems like all of the resource source files (i.e., resource.rc) for these DLLs -- and the main program -- should be sharing the same copy of resource.h. After all, all those IDD_xxx values have to be consistent, and it seems like making updates to the resources would be even more complicated by having to keep multiple resource.h files in sync!
So am I correct on this, and does anyone have any tips for how to best implement this? Should I modify resource.rc in the DLL projects to point to the "master" resource.h in the main program directory?
Yes, use the same resource.h file for sure.
One way is to just copy the resources you need to be translated into the the new resource project--stuff like menus, strings, dialogs. Bitmaps and icons probably don't need to be translated unless you put some text on them that is language specific. If you know your localse, at program startup you can call AfxSetResourceHandle() with the resource DLL you manually load.
Another way to approach the problem if you have a multitude of DLLs and EXEs is to use binary resource editing tools. What they do is create token files from your resources. Your translators edit the token file with the binary editing tool. When all is done, you run a tool to apply the translation to the binaries. Basically, you don't distribute resource DLLs, but distribute different versions of your DLLs for each language. The tools are smart enough so that if you make a change like add a string or dialog, it will get picked up and your translator can see that he needs to translate something new. The previously translated work will be saved in the token files. This is how we do it at my shop. We used to use Microsoft's Localization Resource toolkit. I don't know if we still use it or not since it is somebody else's responsibility now.
I found the MSDN article ID 198846 a good starting point for sharing of resources via a dll, though it does need updating for newer versions of visual studio, it was quite easy to follow and understand.
http://support.microsoft.com/kb/198846

Organizing .resx files in mvc 3 application

I have a question about organizing .resx files in mvc3 application. So far I have managed to do the following:
Creating new class library in a solution for resources and adding resources for two languages. Everything works fine when I have for example:
Resources.resx //default language
Resources.en.resx //english language
But I want to have such organization in my class library:
DefaultLanguage foder
- Resources.resx
en folder
- Resources.en.resx
I want to organize resources by folders. I think it is more appropriate for people who will translate the site and it is also more maintainable. When I organize resources in such a way the web page returns an error...cannot find error. Am I missing something? I know that you should not have folder name in namespace because that would mean that referencing resource in View is dependent on folder name and this is not correct.
The point is I would like to have the same behaviour of resources wheter they are organized in folders or not...
By the way: I check on the web and could not find any appropriate solution.
Thank you for your answers!
MVC3 uses ASP.NET resource management. See ASP.NET documentation for details. If you want to rely on ASP.NET behaviour and generated strongly typed classes, then you must keep resource file from default language and other language specific resource files together.
To have the same tree structure that you suggested, then you have to implement your own resource management. You probably don't want to do that, because (at least some) resource editing tools rely on that behaviour.
On our projects we have one resource (and his translations) for each view. They are in folder Localization within MVC3 project. Inside we keep the same tree structure as is within Views folder. This is more or less the same as ASP.NET local resources are organized. Common strings are kept in one .resx file on root of Localization folder. This ensures maintainability.
To keep your people that will do translation happy you have to pick good .resx editing tool.

Generating resource files for application based on default resource files

I have a .net application that currently has resource files for all it's content, one per .aspx and .ascx. Currently there are only resource files for english.
I now need to add resource files for another language which means I need to replicate all the resource files with just the keys and no values, files named with the correct culture extension eg es for spainish.
My application is built against the .net 3.5 framework in VS2008.
Is there any way of automatically creating/generating the new resource files, in the format detailed above for the entire solution?
You could use this free command line tool or a more sophisticated service like Amanuens.
Disclaimer: I've built the tool and my company is behind the service I've linked.

Multiple setup projects for different languages and brand names

I need to rebrand my application, that means create another application resource file with different strings, slash screen and icons.
My application is also localized for a second language, i have another resource file with all application string which is translated, that creates me additional, satellite dll.
I need to build 4 setup project 2 for each language and 2 for each brand name.
What will the elegant solution for this? Is there any way to create additional application resource file same way I did with language translation and how I include a satellite (resource in a second language dll) in my setup project and not including resources in the original, neutral language.
Thank you.
I assume that those branding resources are not in setup project, but in main project, and that main project is C++.
In C++ you can have several .rc files in a project. This is most likely true for C# resources too. Move all branding material to second resource file. Create another project, shallow in nature, that references all files (including .rc) from original, but uses its own versions of branding files. Apart from strings, icons, and images maybe you will have some dialogs copied and branded as well. Make sure they all have resource identifiers in sync.
Creating another project can be done by just copying original project and fiddling with paths in text editor. Just make sure you change the project GUID, so that two project can coexist in the same solution.

How do I get the Windows Forms Designer to use resources from external assembly?

I have some resources (images in this case) in a resource file that I use on controls in my Windows Forms project. The Visual Studio Resource Selection dialog doesn't have very good support for choosing images from resource files unless they're in specific locations, but you can edit the designer file directly, and this works just fine; the application compiles and runs correctly, and the Windows Forms Designer is smart enough to not mess up my hand-edited code.
// in an assembly named ResourceConsumer
this.button1.Image = global::ResourceConsumer.Properties.Resources.Close32x32;
Now I want to move those resources to an external assembly so they can be used by multiple applications. I can set up an assembly to expose its resources without a problem (as long as I'm using Visual Studio 2008 or later), and this works fine. When I change the designer code to reference the image from its new location, the code compiles and runs correctly, but now the Windows Forms Designer changes my code whenever it generates code; it embeds the binary of the image in the local resource file and references it from there.
// ResourceProducer is an external assembly containing resources
this.button1.Image = global::ResourceProducer.Properties.Resources.Exit32x32;
is changed by the Windows Forms Designer to:
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
The Windows Forms Designer seems to understand pulling a resource from within the same assembly, but not an external one. Is there any way to have the Windows Forms Designer allow me to use a resource from an external assembly?
I have the exact same problem and there may be an alternative approach, depending on your code-base. If the properties that have been modified to reference a specific resource are on custom controls, then you could add the [[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] attribute to those properties (override or hide them, if necessary) and the Designer will leave them alone.
However, if the properties are on basic UI elements (e.g. Form.BackgroundImage) then you'd have to have to override or hide those as well and I'm not sure how desirable that is.
Nope, the designer doesn't support this. Important that it works the way it does, localization through satellite assemblies wouldn't work otherwise.
You can do this but you have to write the code yourself. Pretty much what you find in the Resources.Designer.cs file. Do consider if this is worth the effort, it isn't very maintainable and sharing resource assemblies isn't much of an optimization. A terabyte disk is less than a hundred bucks.
Btw: never edit the Resources.Designer.cs file yourself.

Resources