Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to localize images in iOS if they are set up in a storyboard?

I know how to localize storyboard elements like label, buttons etc. However, I faced a problem where I need to localize the images that were setup in a storyboard in the attribute inspector for the Image View.

Is there a way to localize those without setting those images up in the code, in the viewDidLoad method and calling setImage:[UIImage imageNamed: NSLocalizedString(...)]; ?

Any kind of help is highly appreciated!

like image 460
Eugene Gordin Avatar asked Oct 24 '14 18:10

Eugene Gordin


1 Answers

I guess I figured it out...maybe not the ideal way of doing it but works for me...

Open image folder in your Project Navigator (panel).

When you click one of the images, on the right (Inspector panel) you'll see the button "Localize".

enter image description here

Clicking on that button gives you a pop-up asking if you want it to be the base (in my case I say yes).

So now in the inspector there're check boxes: Base, language 1, language 2 etc (language n - is the languages you added to your project in the localization settings). enter image description here

So now if you put a check mark into one of the language check boxes, your image file will have a drop down arrow showing that it has some content inside. If you click that, you'll see how it expands showing the localized files with the name of the language in the () brackets. enter image description here

However, at this point those files are all the same as the base. So now you need to substitute the base files with the localized ones.

If you right click on the file that needs to be localized, say myImage.png(German), open it in Finder, and replace that file with the right one. Important! The name of the file should stay the same!

I'll post the screenshots later, so it's all clear how to do it.

like image 129
Eugene Gordin Avatar answered Sep 19 '22 13:09

Eugene Gordin