atom feed44 messages in net.java.dev.appframework.usersRe: Question about internationalizing...
FromSent OnAttachments
Rob RossDec 23, 2008 4:48 pm 
Olivier GrégoireDec 24, 2008 1:41 am 
Karsten LentzschJan 6, 2009 2:54 am 
Rob RossJan 12, 2009 4:00 pm 
Mark FortnerJan 14, 2009 10:25 am 
Karsten LentzschJan 15, 2009 1:31 pm 
Karsten LentzschJan 15, 2009 1:46 pm 
Rob RossJan 15, 2009 5:03 pm 
Olivier GrégoireJan 16, 2009 8:12 am 
Rob RossJan 16, 2009 11:21 am 
Karsten LentzschJan 16, 2009 11:31 am 
Rob RossJan 16, 2009 5:35 pm 
Karsten LentzschJan 18, 2009 11:40 am 
Harald KuhrJan 19, 2009 6:47 am 
Karsten LentzschJan 19, 2009 9:27 am 
Rob RossJan 23, 2009 7:33 pm 
Mark FortnerJan 24, 2009 9:04 am 
Rob RossJan 24, 2009 9:14 am 
Karsten LentzschJan 30, 2009 11:58 am 
Rob RossFeb 7, 2009 9:28 pm 
Karsten LentzschFeb 10, 2009 11:25 am 
Chiovari Cristian SergiuFeb 10, 2009 10:49 pm 
Jean-Francois PoilpretFeb 11, 2009 3:58 am 
Harald KuhrFeb 11, 2009 5:01 am 
Jean-Francois PoilpretFeb 11, 2009 5:47 am 
Anil PhilipFeb 11, 2009 6:48 am 
Karsten LentzschFeb 11, 2009 6:57 am 
Karsten LentzschFeb 11, 2009 7:00 am 
Chiovari Cristian SergiuFeb 11, 2009 11:00 am 
Martin SkoppFeb 12, 2009 2:34 am 
Karsten LentzschFeb 12, 2009 5:31 am 
Harald KuhrFeb 12, 2009 8:09 am 
Harald KuhrFeb 12, 2009 8:15 am 
Anil PhilipFeb 12, 2009 11:17 am 
Anil PhilipFeb 13, 2009 6:30 am 
Werner RandelshoferFeb 14, 2009 4:44 am 
Karsten LentzschFeb 16, 2009 12:14 pm 
Karsten LentzschFeb 16, 2009 12:17 pm 
Chiovari Cristian SergiuFeb 16, 2009 1:15 pm 
Chiovari Cristian SergiuFeb 16, 2009 1:18 pm 
Michael ErskineFeb 17, 2009 5:21 am 
Rob RossFeb 25, 2009 11:53 am 
Karsten LentzschFeb 25, 2009 12:41 pm 
Karsten LentzschMar 2, 2009 11:13 am 
Subject:Re: Question about internationalizing menu items
From:Rob Ross (rob.@gmail.com)
Date:Feb 7, 2009 9:28:28 pm
List:net.java.dev.appframework.users

On Jan 6, 2009, at 2:54 AM, Karsten Lentzsch wrote:

Here's how I define the preferences (options) action with my ResourceMap implementation. It provides an optional suffix for the OS ($os), Look&Feel ($laf), or system property (e.g. $java.version):

openPreferences.Action.text=${openPreferences.Action.text.[$os]} openPreferences.Action.text.default=Preferences openPreferences.Action.text.win=Optio&ns openPreferences.Action.accelerator=$ {openPreferences.Action.accelerator.[$os]} openPreferences.Action.accelerator.default=${null} openPreferences.Action.accelerator.mac=meta COMMA

On the Mac the text is "Preferences" and accelerator is meta Comma, on Windows the text is "Options", mnemonic is 'n' and there's no accelerator.

The menu item placement is managed by the GUI building code.

-Karsten

Karsten,

I've been setting up a lot of Actions and have thought up a simpler implementation than this that still provides the same level of flexibility.

Instead of having this in the properties file:

Preferences.Action.text=${Preferences.Action.text.[$os]} Preferences.Action.text.default=Preferences... Preferences.Action.text.win=&Options Preferences.Action.accelerator=${Preferences.Action.accelerator.[$os]} Preferences.Action.accelerator.default=${null} Preferences.Action.accelerator.mac=command COMMA

I can reduce it to :

Preferences.Action.text=Preferences... Preferences.Action.text.win=&Options Preferences.Action.accelerator.mac=command COMMA

The way this would work is, first, the "os" variable, (the same one as you currently use) can be both set/retrieved explicitly , as well as automatically initialized by the framework. Next, the framework already "knows" about the common values this variable can take on (e.g., "mac", "win", "solaris", etc.

By allowing it to be explicitly set, you provide the ability to expand the framework in case a user has some particular variation not initially thought of.

But the real difference comes in the implementation of the Action property injector. This would now use the concept of "the most specific platform attribute". So in the case of say the "text" property, if the application is running on the Windows platform, the value of Preferences.Action.text.win is used. On all other platforms, the value of Preferences.Action.text would be used.

Now say we run the same app on Mac OS. Since there is no specific "Preferences.Action.text.mac" property specified, the "Preferences.Action.text" property is used. Thus overriding properties for specific platforms becomes just a matter of providing for that specific value. That avoids having to have a "default" variant; the default would be just the base attribute (Preferences.Action.text), and a more specific variant is used only when such a variant is specified AND running on that platform.

Note there is no "Preferences.Action.accelerator" property specified. Thus, there is no default accelerator for this Action, so on most platforms there would not be an accelerator associated with this Action. But, on the Mac, this action would get the command-COMMA accelerator.

Also note, "command" would be synonymous with "meta", and it's trivially easy to add this functionality. Mac developers are so used to working with "command" key, and not so much "meta", that seems more natural. Of course, this could be written as "meta COMMA" and produce the exact same result.

I really think you should consider this approach, because after having defined 30 Actions now using your notation, my properties files seem very cluttered with a lot of boilerplate "scripting" , whereas the approach I'm suggesting seems a lot more streamlined and easier to read.

Let me know what you think!