Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Overriding resources in shared library

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Globalizer Support
View previous topic :: View next topic  
Author Message
hofingerandi



Joined: 29 Nov 2010
Posts: 19

PostPosted: Mon Mar 14, 2011 10:17 am    Post subject: Overriding resources in shared library Reply with quote

I have a library for "common dialogs" which I need to localize. The problem is, depending on the caller, the localization should be different.

How is this ideally done? Is there even a way, that shows the modified dialog to the translator?

To give some additional info, consider two (Winforms) projects Utils and Common. Utils.dll performs certain actions and displays dialogs from Common.dll. Now Utils.dll can be called from either Client1.exe or Client2.exe. Depending on the calller, the dialogs from Common should look slightly different (e.g. different icon, different title bar). Unfortunately, it is not an option to generate the modified dialog in Client1 and pass it through Utils, since too many layers/classes would be involved.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Mar 14, 2011 9:40 pm    Post subject: Reply with quote

At first reading I though you meant system common dialogs (like FileOpen, FileSave etc). These are normally localized by getting the title, file filter and other configurable text resources from a Resource file. Globalizer doesn't have a built in mechanism to preview these resource strings applied to the actual dialog (since it doesn't know what your code does with the strings). As per your suggestion with MessageBoxes we could potentially build something into Globalizer to do this.

I think now you mean common dialogs that you have built yourself? In either case you should either be passing the localized resources that may be different from the higher layers (eg icons, strings) etc. These would then be localized in the higher layers. Another alternative would be to pass down an enum value and have the common layer load the required resources dynamically based on the enum value.

This won't allow you to see the dynamically generated resources in the preview - but the preview is just a preview it can't show everything - just like in the Visual Studio designer you can't see changes that are done programmatically. To see dynamically generated code in action your translator would need to do a deployed build and run the application.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
hofingerandi



Joined: 29 Nov 2010
Posts: 19

PostPosted: Tue Mar 15, 2011 8:01 am    Post subject: Reply with quote

Indeed I was talking about dialogs I built myself.

So the strings are localized in the higher layer (clearly, since they have to differ for Client1.exe and Client2.exe) and then transferred to the common layer by either a push- or a poll-mechanism.

I would prefer a push-mechanism, for which I can think of the following possibilities:
* Each respective class has public static fields, I can set at startup
* Common.dll grants access to specific values returned by its ResourceManager
* Common.dll allows to replace its ResourceManager by an alternative implementation (one that looks up strings in Client1.exe first, with fall-back to Common.dll)

I think, I will go for the last one, since this would lead to a one-time-effort only. Overriding a resource in Common.dll would afterwards just mean, to create a resource with the same name in the appropriate Resources.resx of Client1.exe.

Or is there some standard/recommended implementation? Looking in the web I didn't find any, but maybe I was just looking for the wrong keywords...
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Mar 15, 2011 10:21 am    Post subject: Reply with quote

I don't know your application architecture so it is hard to say which option would be best. Another possibility is that you consider using inheritance. In other words derive a form from the base form class defined in Common. Then you can just set the properties which are different in the derived class. This would be the "standard" mechanism for this type of thing (and would also allow previewing of the base and derived forms) - however it may not suit your needs.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Globalizer Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group