- Efficient iOS localization solution.(Objc, swift, NSLocalizedString, xib)
- 高效的iOS本地化解决方案
- 点赞富一生.
- Drag floder SDLocalizeto your project.
#import "SDLocalize.h"pod 'SDLocalize'
- SDLocalize
- NSObject + SDLocalize
- NSString + SDLocalize
- NSArray + SDLocalize
- 首先标记一组需要本地化的控件
- 然后在恰当时机(viewDidLoad),触发一组本地化任务(Then (viewDidLoad) fires a set of localization tasks when needed)
- SDLocalize会使用控件的文本作为LocalizedString.key替换当前控件的文本
- Start by marking a set of controls that need to be localized
- Then (viewDidLoad) fires a set of localization tasks when needed
- SDLocalize replaces the text of the current control with the text of the control as LocalizedString.key
// It then triggers a set of localization tasks when needed
- (void)viewDidLoad {
    [SDLocalize defaultLocalize];
}control0.text = <LocalizedString.key>;
control1.text = <LocalizedString.key>;
control2.text = <LocalizedString.key>;
...
[control0 sdl_defaultRegister];
[control1 sdl_defaultRegister];
control2.sdl_defaultRegister = @"-";
...
// 然后在恰当时机(viewDidLoad),触发一组本地化任务
// It then triggers a set of localization tasks when needed
- (void)viewDidLoad {
    [SDLocalize defaultLocalize]; // Takes effect on all controls marked as default pages
    //[control0 sdl_localizeIfNeed];
    //[control1 sdl_localizeIfNeed];
    //[control2 sdl_localizeIfNeed];
    // ...
}- < UILabe, UIButtonl, UITextView >.text
- < UITextField >.placeholder
[SDLocalize customTextGetter:^(id object){
    if(object is MyView) {
        return myView.myText;
    }
} andSetter:^(NSString *localizedText, id object){
    if(object is MyView) {
        myView.myText = localizedText;
    }
}];control.sdl_dynamicFormat = @"My name is %@, %@ years old."; // XIB supported
...
[control sdl_localizeWithFormateArgs:@[name, age]];[control sdl_localizeIfNeed];string.sdl_localizedString;
@[string0, string1, string2, ...].sdl_localizedArray;control.sdl_localizedDone- 阅读源代码(Read the source code)
- app合作:meterwhite@outlook.com
