Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
is it common to forgo the use of attributed strings (particularly those that use NSRange) in localized apps? most words will have different character lengths in different languages, so the range of an attribute won't match correctly...

for example, if i want the first word to be blue and underlined, and the remaining text to just be red, and wrote my attributes for english, it would look like this:

Code:
English:

[U][COLOR="Blue"]Today:[/COLOR][/U]  [COLOR="Red"]Monday.[/COLOR]


Français:

[COLOR="Blue"][U]Aujour[/U][/COLOR][COLOR="Red"]d'hui:  lundi.[/COLOR]

wouldn't it be easier to break up the textField into separate strings for localization instead of trying to add attributes to the textField?

any thoughts?
 
split them into two separate strings which have the required properties setup for them and then merge them together at the end for display. (Probably using NSMutableAttributedString's appendAttributedString:)
 
split them into two separate strings which have the required properties setup for them and then merge them together at the end for display. (Probably using NSMutableAttributedString's appendAttributedString:)

sure, that would work for my example, but for apps that have lots of text, instructions, etc... it just seems that there's no easy way to localize attributes like there is for localizing strings... which i find quite interesting since this absolutely must be a problem for many many developers who have localized apps. i mean, it just seems easier in most cases to create separate strings with their own attributes if the app is going to be localized, but i think it's a bit bizarre that you can't localize attributes - as far as i know...
 
NSAttributedString is a bit of a PITA in my experience. But as you're only localising strings for screen display it shouldn't be a big deal.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.