5

I'm trying to localize a key in the InfoPlist.strings files which consists of a nested dictionary, like so:

baseKey = {
    secondDict = {
        "key" = "value";
    };
};

Is there any way I can access the inner key directly from the InfoPlist.strings file?

"baseKey.secondDict.key" = "newValue";

doesn't seem to work... Any ideas? I know I can replicate the dictionary structure in the strings file, but it contains some other information that I would prefer not to have in there.

Harry Lachenmayer
  • 968
  • 1
  • 6
  • 7

2 Answers2

2

Apparently it works like this:

Replace "value" with some localization identifier newvalue_i18n_key.

Then, in InfoPlist.strings for each language, do this:

newvalue_i18n_key = "value";

This is more similar to how NSLocalizedString works. To my reading, this is not what Apple says in the official documentation regarding localizing plist files, but it is what Apple does in some sample code.

This question comes up with the same answer.

Community
  • 1
  • 1
divergio
  • 2,000
  • 13
  • 22
-1

You can quickly access nested values this way, where "User" is the key to a NSDictionary and "Username" is a key to a NSString.

yourDict[@"User"][@"Username"]
Leonardo
  • 751
  • 8
  • 15
  • This is true for accessing values from code. The question is asking about localizing values from the InfoPlist.strings file. – divergio Oct 02 '15 at 07:55