Tuesday, October 25, 2005

Graphical Editing Framework for Cocoa

For my apprenticeship I am working on a project in Java in the Eclipse framework. Because we're working on a visual editor we make use of GEF (Graphical Editing Framework). The documentation for this is rather poor, but that's not the point of my post.

Now I have been searching for a similar framework in Cocoa, but haven't found anything. So here comes my mad megalomanic idea. Let's start a project on sourceforge to make our own framework, based on GEF. Of course making use of the idiosyncrasies of Objective-C and Cocoa, instead of the Java stuff in GEF.

I really believe such a project could provide a boost in Cocoa application development. Some input from other developers would be nice.

Mind, that I currently don't have time to immediately start something like that. Just some thoughts and dreams for the moment.

References:
Eclipse: http://www.eclipse.org
Gef: http://www.eclipse.org/gef/

Tuesday, October 04, 2005

Localized strings with a specified localization

I have been searching for a way to get a localized string for a specified localization for some time now. Finally I have found the solution. Well to be honest, I was given the solution by a certain Douglas Davidson on the CocoaDev mailing list. Thank you very much Douglas!

Here's the problem: Assume you have an application which has multiple localizations, but needs to access the localizations besides the preferred localization of the user at runtime. A simple example could be an App that I am currently working on, which among other things prepares exams for teachers. Those exams could be in a different language than the one the program is currently running in. I would like to use something similar to NSLocalizedString for the static text on the exam.

After finding out this wasn't provided by NSBundle in Cocoa yet, I have decided to make a category which adds support for this.
The important thing here is the macro NSLocalizedStringForLocalization. This is essentially the same as NSLocalizedString, except that you can specify the localization you want. Check out the code:
NSBundle_Extensions.h
NSBundle_Extensions.m

[update] The strings dictionary is now cached
[update 2] Fixed bug explained in comments by Jonathon