We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// 将self.testView中所有的UILabel中的文字转换支持多语言 [self.testView ax_eachSubview:[UILabel class] action:^(__kindof UIView * _Nonnull subview) { UILabel *lb = subview; AXLocalizedLabel(lb); }]; // 将self.testView中所有的UITextField中的文字转换支持多语言 [self.local ax_eachSubview:[UITextField class] action:^(__kindof UIView * _Nonnull subview) { UITextField *tf = subview; AXLocalizedTextField(tf); }]; // 将self.testView中所有的UITextView中的文字转换支持多语言 [self.local ax_eachSubview:[UITextView class] action:^(__kindof UIView * _Nonnull subview) { UITextView *tv = subview; AXLocalizedTextView(tv); }];
注意:此方法生效的前提是你的Localizable.strings文件中有这些语言的翻译。
Localizable.strings
/** 将UILabel中的文字转换成NSLocalizedString @param label 目标UILabel */ FOUNDATION_EXTERN void AXLocalizedLabel(UILabel *label); /** 将UITextView中的文字转换成NSLocalizedString @param textView 目标UITextView */ FOUNDATION_EXTERN void AXLocalizedTextView(UITextView *textView); /** 将UITextField中的文字转换成NSLocalizedString @param textField 目标UITextField */ FOUNDATION_EXTERN void AXLocalizedTextField(UITextField *textField);
inline void AXLocalizedLabel(UILabel *label){ label.text = NSLocalizedString(label.text, nil); } inline void AXLocalizedTextView(UITextView *textView){ textView.text = NSLocalizedString(textView.text, nil); } inline void AXLocalizedTextField(UITextField *textField){ textField.placeholder = NSLocalizedString(textField.placeholder, nil); textField.text = NSLocalizedString(textField.text, nil); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
用法示例
接口
实现
The text was updated successfully, but these errors were encountered: