Re: Localize Attributed Strings?
Re: Localize Attributed Strings?
- Subject: Re: Localize Attributed Strings?
- From: Douglas Davidson <email@hidden>
- Date: Tue, 6 Jan 2009 10:19:31 -0800
On Jan 6, 2009, at 9:22 AM, Alastair Houghton wrote:
On 4 Jan 2009, at 00:02, Chunk 1978 wrote:
is this possible? i have a string that changes color and size
according to the length of the words in the string. however, these
words and their lengths change in different languages. clearly i
could add and NSLocalization wrapper to the string, but the problem
is
that the attributes would remain the same.
One way is to store your string's contents in an RTF file that you
include as a resource in your application, then load its contents
using -[NSAttributedString initWithPath:documentAttributes:] (or
similar). You can use -[NSBundle pathForResource:ofType:] to find
the path for the correct localized variant.
There are many variations on the above, but hopefully that should
get you on the right track.
Here are some possible variations: (1) you can store multiple pieces
of attributed text in an RTF file, using some convention of your own
to separate them; (2) you can use NSKeyedArchiver to write out a
dictionary of attributed strings to a file; (3) if you really want to
use the localized string mechanism, you can put some basic HTML markup
in your localized strings and used NSAttributedString's HTML
conversion to get attributed strings; etc., etc.
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden