cody
cody

Reputation: 148

How to localize downloaded images in iOS app

We have an application that needs to support multiple languages, both in text strings and photos. We would like to have our users be able to specify a language and have all of those files downloaded at runtime, since there are a lot of files. I have been looking for threads on best practices for this, and I haven't found much. I was wondering if anyone has experience with this type of thing. My ideas to solve the problem are:

  1. Download the files into the sandboxed area and localize the folder programmatically (if that's possible)

  2. Download the files and then move them into a localized folder of images

Does anyone have any experience with this kind of thing?

Upvotes: 0

Views: 110

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100503

The processs is very easy you need to create a folder in Application support / documents with the key of the language dynamically ( sure it's possible with This ) such as

en -> file.text
   -> images -> img1.png
             -> img2.png

fr-> file.text
   -> images -> img1.png
             -> img2.png

and so on , then according to your app setting load from the folder , another way is to use SdWebImage and create your images urls in this manner

https://www.dom1.com/en/img1
https://www.dom1.com/fr/img1

en/fr according to the current setting , if it's a patch of images , then method 1 is fitting perfectly


Suppose you have a setting like

 let current = UserDefaults.shared.string(forKey:"CurrentLang") // gives en / fr

then make current a global var that you use in any method or string composition that's has a reference to text/image donwloaded content inside all the app

Upvotes: 1

Related Questions