ios – SKProduct本地化标题总是英文

ios – SKProduct本地化标题总是英文,第1张

概述我正在使用 Xcode v7.2和Obj-c.我正在为现有的iOS应用添加不同的语言.主要问题是SKProduct的localizedTitle(iTC上的显示名称)总是以英文显示.我可以正确地显示价格本地化和格式化.我已经准备好了许多关于SO的类似问题,并尝试过他们的解决方案,但它似乎对我不起作用(例如: this和 this). 期望的结果: >向用户显示3个按钮;每个按钮都有不同的标题和价格 我正在使用 Xcode v7.2和Obj-c.我正在为现有的iOS应用添加不同的语言.主要问题是SKProduct的localizedTitle(iTC上的显示名称)总是以英文显示.我可以正确地显示价格本地化和格式化.我已经准备好了许多关于SO的类似问题,并尝试过他们的解决方案,但它似乎对我不起作用(例如: this和 this).

期望的结果:

>向用户显示3个按钮;每个按钮都有不同的标题和价格.
>动态更改IAP的显示名称和只在iTC中更新它的价格(所以每次我想要更改时我都不需要更新代码).
>由于#2,我无法在按钮上硬编码IAP名称或价格.
>从iTC中拉出本地化标题(iTC上的显示名称)和价格,以用作按钮上的文本标签.

这是我已经设置的内容:

>在iTC上创建测试用户并为他们分配不同的商店:


>在iTC上设置IAP并添加语言和显示名称:


>代码从iTC获取SKProduct localizedTitle和价格

[[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];        }    }

>创建新的Xcode方案,以便将测试设备语言,位置和区域设置为所需的国家/地区
>在Xcode模拟器上退出App Store(来自“设置”).在模拟器中运行测试时,我最初会以正确的语言查看我的应用程序,但按钮上的文本是英文的.这是因为我还没有改变App Store的位置.我点击IAP购买按钮,它会提示我登录.
>我使用我的测试用户登录该国家/地区.我停止应用程序然后再次运行它.

结果:
我正确地看到了该国家/地区的IAP价格,但我没有看到该按钮的标题是否已正确本地化.按钮的标题仍为英文.我设置的每种语言都会发生这种情况.

谁能发现我在这里做错了什么?我是否错误地认为SKProduct.localizedTitle没有返回该语言的iTC显示名称(App Store)?任何帮助将不胜感激,谢谢.

解决方法 基于
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.

总结

以上是内存溢出为你收集整理的ios – SKProduct本地化标题总是英文全部内容,希望文章能够帮你解决ios – SKProduct本地化标题总是英文所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1055633.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存