Re: Bindings and localization
Re: Bindings and localization
- Subject: Re: Bindings and localization
- From: mmalcolm crawford <email@hidden>
- Date: Thu, 11 Nov 2004 15:24:17 -0800
On Nov 11, 2004, at 10:47 AM, Larry Gerndt wrote:
Has anyone thought of a way to use bindings to localize resources
automatically?
Yes...
If there is no way, would this be a good enhancement request?
Yes.
For example, currently the bindings allow you to bind to either:
File's Owner
Shared User Defaults
Shared Application
Would it make sense to provide a fourth binding called "Localized
Strings", such that an object so bound would retrieve its text value
automatically by keying into Localizable.string using the english
value as the key?
Rather than constraining the developer to Localizable.strings it would
be better to be able also to specify a strings table (default would be
"Localizable").
All that said, it's not clear just how much value bindings per se would
be in many localisation tasks. Part of the effort is typically
ensuring that the user interface is satisfactorily laid out. Using
bindings, or any other mechanism (in the absence of any other tools
support), to dynamically localise the interface at runtime makes it
more difficult for translators and for designers.
Where common cases where the user interface is dynamically generated
(error strings presented in standard panels, for example), a simple
value transformer will generally suffice:
- (id)transformedValue:(id)localizationKey
{
NSString *localizedString = [[NSBundle mainBundle]
localizedStringForKey: localizationKey
value:@"No translation"
table:nil];
return localizedString;
}
This example, however, starts to point to some of the inherent
difficulties. There are several assumptions: Where the bundle comes
from; what the default value should be; what table is used.
You could readily create a number of different value transformers, each
given different tables (and bundles if necessary), so the
transformation method would look more like this:
- (id)transformedValue:(id)localizationKey
{
NSString *errorString =
[NSString stringWithFormat:@"No translation in table %@ for \n%@",
[self localizationTable], localizationKey];
NSString *localizedString = [[self localizationBundle]
localizedStringForKey: localizationKey
value: errorString
table: [self localizationTable];
return localizedString;
}
but that starts to get a bit fiddly...
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden