app的本地化 & 国际化

IOS篇

1. app name 多语言设置

注意:xcode 8 以后没有support Files 文件夹了,不用care,

只要配置文件名称填对就行   InfoPlist.strings , 在右边工具栏的localization 中选择对应的语言打勾就会

自动生成对应的子文件例如:InfoPlist.strings(English)

如果是自定义的文本命名:  Localizable.strings

名称切勿填错了,否则无效果

申明方式

"Login"="登录";

程序内引用方式:

NSLocalizedString(@"Login",@“这是注释无影响可填写nil”);

参考链接:

浅谈Xcode8通过创建strings文件来实现app名称和内容的语言国际化

iOS项目的本地化处理(多国语言)

 

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 是可以切换区域的,切换到其他国家去测呗!

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UniApp 提供了国际化的支持,可以方便地将应用程序本地化为不同的语言版本。要在 UniApp 中实现国际化,你可以按照以下步骤进行操作: 1. 在 `src` 目录下创建一个名为 `lang` 的文件夹,用于存放不同语言版本的文件。 2. 在 `lang` 文件夹下创建一个 `locale.json` 文件,用于存放公共的翻译文本。 ```json // locale.json { &quot;en&quot;: { &quot;hello&quot;: &quot;Hello&quot;, &quot;world&quot;: &quot;World&quot; }, &quot;zh-CN&quot;: { &quot;hello&quot;: &quot;你好&quot;, &quot;world&quot;: &quot;世界&quot; } } ```*** ```json // en.json { &quot;welcome&quot;: &quot;Welcome&quot; } // zh-CN.json { &quot;welcome&quot;: &quot;欢迎&quot; } ``` 4. 在需要使用翻译文本的页面或组件中,使用 `$t` 方法进行翻译。 ```html &lt;template&gt; &lt;view&gt; &lt;text&gt;{{$t(&#39;hello&#39;)}}&lt;/text&gt; &lt;text&gt;{{$t(&#39;welcome&#39;)}}&lt;/text&gt; &lt;/view&gt; &lt;/template&gt; ``` 5. 配置语言环境,在 `main.js` 中引入 `@dcloudio/uni-i18n` 插件,并设置默认语言和语言列表。 ```javascript import Vue from &#39;vue&#39; import App from &#39;./App&#39; import i18n from &#39;./lang&#39; Vue.prototype._i18n = i18n const app = new Vue({ i18n, ...App }) app.$mount() ``` 6. 在 `lang` 文件夹下创建 `index.js` 文件,用于初始化语言环境。 ```javascript // index.js import Vue from &#39;vue&#39; import uniI18n from &#39;@dcloudio/uni-i18n&#39; Vue.use(uniI18n, { locale: &#39;zh-CN&#39;, fallbackLocale: &#39;en&#39;, messages: { &#39;en&#39;: require(&#39;./en.json&#39;), &#39;zh-CN&#39;: require(&#39;./zh-CN.json&#39;) } }) ``` 以上是在 UniApp 中实现国际化的基本步骤,你可以根据需要扩展和调整。希望对你有所帮助!如果有更多问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值