/* */ /* */

2012年11月26日月曜日

【iPhoe】価格の多言語対応について【StoreKit】

またもやiPhoneの話題です。
いい加減Androidに触りたいです。Rubyでも遊びたいです。


さて、今回の話題はiPhoneでの多言語対応、特に課金処理部分で私が躓いた点です。

課金処理の入ったiPhoneアプリで多言語対応にする際、
問題となるのは金額の表記だと思います。

日本の人には円表記で、海外の人には米ドル表記にしたい!となった時にどうするかなのですが、
公式のリファレンスそのままでオーケーです。


- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)responseの中で


NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:product.priceLocale];
NSString *formattedString = [numberFormatter stringFromNumber:product.price];


この様にするだけで、自動で価格の表記が変わってくれます。

さて、ここで問題なのが”何に合わせて”表記が変化するのかです。
自分は最初、他の部分のローカライズと同じで、iPhone本体の言語設定から拾ってくれるのだろうと考えておりました。
実際は、”最後にログインしたAppleアカウントに紐付いている国”の表記がされます。
多分、請求とかでややこしくなるのを避ける措置なのかなと思います。

なので、本体設定を英語にして、表記をUSに設定しても、円単位の数字が返って来る事があります。
テストする時は他の国に設定したアカウントでログインする様にしてください。
ホント面倒です・・・


1 件のコメント:

  1. A detailed guide to the titanium road bike and how to change
    The main advantage of a road bike is that it titanium hair trimmer lets you ride price of titanium faster than titanium exhaust wrap you would normally on a regular bike. The second titanium pipes advantage titanium hammers of a road bike is that it

    返信削除