├── .gitignore ├── LICENSE ├── README.md ├── SimpleLocalizedTool ├── SimpleLocalizedTool.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── SimpleLocalizedTool │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── Main.storyboard │ ├── DragView.h │ ├── DragView.m │ ├── Info.plist │ ├── LocalizedStringHandle.h │ ├── LocalizedStringHandle.m │ ├── Test.h │ ├── Test.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── screen shot 1.png └── screen shot 2.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 zsy78191 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SimpleLocalizedTool 2 | 3 | 本地化自动摘取工具。 4 | 5 | ## 使用方法 6 | 7 | 脱取文件进入拖放区域,自动在文件目录中生成Localizable.strings文件和其他对应的本地化文件。 8 | 9 | 支持的文件格式是 .m 和 .mm文件,支持的语法格式是 10 | 11 | ``` 12 | NSString* a = NSLocalizedString(@"这是一个测试", nil); 13 | NSString* b = NSLocalizedString(@"第一条是普通本地化, 翻译写入Localizable.strings文件", nil); 14 | NSString* c = NSLocalizedString(@"第二条是带注释的语句", @"这里是这条本地化语句的注释"); 15 | NSString* d = NSLocalizedStringFromTable(@"第三条是带表名的本地化语句,写在 XXX(表名).strings文件里", @"OtherFile",nil); 16 | NSString* e = NSLocalizedStringFromTable( @"最后一条测试书写规范,空格,特殊符号(\"{@#$)等等" , @"OtherFile" , nil); 17 | ``` 18 | 19 | ## 生成的文件 20 | 21 | ``` 22 | //Localizable.strings 23 | 24 | "这是一个测试" = "这是一个测试"; 25 | "第一条是普通本地化, 翻译写入Localizable.strings文件" = "第一条是普通本地化, 翻译写入Localizable.strings文件"; 26 | "第二条是带注释的语句" = "第二条是带注释的语句"; 27 | 28 | 29 | //OtherFile.strings 30 | 31 | "第三条是带表名的本地化语句,写在 XXX(表名).strings文件里" = "第三条是带表名的本地化语句,写在 XXX(表名).strings文件里"; 32 | "最后一条测试书写规范,空格,特殊符号(\"{@#$)等等" = "最后一条测试书写规范,空格,特殊符号(\"{@#$)等等"; 33 | ``` 34 | 35 | 36 | ![](https://raw.githubusercontent.com/zsy78191/SimpleLocalizedTool/master/screen%20shot%201.png) 37 | 38 | ![](https://raw.githubusercontent.com/zsy78191/SimpleLocalizedTool/master/screen%20shot%202.png) 39 | 40 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D4AC9F4A1C27EB9F00A983F3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AC9F491C27EB9F00A983F3 /* AppDelegate.m */; }; 11 | D4AC9F4D1C27EB9F00A983F3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AC9F4C1C27EB9F00A983F3 /* main.m */; }; 12 | D4AC9F501C27EB9F00A983F3 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AC9F4F1C27EB9F00A983F3 /* ViewController.m */; }; 13 | D4AC9F521C27EB9F00A983F3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D4AC9F511C27EB9F00A983F3 /* Assets.xcassets */; }; 14 | D4AC9F551C27EB9F00A983F3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D4AC9F531C27EB9F00A983F3 /* Main.storyboard */; }; 15 | D4AC9F611C27F49200A983F3 /* DragView.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AC9F601C27F49200A983F3 /* DragView.m */; }; 16 | D4AC9F641C27FDD300A983F3 /* LocalizedStringHandle.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AC9F631C27FDD300A983F3 /* LocalizedStringHandle.m */; }; 17 | D4AC9F671C28EAD500A983F3 /* Test.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AC9F661C28EAD500A983F3 /* Test.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | D4AC9F451C27EB9F00A983F3 /* SimpleLocalizedTool.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleLocalizedTool.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | D4AC9F481C27EB9F00A983F3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 23 | D4AC9F491C27EB9F00A983F3 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 24 | D4AC9F4C1C27EB9F00A983F3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 25 | D4AC9F4E1C27EB9F00A983F3 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 26 | D4AC9F4F1C27EB9F00A983F3 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 27 | D4AC9F511C27EB9F00A983F3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | D4AC9F541C27EB9F00A983F3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | D4AC9F561C27EB9F00A983F3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | D4AC9F5F1C27F49200A983F3 /* DragView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragView.h; sourceTree = ""; }; 31 | D4AC9F601C27F49200A983F3 /* DragView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DragView.m; sourceTree = ""; }; 32 | D4AC9F621C27FDD300A983F3 /* LocalizedStringHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedStringHandle.h; sourceTree = ""; }; 33 | D4AC9F631C27FDD300A983F3 /* LocalizedStringHandle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalizedStringHandle.m; sourceTree = ""; }; 34 | D4AC9F651C28EAD500A983F3 /* Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test.h; sourceTree = ""; }; 35 | D4AC9F661C28EAD500A983F3 /* Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Test.m; sourceTree = ""; }; 36 | /* End PBXFileReference section */ 37 | 38 | /* Begin PBXFrameworksBuildPhase section */ 39 | D4AC9F421C27EB9F00A983F3 /* Frameworks */ = { 40 | isa = PBXFrameworksBuildPhase; 41 | buildActionMask = 2147483647; 42 | files = ( 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | /* End PBXFrameworksBuildPhase section */ 47 | 48 | /* Begin PBXGroup section */ 49 | D4AC9F3C1C27EB9F00A983F3 = { 50 | isa = PBXGroup; 51 | children = ( 52 | D4AC9F471C27EB9F00A983F3 /* SimpleLocalizedTool */, 53 | D4AC9F461C27EB9F00A983F3 /* Products */, 54 | ); 55 | sourceTree = ""; 56 | }; 57 | D4AC9F461C27EB9F00A983F3 /* Products */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | D4AC9F451C27EB9F00A983F3 /* SimpleLocalizedTool.app */, 61 | ); 62 | name = Products; 63 | sourceTree = ""; 64 | }; 65 | D4AC9F471C27EB9F00A983F3 /* SimpleLocalizedTool */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | D4AC9F651C28EAD500A983F3 /* Test.h */, 69 | D4AC9F661C28EAD500A983F3 /* Test.m */, 70 | D4AC9F621C27FDD300A983F3 /* LocalizedStringHandle.h */, 71 | D4AC9F631C27FDD300A983F3 /* LocalizedStringHandle.m */, 72 | D4AC9F5F1C27F49200A983F3 /* DragView.h */, 73 | D4AC9F601C27F49200A983F3 /* DragView.m */, 74 | D4AC9F481C27EB9F00A983F3 /* AppDelegate.h */, 75 | D4AC9F491C27EB9F00A983F3 /* AppDelegate.m */, 76 | D4AC9F4E1C27EB9F00A983F3 /* ViewController.h */, 77 | D4AC9F4F1C27EB9F00A983F3 /* ViewController.m */, 78 | D4AC9F511C27EB9F00A983F3 /* Assets.xcassets */, 79 | D4AC9F531C27EB9F00A983F3 /* Main.storyboard */, 80 | D4AC9F561C27EB9F00A983F3 /* Info.plist */, 81 | D4AC9F4B1C27EB9F00A983F3 /* Supporting Files */, 82 | ); 83 | path = SimpleLocalizedTool; 84 | sourceTree = ""; 85 | }; 86 | D4AC9F4B1C27EB9F00A983F3 /* Supporting Files */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | D4AC9F4C1C27EB9F00A983F3 /* main.m */, 90 | ); 91 | name = "Supporting Files"; 92 | sourceTree = ""; 93 | }; 94 | /* End PBXGroup section */ 95 | 96 | /* Begin PBXNativeTarget section */ 97 | D4AC9F441C27EB9F00A983F3 /* SimpleLocalizedTool */ = { 98 | isa = PBXNativeTarget; 99 | buildConfigurationList = D4AC9F591C27EB9F00A983F3 /* Build configuration list for PBXNativeTarget "SimpleLocalizedTool" */; 100 | buildPhases = ( 101 | D4AC9F411C27EB9F00A983F3 /* Sources */, 102 | D4AC9F421C27EB9F00A983F3 /* Frameworks */, 103 | D4AC9F431C27EB9F00A983F3 /* Resources */, 104 | ); 105 | buildRules = ( 106 | ); 107 | dependencies = ( 108 | ); 109 | name = SimpleLocalizedTool; 110 | productName = SimpleLocalizedTool; 111 | productReference = D4AC9F451C27EB9F00A983F3 /* SimpleLocalizedTool.app */; 112 | productType = "com.apple.product-type.application"; 113 | }; 114 | /* End PBXNativeTarget section */ 115 | 116 | /* Begin PBXProject section */ 117 | D4AC9F3D1C27EB9F00A983F3 /* Project object */ = { 118 | isa = PBXProject; 119 | attributes = { 120 | LastUpgradeCheck = 0720; 121 | ORGANIZATIONNAME = gerinn; 122 | TargetAttributes = { 123 | D4AC9F441C27EB9F00A983F3 = { 124 | CreatedOnToolsVersion = 7.2; 125 | }; 126 | }; 127 | }; 128 | buildConfigurationList = D4AC9F401C27EB9F00A983F3 /* Build configuration list for PBXProject "SimpleLocalizedTool" */; 129 | compatibilityVersion = "Xcode 3.2"; 130 | developmentRegion = English; 131 | hasScannedForEncodings = 0; 132 | knownRegions = ( 133 | en, 134 | Base, 135 | ); 136 | mainGroup = D4AC9F3C1C27EB9F00A983F3; 137 | productRefGroup = D4AC9F461C27EB9F00A983F3 /* Products */; 138 | projectDirPath = ""; 139 | projectRoot = ""; 140 | targets = ( 141 | D4AC9F441C27EB9F00A983F3 /* SimpleLocalizedTool */, 142 | ); 143 | }; 144 | /* End PBXProject section */ 145 | 146 | /* Begin PBXResourcesBuildPhase section */ 147 | D4AC9F431C27EB9F00A983F3 /* Resources */ = { 148 | isa = PBXResourcesBuildPhase; 149 | buildActionMask = 2147483647; 150 | files = ( 151 | D4AC9F521C27EB9F00A983F3 /* Assets.xcassets in Resources */, 152 | D4AC9F551C27EB9F00A983F3 /* Main.storyboard in Resources */, 153 | ); 154 | runOnlyForDeploymentPostprocessing = 0; 155 | }; 156 | /* End PBXResourcesBuildPhase section */ 157 | 158 | /* Begin PBXSourcesBuildPhase section */ 159 | D4AC9F411C27EB9F00A983F3 /* Sources */ = { 160 | isa = PBXSourcesBuildPhase; 161 | buildActionMask = 2147483647; 162 | files = ( 163 | D4AC9F501C27EB9F00A983F3 /* ViewController.m in Sources */, 164 | D4AC9F4D1C27EB9F00A983F3 /* main.m in Sources */, 165 | D4AC9F641C27FDD300A983F3 /* LocalizedStringHandle.m in Sources */, 166 | D4AC9F671C28EAD500A983F3 /* Test.m in Sources */, 167 | D4AC9F611C27F49200A983F3 /* DragView.m in Sources */, 168 | D4AC9F4A1C27EB9F00A983F3 /* AppDelegate.m in Sources */, 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXSourcesBuildPhase section */ 173 | 174 | /* Begin PBXVariantGroup section */ 175 | D4AC9F531C27EB9F00A983F3 /* Main.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | D4AC9F541C27EB9F00A983F3 /* Base */, 179 | ); 180 | name = Main.storyboard; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXVariantGroup section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | D4AC9F571C27EB9F00A983F3 /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 191 | CLANG_CXX_LIBRARY = "libc++"; 192 | CLANG_ENABLE_MODULES = YES; 193 | CLANG_ENABLE_OBJC_ARC = YES; 194 | CLANG_WARN_BOOL_CONVERSION = YES; 195 | CLANG_WARN_CONSTANT_CONVERSION = YES; 196 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 197 | CLANG_WARN_EMPTY_BODY = YES; 198 | CLANG_WARN_ENUM_CONVERSION = YES; 199 | CLANG_WARN_INT_CONVERSION = YES; 200 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 201 | CLANG_WARN_UNREACHABLE_CODE = YES; 202 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 203 | CODE_SIGN_IDENTITY = "-"; 204 | COPY_PHASE_STRIP = NO; 205 | DEBUG_INFORMATION_FORMAT = dwarf; 206 | ENABLE_STRICT_OBJC_MSGSEND = YES; 207 | ENABLE_TESTABILITY = YES; 208 | GCC_C_LANGUAGE_STANDARD = gnu99; 209 | GCC_DYNAMIC_NO_PIC = NO; 210 | GCC_NO_COMMON_BLOCKS = YES; 211 | GCC_OPTIMIZATION_LEVEL = 0; 212 | GCC_PREPROCESSOR_DEFINITIONS = ( 213 | "DEBUG=1", 214 | "$(inherited)", 215 | ); 216 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 217 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 218 | GCC_WARN_UNDECLARED_SELECTOR = YES; 219 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 220 | GCC_WARN_UNUSED_FUNCTION = YES; 221 | GCC_WARN_UNUSED_VARIABLE = YES; 222 | MACOSX_DEPLOYMENT_TARGET = 10.11; 223 | MTL_ENABLE_DEBUG_INFO = YES; 224 | ONLY_ACTIVE_ARCH = YES; 225 | SDKROOT = macosx; 226 | }; 227 | name = Debug; 228 | }; 229 | D4AC9F581C27EB9F00A983F3 /* Release */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_MODULES = YES; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_WARN_BOOL_CONVERSION = YES; 238 | CLANG_WARN_CONSTANT_CONVERSION = YES; 239 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 240 | CLANG_WARN_EMPTY_BODY = YES; 241 | CLANG_WARN_ENUM_CONVERSION = YES; 242 | CLANG_WARN_INT_CONVERSION = YES; 243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 244 | CLANG_WARN_UNREACHABLE_CODE = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | CODE_SIGN_IDENTITY = "-"; 247 | COPY_PHASE_STRIP = NO; 248 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 249 | ENABLE_NS_ASSERTIONS = NO; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu99; 252 | GCC_NO_COMMON_BLOCKS = YES; 253 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 254 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 255 | GCC_WARN_UNDECLARED_SELECTOR = YES; 256 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 257 | GCC_WARN_UNUSED_FUNCTION = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | MACOSX_DEPLOYMENT_TARGET = 10.11; 260 | MTL_ENABLE_DEBUG_INFO = NO; 261 | SDKROOT = macosx; 262 | }; 263 | name = Release; 264 | }; 265 | D4AC9F5A1C27EB9F00A983F3 /* Debug */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 269 | COMBINE_HIDPI_IMAGES = YES; 270 | INFOPLIST_FILE = SimpleLocalizedTool/Info.plist; 271 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 272 | PRODUCT_BUNDLE_IDENTIFIER = com.gerinn.SimpleLocalizedTool; 273 | PRODUCT_NAME = "$(TARGET_NAME)"; 274 | }; 275 | name = Debug; 276 | }; 277 | D4AC9F5B1C27EB9F00A983F3 /* Release */ = { 278 | isa = XCBuildConfiguration; 279 | buildSettings = { 280 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 281 | COMBINE_HIDPI_IMAGES = YES; 282 | INFOPLIST_FILE = SimpleLocalizedTool/Info.plist; 283 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 284 | PRODUCT_BUNDLE_IDENTIFIER = com.gerinn.SimpleLocalizedTool; 285 | PRODUCT_NAME = "$(TARGET_NAME)"; 286 | }; 287 | name = Release; 288 | }; 289 | /* End XCBuildConfiguration section */ 290 | 291 | /* Begin XCConfigurationList section */ 292 | D4AC9F401C27EB9F00A983F3 /* Build configuration list for PBXProject "SimpleLocalizedTool" */ = { 293 | isa = XCConfigurationList; 294 | buildConfigurations = ( 295 | D4AC9F571C27EB9F00A983F3 /* Debug */, 296 | D4AC9F581C27EB9F00A983F3 /* Release */, 297 | ); 298 | defaultConfigurationIsVisible = 0; 299 | defaultConfigurationName = Release; 300 | }; 301 | D4AC9F591C27EB9F00A983F3 /* Build configuration list for PBXNativeTarget "SimpleLocalizedTool" */ = { 302 | isa = XCConfigurationList; 303 | buildConfigurations = ( 304 | D4AC9F5A1C27EB9F00A983F3 /* Debug */, 305 | D4AC9F5B1C27EB9F00A983F3 /* Release */, 306 | ); 307 | defaultConfigurationIsVisible = 0; 308 | defaultConfigurationName = Release; 309 | }; 310 | /* End XCConfigurationList section */ 311 | }; 312 | rootObject = D4AC9F3D1C27EB9F00A983F3 /* Project object */; 313 | } 314 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "LocalizedStringHandle.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 19 | // Insert code here to initialize your application 20 | 21 | 22 | 23 | } 24 | 25 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 26 | // Insert code here to tear down your application 27 | } 28 | 29 | - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames 30 | { 31 | // NSLog(@"%@",filenames); 32 | 33 | NSString* fileName = filenames.firstObject; 34 | NSError* error; 35 | NSData* data = [NSData dataWithContentsOfFile:fileName options:NSDataReadingMappedAlways error:&error]; 36 | if (error) { 37 | NSLog(@"%@",error); 38 | } 39 | else 40 | { 41 | NSString* content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 42 | [LocalizedStringHandle handleOriginFileContent:content]; 43 | } 44 | 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | Default 511 | 512 | 513 | 514 | 515 | 516 | 517 | Left to Right 518 | 519 | 520 | 521 | 522 | 523 | 524 | Right to Left 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | Default 536 | 537 | 538 | 539 | 540 | 541 | 542 | Left to Right 543 | 544 | 545 | 546 | 547 | 548 | 549 | Right to Left 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/DragView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DragView.h 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DragView : NSView { 12 | BOOL isHighlighted; 13 | BOOL inView; 14 | } 15 | 16 | @property (assign, setter=setHighlighted:) BOOL isHighlighted; 17 | 18 | @property (nonatomic, strong) void (^ getNewTextBlock)(NSDictionary* final, NSString* filepath); 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/DragView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DragView.m 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import "DragView.h" 10 | 11 | #import "LocalizedStringHandle.h" 12 | 13 | @implementation DragView 14 | 15 | @dynamic isHighlighted; 16 | 17 | - (void)awakeFromNib 18 | { 19 | NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd)); 20 | [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]]; 21 | } 22 | 23 | - (NSDragOperation)draggingEntered:(id )sender { 24 | NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd)); 25 | 26 | NSPasteboard *pboard = [sender draggingPasteboard]; 27 | 28 | NSLog(@"%@",[pboard types]); 29 | 30 | inView = YES; 31 | 32 | [self setHighlighted:YES]; 33 | return NSDragOperationEvery; 34 | } 35 | 36 | - (void)draggingEnded:(id)sender 37 | { 38 | if (inView) { 39 | NSPasteboard *pboard = [sender draggingPasteboard]; 40 | NSArray *paths = [pboard propertyListForType:NSFilenamesPboardType]; 41 | NSLog(@"%@",paths); 42 | NSLog(@"end"); 43 | 44 | 45 | NSString* fileName = paths.firstObject; 46 | 47 | if ([fileName hasSuffix:@".m"]||[fileName hasSuffix:@".mm"]) { 48 | NSError* error; 49 | NSData* data = [NSData dataWithContentsOfFile:fileName options:NSDataReadingMappedAlways error:&error]; 50 | if (error) { 51 | NSLog(@"%@",error); 52 | } 53 | else 54 | { 55 | NSString* content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 56 | NSDictionary* final = [LocalizedStringHandle handleOriginFileContent:content]; 57 | if (self.getNewTextBlock) { 58 | self.getNewTextBlock(final,fileName); 59 | } 60 | 61 | } 62 | } 63 | else 64 | { 65 | NSLog(@"文件格式不支持"); 66 | } 67 | } 68 | } 69 | 70 | - (void)draggingExited:(id )sender { 71 | [self setHighlighted:NO]; 72 | 73 | inView = NO; 74 | } 75 | 76 | 77 | - (BOOL)prepareForDragOperation:(id )sender { 78 | return YES; 79 | } 80 | 81 | - (BOOL)performDragOperation:(id )sender { 82 | [self setHighlighted:NO]; 83 | return YES; 84 | } 85 | - (BOOL)isHighlighted { 86 | return isHighlighted; 87 | } 88 | 89 | - (void)setHighlighted:(BOOL)value { 90 | isHighlighted = value; 91 | [self setNeedsDisplay:YES]; 92 | } 93 | 94 | - (void)drawRect:(NSRect)dirtyRect { 95 | [super drawRect:dirtyRect]; 96 | NSLog(@"%@",@(isHighlighted)); 97 | if (isHighlighted) { 98 | [NSBezierPath setDefaultLineWidth:6.0]; 99 | [[NSColor keyboardFocusIndicatorColor] set]; 100 | [NSBezierPath strokeRect:self.frame]; 101 | } 102 | } 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | m 13 | 14 | CFBundleTypeName 15 | m 16 | CFBundleTypeRole 17 | Viewer 18 | LSHandlerRank 19 | Owner 20 | 21 | 22 | CFBundleTypeExtensions 23 | 24 | mm 25 | 26 | CFBundleTypeName 27 | mm 28 | CFBundleTypeRole 29 | Viewer 30 | 31 | 32 | CFBundleExecutable 33 | $(EXECUTABLE_NAME) 34 | CFBundleIconFile 35 | 36 | CFBundleIdentifier 37 | $(PRODUCT_BUNDLE_IDENTIFIER) 38 | CFBundleInfoDictionaryVersion 39 | 6.0 40 | CFBundleName 41 | $(PRODUCT_NAME) 42 | CFBundlePackageType 43 | APPL 44 | CFBundleShortVersionString 45 | 1.0 46 | CFBundleSignature 47 | ???? 48 | CFBundleVersion 49 | 1 50 | LSMinimumSystemVersion 51 | $(MACOSX_DEPLOYMENT_TARGET) 52 | NSHumanReadableCopyright 53 | Copyright © 2015年 gerinn. All rights reserved. 54 | NSMainStoryboardFile 55 | Main 56 | NSPrincipalClass 57 | NSApplication 58 | 59 | 60 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/LocalizedStringHandle.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocalizedStringHandle.h 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LocalizedStringHandle : NSObject 12 | 13 | + (NSDictionary*)handleOriginFileContent:(NSString*)content; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/LocalizedStringHandle.m: -------------------------------------------------------------------------------- 1 | // 2 | // LocalizedStringHandle.m 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import "LocalizedStringHandle.h" 10 | 11 | @implementation LocalizedStringHandle 12 | 13 | + (NSDictionary *)handleOriginFileContent:(NSString *)content 14 | { 15 | 16 | //((\s*@".*?"\s*,?\s*)|\s*nil\s*,?\s*){2,3} 17 | NSError* error; 18 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"NSLocalizedString\\s*\\(((\\s*@\".*?\"\\s*,?\\s*)|\\s*nil\\s*,?\\s*){2,3}\\)|NSLocalizedStringFromTable\\s*\\(((\\s*@\".*?\"\\s*,?\\s*)|\\s*nil\\s*,?\\s*){2,3}\\)" options:NSRegularExpressionCaseInsensitive error:&error]; 19 | NSArray* array = [regex matchesInString:content options:kNilOptions range:NSMakeRange(0, content.length)]; 20 | NSMutableArray* results = [NSMutableArray array]; 21 | 22 | [array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 23 | NSTextCheckingResult* result = obj; 24 | NSString* temp = [content substringWithRange:result.range]; 25 | [results addObject:temp]; 26 | }]; 27 | 28 | NSMutableDictionary* final = [NSMutableDictionary dictionary]; 29 | 30 | [results enumerateObjectsUsingBlock:^(NSString* _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 31 | 32 | NSError* error; 33 | // NSMutableString* string = [obj mutableCopy]; 34 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(?<=@\").*?(?=((? 10 | 11 | @interface Test : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/Test.m: -------------------------------------------------------------------------------- 1 | // 2 | // Test.m 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/22. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import "Test.h" 10 | 11 | @implementation Test 12 | 13 | - (instancetype)init 14 | { 15 | self = [super init]; 16 | if (self) { 17 | 18 | 19 | NSString* a = NSLocalizedString(@"这是一个测试", nil); 20 | NSString* b = NSLocalizedString(@"第一条是普通本地化, 翻译写入Localizable.strings文件", nil); 21 | NSString* c = NSLocalizedString(@"第二条是带注释的语句", @"这里是这条本地化语句的注释"); 22 | NSString* d = NSLocalizedStringFromTable(@"第三条是带表名的本地化语句,写在 XXX(表名).strings文件里", @"OtherFile",nil); 23 | NSString* e = NSLocalizedStringFromTable( @"最后一条测试书写规范,空格,特殊符号(\"{@#$)等等" , @"OtherFile" , nil); 24 | 25 | 26 | [self handle:a]; 27 | [self handle:b]; 28 | [self handle:c]; 29 | [self handle:d]; 30 | [self handle:e]; 31 | 32 | } 33 | return self; 34 | } 35 | 36 | - (void)handle:(NSString*)string 37 | { 38 | 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "DragView.h" 12 | 13 | @interface ViewController : NSViewController 14 | 15 | 16 | @property (unsafe_unretained) IBOutlet NSTextView *textView; 17 | 18 | 19 | 20 | @end 21 | 22 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @implementation ViewController 12 | 13 | - (void)viewDidLoad { 14 | [super viewDidLoad]; 15 | 16 | // Do any additional setup after loading the view. 17 | 18 | [self.view registerForDraggedTypes:@[NSPasteboardTypeString]]; 19 | 20 | __weak ViewController* weakSelf = self; 21 | NSMutableString* string = [NSMutableString string]; 22 | 23 | [(DragView*)self.view setGetNewTextBlock:^(NSDictionary * dictionary,NSString* filepath) { 24 | __strong ViewController* strongSelf = weakSelf; 25 | 26 | 27 | [string appendFormat:@"//%@\n",filepath]; 28 | [[dictionary allKeys] enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 29 | 30 | NSString* path = [[filepath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.strings",obj]]; 31 | NSMutableString* stringWrite = [NSMutableString string]; 32 | if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { 33 | 34 | NSData* d = [NSData dataWithContentsOfFile:path]; 35 | NSString* origin = [[NSString alloc] initWithData:d encoding:NSUTF8StringEncoding]; 36 | [stringWrite appendString:origin]; 37 | 38 | // NSArray* originArray = [strongSelf findString:@"\".*?\"\\s*?=\\s*?\".*?\";" inString:origin]; 39 | } 40 | else 41 | { 42 | [stringWrite insertString:[NSString stringWithFormat:@"// SimpleLocalizedTool\n//\n// Created by Gerinn on 15/12/21.\n// Copyright © 2015年 gerinn. All rights reserved.\n// Github : https://github.com/zsy78191/SimpleLocalizedTool \n\n"] atIndex:0];\ 43 | } 44 | 45 | [string appendFormat:@"\n\n//%@.strings\n\n",obj]; 46 | 47 | NSArray* array = dictionary[obj]; 48 | [array enumerateObjectsUsingBlock:^(id _Nonnull obj2, NSUInteger idx, BOOL * _Nonnull stop) { 49 | [string appendFormat:@"\"%@\" = \"%@\";\n",obj2,obj2]; 50 | [stringWrite appendFormat:@"\"%@\" = \"%@\";\n",obj2,obj2]; 51 | }]; 52 | 53 | NSData* data = [stringWrite dataUsingEncoding:NSUTF8StringEncoding]; 54 | [data writeToFile:path atomically:YES]; 55 | }]; 56 | 57 | strongSelf.textView.string = string; 58 | }]; 59 | } 60 | 61 | - (void)setRepresentedObject:(id)representedObject { 62 | [super setRepresentedObject:representedObject]; 63 | 64 | // Update the view, if already loaded. 65 | } 66 | 67 | 68 | - (NSArray*)findString:(NSString*)string inString:(NSString*)origin 69 | { 70 | NSError* error; 71 | // NSMutableString* string = [obj mutableCopy]; 72 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:string options:NSRegularExpressionCaseInsensitive error:&error]; 73 | NSArray* array_temp = [regex matchesInString:origin options:kNilOptions range:NSMakeRange(0, origin.length)]; 74 | return array_temp; 75 | } 76 | 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /SimpleLocalizedTool/SimpleLocalizedTool/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleLocalizedTool 4 | // 5 | // Created by 张超 on 15/12/21. 6 | // Copyright © 2015年 gerinn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /screen shot 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsy78191/SimpleLocalizedTool/4541938bdb4400e5935dfaac05045e844bbdcbb7/screen shot 1.png -------------------------------------------------------------------------------- /screen shot 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsy78191/SimpleLocalizedTool/4541938bdb4400e5935dfaac05045e844bbdcbb7/screen shot 2.png --------------------------------------------------------------------------------