IOS篇
1. app name 多语言设置
注意:xcode 8 以后没有support Files 文件夹了,不用care,
只要配置文件名称填对就行 InfoPlist.strings , 在右边工具栏的localization 中选择对应的语言打勾就会
自动生成对应的子文件例如:InfoPlist.strings(English)
如果是自定义的文本命名: Localizable.strings
名称切勿填错了,否则无效果
申明方式
"Login"="登录";
程序内引用方式:
NSLocalizedString(@"Login",@“这是注释无影响可填写nil”);
参考链接:
浅谈Xcode8通过创建strings文件来实现app名称和内容的语言国际化
2. Appstore 多语言设置
https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide_zh_CN/Chapters/DisplayInMoreLanguages.html
内购的本地化
在应用客户端里,商品信息通过向AppStore发起SKProductsRequest获得
void IOSIAP::requestProducts(std::vector <std::string> &productIdentifiers)
{
NSMutableSet *set = [NSMutableSet setWithCapacity:productIdentifiers.size()];
std::vector <std::string>::iterator iterator;
for (iterator = productIdentifiers.begin(); iterator != productIdentifiers.end(); iterator++) {
[set addObject:[NSString stringWithUTF8String:(*iterator).c_str()]];
}
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:set];
iAPProductsRequestDelegate *delegate = [[iAPProductsRequestDelegate alloc] init];
delegate.iosiap = this;
productsRequest.delegate = delegate;
[productsRequest start];
}
- (void)productsRequest:(SKProductsRequest *)request
didReceiveResponse:(SKProductsResponse *)response
{
// release old
if (_iosiap->skProducts) {
[(NSArray *)(_iosiap->skProducts) release];
}
// record new product
_iosiap->skProducts = [response.products retain];
for (int index = 0; index < [response.products count]; index++) {
SKProduct *skProduct = [response.products objectAtIndex:index];
// check is valid
bool isValid = true;
for (NSString *invalidIdentifier in response.invalidProductIdentifiers) {
NSLog(@"invalidIdentifier:%@", invalidIdentifier);
if ([skProduct.productIdentifier isEqualToString:invalidIdentifier]) {
isValid = false;
break;
}
}
IOSProduct *iosProduct = new IOSProduct;
iosProduct->productIdentifier = std::string([skProduct.productIdentifier UTF8String]);
iosProduct->localizedTitle = std::string([skProduct.localizedTitle UTF8String]);
iosProduct->localizedDescription = std::string([skProduct.localizedDescription UTF8String]);
// locale price to string
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setLocale:skProduct.priceLocale];
NSString *priceStr = [formatter stringFromNumber:skProduct.price];
[formatter release];
iosProduct->localizedPrice = std::string([priceStr UTF8String]);
iosProduct->index = index;
iosProduct->isValid = isValid;
_iosiap->iOSProducts.push_back(iosProduct);
}
}
注意:本地化的判断 根据用户手机登录的账号所对应的——应用市场的区域。
priceStr 是拼接好当地货币符号的价格描述
3. 官方提供的 app 内容的本地化方案
真的是非常方便!
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPInternational/LocalizingYourApp/LocalizingYourApp.html#//apple_ref/doc/uid/10000171i-CH5-SW1
4. 本地化货币描述 和货币价格
(1)IOS渠道如何判断应该展示 什么货币? 根据用户登录的 APPID
(2)如果用户没有登录 APPID ? 那么根据下载游戏的时候记录的 APPID 来展示(猜测的)
(3)如何获得本地化的 商品描述? APPSTORE 后台自己配置的。获取商品列表的时候可以拿到。
当然,原生弹窗展示的信息,也是在后台配置的。
(4)需要关心汇率问题吗? 不用,苹果给予的商品列表是 转换了货币符号和价格的。也就是拿到直接展示即可
(5)如何测试国外的本地化是否真的做好了? APPID 是可以切换区域的,切换到其他国家去测呗!