1

出于国际化的目的,我尝试放入NSLocalizedString一个数组。我有随机图片,其中包含与每张图片相关的信息。它适用于英语。不适用于宏,有什么问题?

- (void)showimage
{
 int randomimages = arc4random() % 7+1;

 self.rahmen.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png",randomimages]];

/*    text without the local.strings worked perferct

 self.myStrings = [NSArray arrayWithObjects:
 @" info 0, nothing",
 @" info 1 english",
 @" info 2 english",
 @" info 3 english",
 @" info 4 english",
 @" info 5 english",
 @" info 6 english",
 @" inf0 7 different english",nil];
 */

//here I wanted to put the different strings for internationalzation

self.myStrings = [NSArray arrayWithObjects: NSLocalizedString
                   (@"info0",
                    @"info1",
                    @"info2",
                    @"info3",
                    @"info4",
                    @"info5",
                    @"info6",
                    @"info7",nil)
                  ];                                                 
label.text=[self.myStrings objectAtIndex:randomimages];
}
4

2 回答 2

1

试试这个可能对你有帮助

self.myStrings = [NSArray arrayWithObjects:
    NSLocalizedString(@"info0",nil),
    NSLocalizedString(@"info1",nil),
    NSLocalizedString(@"info2",nil),
    nil];
于 2015-01-20T12:49:21.930 回答
0

NSLocalizedString宏接受两个参数:非本地化字符串和注释。就是这样,仅此而已,您不能通过在数组上调用它来神奇地使其返回数组。您必须将每个非本地化字符串包装在此宏中才能实现您想要的。

于 2013-05-25T12:42:40.067 回答