iOS 本地化

1. 目的支持多語言

2.a.應用名字

  b.應用中的文字,圖片等


舉例:a. (1) Info.plist 添加屬性 Application has localized display name 設置爲 boolean  值爲YES 

(2)  new file  --->String file ---->InfoPlist(文件命名,必須是這個名字) ---->InfoPlist.striings文件

           在資源中添加 "+" 選擇對應的語言 chinese) .點擊可展開

(3) 在對應的語言文件添加關鍵字符串  CFBundleDisplayNmae = "微信"  或者  CFBundleDisplayNmae = "WeChat“

eg  

CFBundleDisplayName = "WeChat"; 

CFBundleDisplayName = "微信";


舉例:b.(1)重複a中的第二步,命名爲Localizable,也是必須。-->Localizable.strings 文件

  (2).eg 


"welcome" = "Click on the screen to continue...";

"welcome" = "點擊屏幕繼續...";

CGRect appRect = [[UIScreen mainScreen] applicationFrame];

    CGRect titleRect = CGRectMake(20, 50, CGRectGetWidth(appRect)-40, 25);

    UILabel *titleLabel = [[UILabel alloc]initWithFrame:titleRect];

    [titleLabel setBackgroundColor:[UIColor clearColor]];

    [titleLabel setTextColor:[UIColor blackColor]];

    [titleLabel setText:NSLocalizedString(@"welcome", nil)];

    [self.view addSubview:titleLabel];

    [titleLabel release];


完,如有錯誤,請指正。



 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章