2010-11-28 67 views
4

我有:NSLocalizedString問題

-(IBAction)about { 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"About", @"Title of AlertView") 
                message:@"App name \n© My name \n2010" 
                delegate:self 
              cancelButtonTitle:NSLocalizedString(@"Back", @"Cancel Button Title") 
              otherButtonTitles:nil]; 
    [alert show]; 
    [alert release]; 
} 

而在Localizable.strings:

/* Title of AlertView */ 
"About" = "Über"; 
/* Cancel Button Title */ 
"Back" = "Zurück"; 

我的問題:當語言是德語是德國的,但是當我改變語言爲英語警報視圖仍然是德國人

怎麼了?

回答

9

使Localizable.strings文件可本地化(點擊它,按下cmd + i並按下「Make file localizable」按鈕)並添加德語和英語本地化。然後寫德國本地化文件的德語版和離開的英文版本是這樣的:

/* Title of AlertView */ 
"About" = "About"; 
/* Cancel Button Title */ 
"Back" = "Back"; 
+0

仍然不起作用:( – Leon 2010-11-28 15:16:36

+1

您確定你有2個文件看起來這些像? http://grab.by/grabs/9de2f9e8f874eb23249a57acd5e74497.png – Knodel 2010-11-28 15:19:16

32

如果您使用的Xcode 4,你會用這樣的問題面對。試試下面的步驟:從設備

  1. 刪除應用程序
  2. 項目樹的
  3. 選擇根節點獲得項目的屬性
  4. 選擇「構建階段」選項卡
  5. 點擊「添加構建階段」,然後選擇「複製文件‘在‘複製文件「
  6. 選擇’資源’視圖
  7. 添加Localizable.strings文件
  8. 執行‘清潔’的項目
  9. 「建立並運行」