From ee1bc5bc325c34c2952c51f23a3cb1435f3758ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A3=9E=E4=BE=A0u?= Date: Tue, 13 Jun 2017 19:04:41 +0800 Subject: [PATCH] init --- .../iOSAppLanguageSwitchDemo/AppDelegate.h | 17 ++++ .../iOSAppLanguageSwitchDemo/AppDelegate.m | 58 +++++++++++++ .../AppIcon.appiconset/Contents.json | 68 +++++++++++++++ .../Base.lproj/FirstViewController.xib | 37 +++++++++ .../Base.lproj/LaunchScreen.storyboard | 27 ++++++ .../Base.lproj/Localizable.strings | 8 ++ .../Base.lproj/SecondViewController.xib | 82 +++++++++++++++++++ .../Class/NSBundle+AppLanguageSwitch.h | 35 ++++++++ .../Class/NSBundle+AppLanguageSwitch.m | 70 ++++++++++++++++ .../FirstViewController.h | 13 +++ .../FirstViewController.m | 53 ++++++++++++ .../iOSAppLanguageSwitchDemo/Info.plist | 43 ++++++++++ .../SecondViewController.h | 13 +++ .../SecondViewController.m | 60 ++++++++++++++ .../en.lproj/FirstViewController.strings | 3 + .../en.lproj/Localizable.strings | 8 ++ .../en.lproj/SecondViewController.strings | 18 ++++ .../iOSAppLanguageSwitchDemo/main.m | 16 ++++ .../zh-Hans.lproj/FirstViewController.strings | 3 + .../zh-Hans.lproj/LaunchScreen.strings | 1 + .../zh-Hans.lproj/Localizable.strings | 8 ++ .../SecondViewController.strings | 18 ++++ 22 files changed, 659 insertions(+) create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/AppDelegate.h create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/AppDelegate.m create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/FirstViewController.xib create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/LaunchScreen.storyboard create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/Localizable.strings create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/SecondViewController.xib create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Class/NSBundle+AppLanguageSwitch.h create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Class/NSBundle+AppLanguageSwitch.m create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/FirstViewController.h create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/FirstViewController.m create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Info.plist create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/SecondViewController.h create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/SecondViewController.m create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/FirstViewController.strings create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/Localizable.strings create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/SecondViewController.strings create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/main.m create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/FirstViewController.strings create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/LaunchScreen.strings create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/Localizable.strings create mode 100644 iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/SecondViewController.strings diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/AppDelegate.h b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/AppDelegate.h new file mode 100644 index 0000000..4052739 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// iOSAppLanguageSwitchDemo +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/AppDelegate.m b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/AppDelegate.m new file mode 100644 index 0000000..dfeeae4 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/AppDelegate.m @@ -0,0 +1,58 @@ +// +// AppDelegate.m +// iOSAppLanguageSwitchDemo +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import "AppDelegate.h" +#import "FirstViewController.h" +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.backgroundColor = [UIColor whiteColor]; + [self.window makeKeyAndVisible]; + + FirstViewController *vc = [[FirstViewController alloc] init]; + self.window.rootViewController = vc; + + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..36d2c80 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/FirstViewController.xib b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/FirstViewController.xib new file mode 100644 index 0000000..a6f73dd --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/FirstViewController.xib @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/LaunchScreen.storyboard b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/Localizable.strings b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/Localizable.strings new file mode 100644 index 0000000..a55d7f2 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/Localizable.strings @@ -0,0 +1,8 @@ +/* + Localizable.strings + iOSAppLanguageSwitchDemo + + Created by zengqingfu on 2017/6/13. + Copyright © 2017年 zengqingfu. All rights reserved. +*/ +"cus_item" = "这是base"; diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/SecondViewController.xib b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/SecondViewController.xib new file mode 100644 index 0000000..36fd46a --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Base.lproj/SecondViewController.xib @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Class/NSBundle+AppLanguageSwitch.h b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Class/NSBundle+AppLanguageSwitch.h new file mode 100644 index 0000000..6889185 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Class/NSBundle+AppLanguageSwitch.h @@ -0,0 +1,35 @@ +// +// NSBundle+AppLanguageSwitch.h +// https://github.com/zengqingf/iOSAppLanguageSwitch +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import +//语言改变通知 +FOUNDATION_EXPORT NSString * const ZZAppLanguageDidChangeNotification; +@interface NSBundle (AppLanguageSwitch) + +/** + 设置语言 + + @param language 参数为语言包的前缀,比如Base.lproj 传入Base、 + 中文语言包zh-Hans.lproj传入zh-Hans,前提是工程中已经提前加入了语言包 + */ ++ (void)setCusLanguage:(NSString *)language; + + +/** + 获取当前的自定义语言,如果使用的是跟随系统语言出参为nil + + @return 语言类型 + */ ++ (NSString *)getCusLanguage; + + +/** + 恢复成跟随系统语言 + */ ++ (void)restoreSysLanguage; +@end diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Class/NSBundle+AppLanguageSwitch.m b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Class/NSBundle+AppLanguageSwitch.m new file mode 100644 index 0000000..0876ac9 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Class/NSBundle+AppLanguageSwitch.m @@ -0,0 +1,70 @@ +// +// NSBundle+AppLanguageSwitch.m +// https://github.com/zengqingf/iOSAppLanguageSwitch +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import "NSBundle+AppLanguageSwitch.h" +#import + + +NSString * const ZZAppLanguageDidChangeNotification = @"cc.devfu.languagedidchange"; + +static const char kBundleKey = 0; +@interface ZZBundleEx : NSBundle +@end + +@implementation ZZBundleEx + +- (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName { + NSBundle *bundle = objc_getAssociatedObject(self, &kBundleKey); + if (bundle) { + return [bundle localizedStringForKey:key value:value table:tableName]; + } else { + return [super localizedStringForKey:key value:value table:tableName]; + } +} +@end + + +static NSString *AppLanguageSwitchKey = @"App_Language_Switch_Key"; +@implementation NSBundle (AppLanguageSwitch) ++ (void)setCusLanguage:(NSString *)language { + id value = nil; + NSUserDefaults *df = [NSUserDefaults standardUserDefaults]; + if (language) { + value = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:language ofType:@"lproj"]]; + NSAssert(value != nil, @"value不能为空,请检查参数是否正确"); + [df setObject:language forKey:AppLanguageSwitchKey]; + [df synchronize]; + } else { + [df removeObjectForKey:AppLanguageSwitchKey]; + [df synchronize]; + } + objc_setAssociatedObject([NSBundle mainBundle], &kBundleKey, value, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + [[NSNotificationCenter defaultCenter] postNotificationName:ZZAppLanguageDidChangeNotification object:nil]; +} + ++ (NSString *)getCusLanguage { + NSUserDefaults *df = [NSUserDefaults standardUserDefaults]; + NSString *language = [df objectForKey:AppLanguageSwitchKey]; + return language; +} + ++ (void)restoreSysLanguage { + [self setCusLanguage:nil]; +} + ++ (void)load { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + object_setClass([NSBundle mainBundle],[ZZBundleEx class]); + NSString *language = [self getCusLanguage]; + if (language) { + [self setCusLanguage:language]; + } + }); +} +@end diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/FirstViewController.h b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/FirstViewController.h new file mode 100644 index 0000000..ac645e2 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/FirstViewController.h @@ -0,0 +1,13 @@ +// +// FirstViewController.h +// iOSAppLanguageSwitchDemo +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import + +@interface FirstViewController : UIViewController + +@end diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/FirstViewController.m b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/FirstViewController.m new file mode 100644 index 0000000..044f3f9 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/FirstViewController.m @@ -0,0 +1,53 @@ +// +// FirstViewController.m +// iOSAppLanguageSwitchDemo +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import "FirstViewController.h" +#import "SecondViewController.h" +#import "NSBundle+AppLanguageSwitch.h" +@interface FirstViewController () + +@end + +@implementation FirstViewController +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageChange:) name:ZZAppLanguageDidChangeNotification object:nil]; +} + +- (void)languageChange:(id)sender { + if (self.isViewLoaded && !self.view.window) { + self.view = nil; + } +} + + +- (IBAction)nextVCAction:(id)sender { + SecondViewController *vc = [[SecondViewController alloc] init]; + [self presentViewController:vc animated:YES completion:nil]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Info.plist b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Info.plist new file mode 100644 index 0000000..c12df3b --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/Info.plist @@ -0,0 +1,43 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/SecondViewController.h b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/SecondViewController.h new file mode 100644 index 0000000..66362a6 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/SecondViewController.h @@ -0,0 +1,13 @@ +// +// SecondViewController.h +// iOSAppLanguageSwitchDemo +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import + +@interface SecondViewController : UIViewController + +@end diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/SecondViewController.m b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/SecondViewController.m new file mode 100644 index 0000000..959ba5c --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/SecondViewController.m @@ -0,0 +1,60 @@ +// +// SecondViewController.m +// iOSAppLanguageSwitchDemo +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import "SecondViewController.h" +#import "NSBundle+AppLanguageSwitch.h" +@interface SecondViewController () + +@end + +@implementation SecondViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. +} +- (IBAction)closeAction:(id)sender { + [self dismissViewControllerAnimated:YES completion:nil]; +} +- (IBAction)setupChineseAction:(id)sender { + [NSBundle setCusLanguage:@"zh-Hans"]; +} + +- (IBAction)setupEnglishAction:(id)sender { + [NSBundle setCusLanguage:@"en"]; +} + +- (IBAction)currentLanguage:(id)sender { + NSString *currLanguage = [NSBundle getCusLanguage]; + NSLog(@"当前语言是=%@", currLanguage); +} +- (IBAction)restoreLanguageAction:(id)sender { + [NSBundle restoreSysLanguage]; +} +- (IBAction)strTestAction:(id)sender { + + NSString *tes = NSLocalizedString(@"cus_item", nil); + NSLog(@"测试字符的结果是=%@", tes); +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/FirstViewController.strings b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/FirstViewController.strings new file mode 100644 index 0000000..0c899d3 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/FirstViewController.strings @@ -0,0 +1,3 @@ + +/* Class = "UIButton"; normalTitle = "下一页"; ObjectID = "dJk-yb-oRh"; */ +"dJk-yb-oRh.normalTitle" = "Next"; diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/Localizable.strings b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/Localizable.strings new file mode 100644 index 0000000..b408690 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/Localizable.strings @@ -0,0 +1,8 @@ +/* + Localizable.strings + iOSAppLanguageSwitchDemo + + Created by zengqingfu on 2017/6/13. + Copyright © 2017年 zengqingfu. All rights reserved. +*/ +"cus_item" = "This is English"; diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/SecondViewController.strings b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/SecondViewController.strings new file mode 100644 index 0000000..f7634e9 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/en.lproj/SecondViewController.strings @@ -0,0 +1,18 @@ + +/* Class = "UIButton"; normalTitle = "关闭"; ObjectID = "CK4-kE-Lyr"; */ +"CK4-kE-Lyr.normalTitle" = "Close"; + +/* Class = "UIButton"; normalTitle = "设置成英文"; ObjectID = "FKp-xO-AWr"; */ +"FKp-xO-AWr.normalTitle" = "Use English"; + +/* Class = "UIButton"; normalTitle = "恢复系统语言"; ObjectID = "hqn-O1-exW"; */ +"hqn-O1-exW.normalTitle" = "Restore To System Language"; + +/* Class = "UIButton"; normalTitle = "设置成中文"; ObjectID = "sRN-Uf-gCL"; */ +"sRN-Uf-gCL.normalTitle" = "Use Chinese"; + +/* Class = "UIButton"; normalTitle = "获取当前自定义语言"; ObjectID = "wzO-U2-Cbk"; */ +"wzO-U2-Cbk.normalTitle" = "get Current Language"; + +/* Class = "UIButton"; normalTitle = "字符串测试"; ObjectID = "kXe-Ad-9Ls"; */ +"kXe-Ad-9Ls.normalTitle" = "String Test"; diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/main.m b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/main.m new file mode 100644 index 0000000..958ba49 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/main.m @@ -0,0 +1,16 @@ +// +// main.m +// iOSAppLanguageSwitchDemo +// +// Created by zengqingfu on 2017/6/13. +// Copyright © 2017年 zengqingfu. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/FirstViewController.strings b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/FirstViewController.strings new file mode 100644 index 0000000..983c9c9 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/FirstViewController.strings @@ -0,0 +1,3 @@ + +/* Class = "UIButton"; normalTitle = "下一页"; ObjectID = "dJk-yb-oRh"; */ +"dJk-yb-oRh.normalTitle" = "下一页"; diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/LaunchScreen.strings b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/LaunchScreen.strings new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/LaunchScreen.strings @@ -0,0 +1 @@ + diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/Localizable.strings b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/Localizable.strings new file mode 100644 index 0000000..596a65d --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/Localizable.strings @@ -0,0 +1,8 @@ +/* + Localizable.strings + iOSAppLanguageSwitchDemo + + Created by zengqingfu on 2017/6/13. + Copyright © 2017年 zengqingfu. All rights reserved. +*/ +"cus_item" = "这是中文"; diff --git a/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/SecondViewController.strings b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/SecondViewController.strings new file mode 100644 index 0000000..f54623c --- /dev/null +++ b/iOSAppLanguageSwitchDemo/iOSAppLanguageSwitchDemo/zh-Hans.lproj/SecondViewController.strings @@ -0,0 +1,18 @@ + +/* Class = "UIButton"; normalTitle = "关闭"; ObjectID = "CK4-kE-Lyr"; */ +"CK4-kE-Lyr.normalTitle" = "关闭"; + +/* Class = "UIButton"; normalTitle = "设置成英文"; ObjectID = "FKp-xO-AWr"; */ +"FKp-xO-AWr.normalTitle" = "设置成英文"; + +/* Class = "UIButton"; normalTitle = "恢复系统语言"; ObjectID = "hqn-O1-exW"; */ +"hqn-O1-exW.normalTitle" = "恢复系统语言"; + +/* Class = "UIButton"; normalTitle = "字符串测试"; ObjectID = "kXe-Ad-9Ls"; */ +"kXe-Ad-9Ls.normalTitle" = "字符串测试"; + +/* Class = "UIButton"; normalTitle = "设置成中文"; ObjectID = "sRN-Uf-gCL"; */ +"sRN-Uf-gCL.normalTitle" = "设置成中文"; + +/* Class = "UIButton"; normalTitle = "获取当前自定义语言"; ObjectID = "wzO-U2-Cbk"; */ +"wzO-U2-Cbk.normalTitle" = "获取当前自定义语言";