Re: Localization w/ parameters
Re: Localization w/ parameters
- Subject: Re: Localization w/ parameters
- From: Mike Ferris <email@hidden>
- Date: Mon, 6 Jan 2003 09:14:13 -0800
It is possible to use NSString from Java if you really need it, but it
can be cumbersome. NSString is usually morphed by the Java bridged so
NSString<->java.lang.String. However, NSString is also wrapped across
the bridge as NSStringReference. You can use NSStringReference from
Java to access string functionality in NSString that is not available
in java.lang.String, but note that on the Java side NSStringReference
is a totally different class from java.lang.String and you will likely
have to convert the NSStringReference to a String at some point in
order for it to be useful...
Unfortunately, it looks like NSStringReference does not wrap the
"format" APIs, probably because they take (char *) arguments and Java
has no such thing... I have used NSStringReference mostly to get at
the various encoding functionality of NSString from Java.
Does Java really have no built in way of doing printf style formatting?
I know that the "+" concatenation support for strings partly replaces
the need for this, but it does not cover nearly all the uses that
printf formatting would.
Mike
Begin forwarded message:
From: Fridiric BLANC <email@hidden>
Date: Sat Jan 4, 2003 6:17:14 PM US/Pacific
To: Chris Ridd <email@hidden>
Cc: email@hidden
Subject: Re: Localization w/ parameters
Reply-To: Fridiric BLANC <email@hidden>
I've looked at the Cocoa docs and only found Obj-C NSString's
stringWithFormat: method to solve my problem. But, my app is written
in Cocoa-Java and NSString is not present here!
There's an NSLocalizedString macro available in Objective C which
will do exactly what you want, if you set up a Localizable.strings
file. Cocoa for Java is a mystery to me, but in Java NSBundle has a
static localizedString method that looks pretty similar.
Thanks a lot for your answer, but I knew what you told me: in Obj-C,
I've found the great doc about all that and this is what I explained
in my message. My question was mainly: "How can I get the behaviours
detailed in Obj-C's NSString for localizing strings in a
Cocoa-Java-based app?"
In fact, there is no way (or I haven't found any way) to do
localization with parameters in Cocoa-Java. To localize normal and
static Strings, you're right, there's all I need in NSBundle and this
is accessible from Java. But to transform a retrieved localized String
which needs injection of data (via the stringWithFormat: method in
Obj-C), I haven't access to this from Java (since this method is in
NSString and NSString is only available in Obj-C :( !)
Thanks anyway for your time,
- Fred
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.