Home‎ > ‎

Bundle中にNSLocalizedStringの使用

バンドルのNSLocalizedStringから文字列の取得

NSLocalizedString がちゃんと動きません。
代わりに NSLocalizedStringFromTableInBundle を使います。

-(void)showMsgBox:(NSString*)updateType
{
 NSAlert* alert;
 alert = [[[NSAlert alloc] init] autorelease];
 [alert setMessageText:NSLocalizedStringFromTableInBundle(@"name", nil, [NSBundle bundleForClass: [self class]], @"name")];
 NSString* text = [NSString stringWithFormat:
      NSLocalizedStringFromTableInBundle(@"customFunctionInfo", nil,
      [NSBundle bundleForClass: [self class]], @"customFunctionInfo"), updateType];

 [alert setInformativeText:text];
 [alert setAlertStyle:NSInformationalAlertStyle];
 [alert addButtonWithTitle:@"OK"];
 int result = [alert runModal];
 [[alert window] orderOut:self];
 if (result == NSAlertFirstButtonReturn) {
  return;
 }
}

参照:http://bathyscaphe.sourceforge.jp/cgi-bin/wiki.cgi?p=ImagePreviewer%A4%F2%BA%EE%C0%AE%A4%B9%A4%EB#P24