Jim
Jim

Reputation: 5960

Localizing strings from the Settings.bundle using InAppSettingsKit

I am attempting to use InAppSettingsKit to manage my settings. This uses the Settings.bundle with a .plist file and the .strings files for each of the languages being translated.

I can confirm that the translation of my strings is working properly outside of my application, using the Setting application. But when I am in my application, the translation is not occurring.

I think it comes down to code like this, from the InAppSettingsKit class IASKSettingsReader, with a couple logging statements that I thought my be helpful:

- (NSString*)titleForStringId:(NSString*)stringId {
    NSLog(@"%@",[_bundle localizedStringForKey:stringId value:stringId table:self.localizationTable]);
    NSLog(@"%@",[_bundle localizedInfoDictionary]);
    return [_bundle localizedStringForKey:stringId value:stringId table:self.localizationTable];
}

If I understand correctly, this should be using a table with the name self.localizationTable as the source of the translation. This value is simply "Root". It's not a path to the Root.strings file in the selected language, so I am guessing that the method localizedStringForKey:value:table: must be using some global system reference that points to the correct path.

I have confirmed that the strings file name is "Root.strings" all around, with a capital R, including in the Root.plist file.

[_bundle localizedInfoDictionary] returns (null); It is doing this for two language settings of English and French.

I'm not sure how to debug this. Thanks for any help you can give.

Upvotes: 4

Views: 1040

Answers (2)

Jim
Jim

Reputation: 5960

It has been quite some time since I resolved this, and at the time, I didn't fully understand it. But, in the interest of closing out this question, I'll point to the following documentation for future reference:

NSBundle Class Reference

which refers to the following:

Resource Programming Guide

In the second document, refer to the section "String REsources -> Loading String Resources Into Your Code"

The solution contains a properly configured Root.strings file, which shows up in the file list like this:

enter image description here

Upvotes: 0

Gereon
Gereon

Reputation: 17844

I'm using InAppSettingsKit with localized text with no problems. Two things I can think of that you could check: are your Root.strings files located in the correct subdirectories of Settings.bundle (en.lproj and fr.lproj for English and French?

Is there a "Strings Filename" entry in your Root.plist? It should simply contain a string with value "Root"

Upvotes: 1

Related Questions