Attributed Strings and Localization?

Discussion in 'Mac Programming' started by Darkroom, Jul 21, 2008.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    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?
     
  2. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #2
    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:)
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #3
    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...
     
  4. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #4
    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.
     

Share This Page