Skip to content

iOS Tutorial: Localization Permission Pop Up

Providing different languages based on user’s preferred language is one way to reach out to a broader audience considering that the biggest population is in Asia. You might want to consider providing localization support if you do not have one yet.

Today you will be show permission pop up based on user’s device language.

Prerequisites

To follow along this tutorial, you’ll need some basic knowledge in:

  • A basic familiarity with Swift.
  • At least Xcode 10.0+

Localization

You will try to prompt for a permission pop up. You can do so by adding the following inside Info.plist.

It should look like the image below:

Do take note that if your permission looks a little different than mine as I am currently using Xcode 12 Beta and this should work with any Xcode.

As you can see, it is currently showing PhotoPermission as the description because that is what we specify in our Info.plist.

Next, you will need to create localizable file. You can do so through File > New >Strings File. Make sure to name your file as InfoPlist.

Then add the language that you would like into your project

Then, go to your newly created InfoPlist.string file and click on the Localize button on the right. There you will be able to select your if you have added any additional languages. You will need to complete the step above first to see any additional languages.

I’ve added Thai so it is showing Thai as an addition. So you will have to localize both and it will create a file for you.

If you have localize both files, your file should look like this:

Now in the English, insert the following inside the English file

and the following inside Thai file

Now you may re-run your project and switch your device language to English or Thai.

They key to actually make this work is:

  1. Localizable files needs to be created as InfoPlist.string
  2. The key in each of the localizable file needs to be according to its usage.

What does 2 means? You can’t use any key strings, you have to only use certain key strings. Right click your Info.plist and Open as > Source Code. From there you can see this is the permission that we are using:

So inside Localizable file, you will need to use NSPhotoLibraryUsageDescription

Where to go From Here

If you feel like you are ready to take on more challenges, feel free to check out some other tutorials that we have created:

Published iniOS Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © DaddyCoding 2020.