Question

I'm creating a music App and I want to support multi languages of MPMediaPickerController. I programmed as follows:

- (IBAction)pushedMusicButton:(id)sender {
    MPMediaPickerController *pickerController = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
    pickerController.delegate = self;
    pickerController.accessibilityLanguage = [[NSLocale preferredLanguages] objectAtIndex:0];
    NSLog(@"Language setting = %@", pickerController.accessibilityLanguage);
    [self presentViewController:pickerController animated:YES completion:nil];
}

I ran this code on my iPhone whose setting is Japanese.

MediaPicker window opened but the string of the button is English… like 'Playlists', 'Artists' or 'Songs'. Log showed accessibilityLanguage is set to JP (Language setting = ja).

How can I change language setting of MPMediaPickerController?

Environment: XCode 4.4.1, iOS SDK 5.1, iPhone (iOS 5.1)

Was it helpful?

Solution

Thank you Sun Tzu and venkat, I finally found the localized file is really needed. but the localized string doesn't.

I created Localizable.string files in en.lproj and ja.lproj and added them to my project. At first I tried to build with null (0byte) Localizable.string but there was a build error, so I entered one set of strings. In en.lproj:

"Playlists" = "Playlists";

In ja.lproj:

enter image description here

Then, not only 'Playlists' but also other label ('Artists', 'Songs',..) was displayed in Japanese.

enter image description here

For the confirmation, I changed the setting to Deutsch. but it displayed as 'Songs' in English. (Not 'Titel')

enter image description here

I created de.lproj folder and copied Localizable.string which is completely same as en.lproj's one. Finally 'Titel' comes.

enter image description here

So, the labels in MPMediaPickerController speaks your mother language, when you added Localizable.string file in .lproj.

My code snippet is:

- (IBAction)pushedMusicButton:(id)sender {
    MPMediaPickerController *pickerController = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
    pickerController.delegate = self;
    [self presentViewController:pickerController animated:YES completion:nil];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top