discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interface localization ?


From: Philippe Roussel
Subject: Re: Interface localization ?
Date: Sat, 24 Nov 2007 01:54:45 +0100
User-agent: Mutt/1.5.11

On Fri, Nov 23, 2007 at 03:08:36PM +0100, Philippe Roussel wrote:
> On Fri, Nov 23, 2007 at 02:08:13PM +0100, Chris B. Vetter wrote:
> > There may be a better way, but here's how I do it:
> > 
> > Since every object that needs to be translated has a title/label, I
> > use the English label in Gorm, then programmatically set every label
> > again using localised strings.
> > 
> > That way, you only need one Gorm file, and a couple of
> > Localisable.strings files.
> 
> Well, thanks Chris, that's a good start ! I should have a look at the
> sources and see if we can do that automatically, that would be cool.

The ugly patch below does that for NSWindow and NSTextField and that's
almost enough to localize my application's dialogs using only
Localisable.strings (when no graphical modifications are necessary).

It's probably the wrong way to do it but could something similar be
implemented ?

Philippe


Index: Source/NSWindow.m
===================================================================
--- Source/NSWindow.m   (révision 25603)
+++ Source/NSWindow.m   (copie de travail)
@@ -4852,7 +4852,12 @@
       [self setMiniwindowTitle: obj];
       obj = [aDecoder decodeObject];
       [self setTitle: obj];
-
+      {
+       NSBundle *bundle = [NSBundle mainBundle];
+       NSString *ls = [bundle localizedStringForKey:obj value:nil table:nil];
+       if (ls)
+         [self setTitle:ls];
+      }
       aSize = [aDecoder decodeSize];
       [self setMinSize: aSize];
       aSize = [aDecoder decodeSize];
Index: Source/NSTextField.m
===================================================================
--- Source/NSTextField.m        (révision 25603)
+++ Source/NSTextField.m        (copie de travail)
@@ -36,6 +36,7 @@
 #include <Foundation/NSNotification.h>
 #include <Foundation/NSString.h>
 #include <Foundation/NSValue.h>
+#include <Foundation/NSBundle.h>
 
 #include "AppKit/NSApplication.h"
 #include "AppKit/NSCursor.h"
@@ -724,7 +725,10 @@
       [aDecoder decodeValueOfObjCType: @encode(SEL) at: &_error_action];
     }
   _text_object = nil;
-
+  NSBundle *bundle = [NSBundle mainBundle];
+  NSString *ls = [bundle localizedStringForKey:[self stringValue] value:nil 
table:nil];
+  if (ls)
+    [self setStringValue:ls];
   return self;
 }
 
-- 
What's tan and black and looks great on a lawyer? A doberman.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]