Swati
Swati

Reputation: 2918

localized images do not load without app restart

I am trying to change the app language from within the app. I am able to achieve this and change the text as per the changed localization but the localized images are not loaded until i restart my app.

1) The localized images are placed in en.lproj and vi.lproj folders.

2) The images are displayed in table view and the table view is reloaded after language change.

still the localized images are not fetched.

Logs that i try to print >>

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

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

Thanks.

Upvotes: 3

Views: 210

Answers (2)

Thomas Deniau
Thomas Deniau

Reputation: 2573

How are you loading your images? If you want to override the language chosen for the system, you can use -[NSBundle pathForResource:ofType:inDirectory:forLocalization:] to specify the localization you want to use when fetching a resource.

Upvotes: 1

Dinesh Kaushik
Dinesh Kaushik

Reputation: 2987

There is one simple workaround

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

e.g. In tableView cellForRowAtIndexPath Method

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

}

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

Otherwise use apple native localisation of images which takes effect after app restart.

Upvotes: 2

Related Questions