SKProduct localizedTitle always in english
Asked Answered
S

1

8

I'm using Xcode v7.2 and Obj-c. I'm adding different languages to an existing iOS app. The main problem is that the SKProduct localizedTitle (Display Name on iTC) always comes back in English. I can show the price properly localized and formatted. I have ready many similar issues on SO and have tried their solutions but it doesn't seem to be working for me (for example: this and this).

Desired outcome:

  1. Show 3 buttons to user; each button has a different title and price.
  2. Dynamically change the IAP's Display Name & price by updating it in iTC only (so I don't have to update the code each time I want a change).
  3. Because of #2, I can't hard-code the IAP name or price on the button.
  4. Pull the localized title (Display Name on iTC) and price from iTC to use as the text label on the buttons.

Here's what I have setup already:

  • Created test users on iTC and assigned them different stores: iTC test users and stores
  • Setup the IAP's on iTC and added the languages and Display Names: iTC IAP list with languages
  • Code to grab SKProduct localizedTitle and price from iTC

    [[FirstDrawIAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
        if (success) {
            storeProducts = products;
            SKProduct *product = (SKProduct *)storeProducts;
            //Format price
            priceFormatter = [[NSNumberFormatter alloc] init];
            [priceFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
            [priceFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
    
            //Iterate thru the buttons using tipButton Outlet Collection
            for (int i = 0; i <  [self.tipButton count]; i++) {
                UIButton *button = [[UIButton alloc] init];
                button = self.tipButton[i];
                //product = storeProducts[i];
                product = products[i];
                //Set the price locale
                [priceFormatter setLocale:product.priceLocale];
                //Localize the button title and append the price
                NSString *btnTxt = [product.localizedTitle stringByAppendingString:@" "];
                NSString *price = [priceFormatter stringFromNumber:product.price];
                NSString *newBtn = [btnTxt stringByAppendingString:price];
                NSLog(@"\nID: %@, Price: %@, Button: %@",[product localizedTitle], price, btnTxt);
                //Set button title
                [button setTitle:newBtn forState:UIControlStateNormal];
    
            }
    
        }
    
  • Create new Xcode scheme so the test device Language, Location and Region are set to the desired country

  • Sign out of App Store on Xcode simulator (from Settings). When running tests in the simulator, I'll initially see my app in the correct language but the text on the buttons is in English. This is because I haven't changed the App Store location yet. I tap the IAP purchase button and it prompts me to login.
  • I login using my test user for that country. I stop the app then run it again.

Result: I correctly see the IAP price for that country but I don't see the button's title correctly localized. The button's title is still in English. This happens with each language I've setup.

Can anyone spot what I'm doing wrong here? Do I have the wrong assumption that SKProduct.localizedTitle does not return the iTC Display Name for that language (App Store)? Any help would be appreciated, thanks.

Seagoing answered 27/12, 2015 at 17:38 Comment(4)
Did you figure this out? I am currently experiencing the same problem.Dowager
Unfortunately, no. As you can see here, also, I didn't get any help in resolving it either. I'm still looking so if anyone has a way to figure this out, please post it here.Seagoing
I'm not sure, but I have the same issue, currentLocale on simulator for me is ru_RU, but product.priceLocale.localeIdentifier (the same as used for localizedTitle) shows en_RU, so the price is OK, but title is always in english. Anyway everything works properly on device for me, so maybe it's simulator related issue. It's gonna be a hard work, but try to test every locale on device. BTW, "Массивная наконечник" is wrong in russian ;) "-ая" is female adjective postfix, while "наконечник" is male noun, so you need "Массивный наконечник", "-ый" is for male adjective.Fiddle
Thanks @Aft3rmath! I gave you an upvote for helping me on the translation.Seagoing
E
7

Based on In-App Purchase FAQ

localizedDescription and localizedTitle return localized information whose language is based on the current iTunes Store rather than the current device language setting.

E answered 15/1, 2018 at 20:30 Comment(1)
but Canadian App Store has two languages (English and French). How it handle?Lavona

© 2022 - 2024 — McMap. All rights reserved.