iosobjective-cabaddressbookaddressbookui

How to localize ABUnknownPersonViewController from AddressBookUI?


I tried to use ABUnknownPersonViewController in my app, but it's only in english. I think it would be better if AddressBookUI shows it automatically in system language. Is there any way to show it in other languages or I need to make my own controller?

update: code

    ABRecordRef aContact = ABPersonCreate();

    ABMutableMultiValueRef phoneNumbers = ABMultiValueCreateMutable(kABMultiStringPropertyType);

    ABMultiValueAddValueAndLabel(phoneNumbers, (__bridge CFStringRef)labelNumber.text, kABPersonPhoneMainLabel, NULL);


    ABRecordSetValue(aContact, kABPersonPhoneProperty, phoneNumbers, nil);

    ABUnknownPersonViewController *picker = [[ABUnknownPersonViewController alloc] init];
    picker.unknownPersonViewDelegate = nil;
    picker.displayedPerson = aContact;
    picker.allowsAddingToAddressBook = YES;
    picker.allowsActions = YES;

    [self.navigationController pushViewController:picker animated:YES];

    [picker release];

    CFRelease(phoneNumbers);
    CFRelease(aContact);

Edit: I just forgot to add language in project localizations


Solution

  • it is shown in the language that is supported by the app based on the user's preferred system language.

    to localise the view apple uses NSLocalizedString and that uses:

        NSArray* preferredLanguages = [NSLocale preferredLanguages];
        NSString* languageCode = preferredLanguages[0];
    

    You can change it before using NSLocalizedString the first time but It can't be changed on the fly. Note that it would change the language for ALL NSLocalizedString calls