請問如何從程式load string
版主: bryanchang、digdog、謝孟叡
請問如何從程式load string
我是剛開始學Cocoa, 1.請問如何從程式修改GUI string (EX: Button上原本)這些String是我先編輯好( 要放哪?? ) 2. 如要支援多國語言, 讓始用著選擇, 就show不同語言?? 有任何example可參考嗎???
- bryanchang
- 討論區管理員
- 文章: 7057
- 註冊時間: 04/19/2001 1:01 am
- 來自: The '60s
- 聯繫:
有找過一些網站跟example( http://developer.apple.com/zh/...),但所有程式都是在開發程式時, UI string就先寫好, 是否可先吧strings 編輯好(要放在哪??plist??) 執行程式後在動態load (EX: like VC++ resource, laodstring),
可以給我一些範例or function name我在去查??
可以給我一些範例or function name我在去查??
//Headermummy 寫:有找過一些網站跟example( http://developer.apple.com/zh/...),但所有程式都是在開發程式時, UI string就先寫好, 是否可先吧strings 編輯好(要放在哪??plist??) 執行程式後在動態load (EX: like VC++ resource, laodstring),
可以給我一些範例or function name我在去查??
@interface MyObject: NSObject
{
IBOutlet NSControl* aControl;
}
@end
//.m
@implementation MyObject
- (void)awakeFromNib
{
if(aControl)
[aControl setTitle:@"myString"];
}
大概是像這樣...要設Button或Control的字串,請找setTitle or setString or setStringValue.
要從resource 讀字串,請找NSBundle
若是要從檔案讀字串, NSStream, NSFileHandle, NSFileManager都會是你的方向,甚至最簡單的,去查 NSData.
做法百百種,你可能要對自己的問題描述的更清楚一點.
沒錯,您說的完全正確!mummy 寫:thank, 因找了好幾天, 還是沒概念 >_<
因開發Application 都支援多國語言(ex: English, Simplifeied Chinese, Tranditional Chinese, Japanse....),且始用的人自己選擇要使用什麼語言,可隨時更換, 而不用跟著OS, 所以想要事先編輯好多國字串...
1. 是不是要建所有語言 .lproj (?? English.lproj, zh_TW.lproj....)
2. 是不是要從 .lproj load string?? 要如何load??
例如:
File "xxx.m"
[panel setTitle:[[NSBundle mainBundle] localizedStringForKey:@"chooseFile"
value:@"Choose project file"
table:@"InfoPlist"]];
File "infoPlist.strings"
"chooseFile" = "拜託您,請選擇檔案 !"
I love OPERA !
不好意思, 我又來發問
順利建好多個 .lproj
( ex: en.lproj => main.nib InfoPlist.strings
fr.lproj => main.nib InfoPlist.strings
.......
)
但當始用的人, 選擇要使用什麼語言,要如何可隨時更換 GUI and String(ex: en->fr), 查了NSLocate (Available in Mac OS X v10.4 and later.)好像有function可用(setLocale),可是只支援 OS x v10.4, 我要用什麼funtion 才可用在(OS X 10.1.2 and later) 隨時更換 GUI and String
順利建好多個 .lproj
( ex: en.lproj => main.nib InfoPlist.strings
fr.lproj => main.nib InfoPlist.strings
.......
)
但當始用的人, 選擇要使用什麼語言,要如何可隨時更換 GUI and String(ex: en->fr), 查了NSLocate (Available in Mac OS X v10.4 and later.)好像有function可用(setLocale),可是只支援 OS x v10.4, 我要用什麼funtion 才可用在(OS X 10.1.2 and later) 隨時更換 GUI and String
