我有興趣爲屏幕上給定的文本找到本地化的字符串鍵。如何反向查找本地化的字符串
這可能嗎?
例如,在一個人爲的例子:
UILabel *label = [[UILabel alloc] initWithFrame:frame];
label.text = NSLocalizedString(@"The key for this label",nil);
// at runtime
UILabel *theLabel = ... // get the label
NSString *text = theLabel.text;
NSLog(@"%@",text); // prints "Foo bar"
// now I want to get the key:
NSString *localizedKey = ???? NSLocalizedStringReverseLookup(text)
NSLog(@"%@",localizedKey); // should print "The key for this label"
我的回答有幫助嗎?這是你的選擇嗎? – nburk
你會通過編寫代碼來做到這一點。但是,我認爲這種做法是完全錯誤的。 – gnasher729