iOS10权限声明国际化

配置需要国际化的语言

  • 选中project->Info->Localizations,然后点击"+",添加需要国际化/本地化的语言,如下图(默认需要勾选Use
    Base Internationalization):

在这里插入图片描述
添加完后,直接点击finish

  • 选中Info.plist,右键New File… ,选择Strings File(iOS->Resource->Strings
    File)
  • 文件名字命名为InfoPlist,且必须是这个名字
  • 在这里插入图片描述
  • 选中InfoPlist.strings,在Xcode的File
    inspection(Xcode右侧文件检查器)中点击Localize,目的是选择我们需要本地化的语言,如下图:
    注意:在点击Localize之前,一定要保证我们已经添加了需要本地化的语言,也就是上面配置需要国际化的语言那一步
    在这里插入图片描述
  • 点击Localize后,会弹出一个对话框,展开对话框列表,发现下拉列表所展示的语言正是我们在上面配置的需要国际化的语言,选择我们需要本地化的语言,然后点击对话框的Localize按钮,如下图:
    在这里插入图片描述
    接下来,勾选你需要的语言就可以了

在InfoPlist.strings(English)添加下面代码
常用的英文

NSBluetoothAlwaysUsageDescription = "App needs your permission to allow Bluetooth to communicate with device";
NSBluetoothPeripheralUsageDescription ="App needs your permission to allow Bluetooth to communicate with device";
NSCalendarsUsageDescription ="App needs your permission to access calendar";
NSCameraUsageDescription ="App needs your permission to use camera function";
NSContactsUsageDescription ="App needs your permission to access your address book";
NSLocationAlwaysUsageDescription ="App needs your consent to enable location function all the time";
NSLocationWhenInUseUsageDescription ="App needs your consent to enable location function all the time";
NSMicrophoneUsageDescription ="App requires your consent to record";
NSPhotoLibraryAddUsageDescription ="App needs your permission to save photos to album";
NSPhotoLibraryUsageDescription ="App needs your permission to access the album";
NSSpeechRecognitionUsageDescription ="App needs your consent to use speech recognition";
NSAppleMusicUsageDescription = "App needs your permission to access multimedia";

在InfoPlist.strings(Chinese(Simplified))添加下面代码

常用的中文

NSBluetoothAlwaysUsageDescription = "APP需要您的允许才能允许蓝牙与设备通信";
 
NSBluetoothPeripheralUsageDescription ="APP需要您的允许才能允许蓝牙与设备通信";
 
NSCalendarsUsageDescription ="APP需要您的允许才能访问日历";
 
NSCameraUsageDescription ="APP需要您的允许才能使用照相机功能";
 
NSContactsUsageDescription ="APP需要您的允许才能访问您的通讯簿";
 
NSLocationAlwaysUsageDescription ="APP需要您的允许才能始终启用位置功能 ";
 
NSLocationWhenInUseUsageDescription ="APP需要您的允许才能始终启用位置功能 ";
 
NSMicrophoneUsageDescription ="APP需要您的允许才能录制";
 
NSPhotoLibraryAddUsageDescription ="APP需要您的允许才能将照片保存到相册 ";
 
NSPhotoLibraryUsageDescription ="APP需要您的允许才能访问相册";
 
NSSpeechRecognitionUsageDescription ="APP需要您的允许才能使用语音识别";
 
NSAppleMusicUsageDescription = "APP需要你的允许才能访问多媒体";

注意
2:创建完成后,去到info.plist文件中点击空白处,右击并选择:Raw Key&Values 显示对应的key;如:Privacy - Photo Library Usage Description————》NSPhotoLibraryUsageDescription;
在这里插入图片描述
把NSPhotoLibraryUsageDescription拷贝到InfoPlist.strings作为Key,分别在不同的多语言上添加对应的value即可。
如:

<key>NSAppleMusicUsageDescription</key>

<string>NSAppleMusicUsageDescription</string>

<key>NSBluetoothAlwaysUsageDescription</key>

<string>NSBluetoothAlwaysUsageDescription</string>

<key>NSBluetoothPeripheralUsageDescription</key>

<string>NSBluetoothPeripheralUsageDescription</string>

<key>NSCalendarsUsageDescription</key>

<string>NSCalendarsUsageDescription</string>

<key>NSCameraUsageDescription</key>

<string>NSCameraUsageDescription</string>

<key>NSContactsUsageDescription</key>

<string>NSContactsUsageDescription</string>

<key>NSLocationAlwaysUsageDescription</key>

<string>NSLocationAlwaysUsageDescription</string>

<key>NSLocationWhenInUseUsageDescription</key>

<string>NSLocationWhenInUseUsageDescription</string>

<key>NSMicrophoneUsageDescription</key>

<string>NSMicrophoneUsageDescription</string>

<key>NSPhotoLibraryUsageDescription</key>

<string>NSPhotoLibraryUsageDescription</string>

<key>NSSpeechRecognitionUsageDescription</key>

<string>NSSpeechRecognitionUsageDescription</string>

    <key>NSPhotoLibraryAddUsageDescription</key>

    <string>NSPhotoLibraryAddUsageDescription</string>

<key>UIBackgroundModes</key>

<array>

<string>bluetooth-central</string>

<string>remote-notification</string>

</array>
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值