代码之家  ›  专栏  ›  技术社区  ›  Felixyz

应用商店的本地化价格

  •  2
  • Felixyz  · 技术社区  · 14 年前

    2 回复  |  直到 14 年前
        1
  •  6
  •   NeilInglis    14 年前

    有一个iTunesWeb服务API你可以使用。

    http://www.apple.com/itunesaffiliates/API/AffiliatesSearch2.1.pdf 记录下来。

    您可以使用“country”查询字段指定希望返回结果的国家。

    NSLocale *locale = [NSLocale currentLocale];
    NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
    NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode
                             value: countryCode]];
    

    不过,您可能需要一个查找表,以与itunesstoreapi相同的方式对其进行格式化。

        2
  •  0
  •   Enyra    14 年前

    如果您可以提取一个简单的数字价格,NSNumberFormatter将为您提供货币本地化。

    NSDecimalNumber *price = [NSDecimalNumber decimalNumberWithString:@"4.95"];
    
    NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
    [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
    

    这将从用户的默认regiona设置中添加货币。如果要更改区域设置,请使用:

    [currencyFormatter setLocale:anyLocale];