Localized images won't load without restarting the app

I am trying to change the application language from within the application. I can achieve this and change the text to match the changed localization, but the localized images don't load until I restart the application.

1) Localized images are placed in the en.lproj and vi.lproj folders.

2) Images are displayed as a table and the table view is reloaded after changing the language.

however, localized images are not retrieved.

The logs I am trying to print ->

NSBundle / Users / admin / Library / Application Support / iPhone Simulator / 7.0 / Applications / 863CF1CB-C9C5-4257-8D6E-DA104C8EC849 / test.app / ru.lproj (not loaded yet)

NSBundle / Users / admin / Library / Application Support / iPhone Simulator / 7.0 / Applications / 863CF1CB-C9C5-4257-8D6E-DA104C8EC849 / test.app / vi.lproj (not loaded yet)

Thank.

+3


source to share


2 answers


There is one simplest workaround

Use different images with a different name according to the language and load the image according to the language selected from the code.

eg. In tableView method cellForRowAtIndexPath



if(language = english) {
imageName = @"logo_english";

}

else if (language = french) {
imageName = @"logo_french";
}

      

Otherwise, use Apple's local image localization, which takes effect after restarting the app.

+2


source


How do you upload your images? If you want to override the language selected for the system, you can use -[NSBundle pathForResource:ofType:inDirectory:forLocalization:]

to specify the localization you want to use when retrieving the resource.



+1


source







All Articles