├── .gitignore ├── ManualLanguageSelectionSample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── ManualLanguageSelectionSample ├── 3rdLib.bundle │ └── Resources │ │ ├── en.lproj │ │ └── Localizable.strings │ │ ├── zh-Hans.lproj │ │ └── Localizable.strings │ │ └── zh-Hant.lproj │ │ └── Localizable.strings ├── 3rdLib_Assets │ ├── en.lproj │ │ └── FromTable.strings │ ├── zh-Hans.lproj │ │ └── FromTable.strings │ └── zh-Hant.lproj │ │ └── FromTable.strings ├── ACLanguageUtil │ ├── ACLanguageUtil.h │ └── ACLanguageUtil.m ├── AppDelegate.h ├── AppDelegate.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ ├── Contents.json │ │ ├── Default-568h@2x.png │ │ └── Default@2x.png ├── Info.plist ├── PrefixHeader.pch ├── SettingsViewController.h ├── SettingsViewController.m ├── ViewController.h ├── ViewController.m ├── en.lproj │ ├── InfoPlist.strings │ ├── LaunchScreen.xib │ └── Localizable.strings ├── main.m ├── zh-Hans.lproj │ ├── InfoPlist.strings │ ├── LaunchScreen.xib │ └── Localizable.strings └── zh-Hant.lproj │ ├── InfoPlist.strings │ ├── LaunchScreen.xib │ └── Localizable.strings └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | *.xcworkspace 15 | !default.xcworkspace 16 | xcuserdata 17 | xcuserstate 18 | *.xcuserstate 19 | profile 20 | *.moved-aside 21 | DerivedData 22 | .idea/ 23 | 24 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 764007B21A2713AC00D10B9D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 764007B11A2713AC00D10B9D /* main.m */; }; 11 | 764007B51A2713AC00D10B9D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 764007B41A2713AC00D10B9D /* AppDelegate.m */; }; 12 | 764007B81A2713AC00D10B9D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 764007B71A2713AC00D10B9D /* ViewController.m */; }; 13 | 764007BD1A2713AC00D10B9D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 764007BC1A2713AC00D10B9D /* Images.xcassets */; }; 14 | 764007C01A2713AC00D10B9D /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 764007BE1A2713AC00D10B9D /* LaunchScreen.xib */; }; 15 | 764007D71A2715A300D10B9D /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 764007D61A2715A300D10B9D /* SettingsViewController.m */; }; 16 | 764007DD1A27199000D10B9D /* ACLanguageUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 764007DC1A27199000D10B9D /* ACLanguageUtil.m */; }; 17 | 764007E91A271C2500D10B9D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 764007EB1A271C2500D10B9D /* Localizable.strings */; }; 18 | 764007EC1A271C3A00D10B9D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 764007EE1A271C3A00D10B9D /* InfoPlist.strings */; }; 19 | 7680341A1A27231500C9D236 /* 3rdLib.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 768034191A27231500C9D236 /* 3rdLib.bundle */; }; 20 | 76D94D121A2841E00014EA2B /* FromTable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 76D94D0E1A2841E00014EA2B /* FromTable.strings */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 764007AC1A2713AC00D10B9D /* ManualLanguageSelectionSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ManualLanguageSelectionSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 764007B01A2713AC00D10B9D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 764007B11A2713AC00D10B9D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 27 | 764007B31A2713AC00D10B9D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 28 | 764007B41A2713AC00D10B9D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 29 | 764007B61A2713AC00D10B9D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 30 | 764007B71A2713AC00D10B9D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 31 | 764007BC1A2713AC00D10B9D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 32 | 764007D51A2715A300D10B9D /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; 33 | 764007D61A2715A300D10B9D /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; 34 | 764007D81A27176C00D10B9D /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = ""; }; 35 | 764007DB1A27199000D10B9D /* ACLanguageUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACLanguageUtil.h; sourceTree = ""; }; 36 | 764007DC1A27199000D10B9D /* ACLanguageUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ACLanguageUtil.m; sourceTree = ""; }; 37 | 764007F01A271C4000D10B9D /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = ""; }; 38 | 764007F11A271C4100D10B9D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 39 | 764007F31A271C4E00D10B9D /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/InfoPlist.strings"; sourceTree = ""; }; 40 | 764007F41A271C4E00D10B9D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = ""; }; 41 | 764007F51A271C5700D10B9D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.xib"; sourceTree = ""; }; 42 | 768034151A271CDE00C9D236 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 43 | 768034161A271CDE00C9D236 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 44 | 768034171A271D1B00C9D236 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/LaunchScreen.xib; sourceTree = ""; }; 45 | 768034181A271D1C00C9D236 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "zh-Hant"; path = "zh-Hant.lproj/LaunchScreen.xib"; sourceTree = ""; }; 46 | 768034191A27231500C9D236 /* 3rdLib.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = 3rdLib.bundle; sourceTree = ""; }; 47 | 76D94D0F1A2841E00014EA2B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/FromTable.strings; sourceTree = ""; }; 48 | 76D94D101A2841E00014EA2B /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/FromTable.strings"; sourceTree = ""; }; 49 | 76D94D111A2841E00014EA2B /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/FromTable.strings"; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 764007A91A2713AC00D10B9D /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | /* End PBXFrameworksBuildPhase section */ 61 | 62 | /* Begin PBXGroup section */ 63 | 764007A31A2713AC00D10B9D = { 64 | isa = PBXGroup; 65 | children = ( 66 | 764007AE1A2713AC00D10B9D /* ManualLanguageSelectionSample */, 67 | 764007AD1A2713AC00D10B9D /* Products */, 68 | ); 69 | sourceTree = ""; 70 | }; 71 | 764007AD1A2713AC00D10B9D /* Products */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 764007AC1A2713AC00D10B9D /* ManualLanguageSelectionSample.app */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 764007AE1A2713AC00D10B9D /* ManualLanguageSelectionSample */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 764007DA1A27197400D10B9D /* ACLanguageUtil */, 83 | 764007B31A2713AC00D10B9D /* AppDelegate.h */, 84 | 764007B41A2713AC00D10B9D /* AppDelegate.m */, 85 | 764007B61A2713AC00D10B9D /* ViewController.h */, 86 | 764007B71A2713AC00D10B9D /* ViewController.m */, 87 | 764007D51A2715A300D10B9D /* SettingsViewController.h */, 88 | 764007D61A2715A300D10B9D /* SettingsViewController.m */, 89 | 76D94D0D1A2841E00014EA2B /* 3rdLib_Assets */, 90 | 768034191A27231500C9D236 /* 3rdLib.bundle */, 91 | 764007BC1A2713AC00D10B9D /* Images.xcassets */, 92 | 764007BE1A2713AC00D10B9D /* LaunchScreen.xib */, 93 | 764007AF1A2713AC00D10B9D /* Supporting Files */, 94 | ); 95 | path = ManualLanguageSelectionSample; 96 | sourceTree = ""; 97 | }; 98 | 764007AF1A2713AC00D10B9D /* Supporting Files */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 764007B11A2713AC00D10B9D /* main.m */, 102 | 764007D81A27176C00D10B9D /* PrefixHeader.pch */, 103 | 764007B01A2713AC00D10B9D /* Info.plist */, 104 | 764007EE1A271C3A00D10B9D /* InfoPlist.strings */, 105 | 764007EB1A271C2500D10B9D /* Localizable.strings */, 106 | ); 107 | name = "Supporting Files"; 108 | sourceTree = ""; 109 | }; 110 | 764007DA1A27197400D10B9D /* ACLanguageUtil */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 764007DB1A27199000D10B9D /* ACLanguageUtil.h */, 114 | 764007DC1A27199000D10B9D /* ACLanguageUtil.m */, 115 | ); 116 | path = ACLanguageUtil; 117 | sourceTree = ""; 118 | }; 119 | 76D94D0D1A2841E00014EA2B /* 3rdLib_Assets */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 76D94D0E1A2841E00014EA2B /* FromTable.strings */, 123 | ); 124 | path = 3rdLib_Assets; 125 | sourceTree = ""; 126 | }; 127 | /* End PBXGroup section */ 128 | 129 | /* Begin PBXNativeTarget section */ 130 | 764007AB1A2713AC00D10B9D /* ManualLanguageSelectionSample */ = { 131 | isa = PBXNativeTarget; 132 | buildConfigurationList = 764007CF1A2713AC00D10B9D /* Build configuration list for PBXNativeTarget "ManualLanguageSelectionSample" */; 133 | buildPhases = ( 134 | 764007A81A2713AC00D10B9D /* Sources */, 135 | 764007A91A2713AC00D10B9D /* Frameworks */, 136 | 764007AA1A2713AC00D10B9D /* Resources */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | ); 142 | name = ManualLanguageSelectionSample; 143 | productName = ManualLanguageSelectionSample; 144 | productReference = 764007AC1A2713AC00D10B9D /* ManualLanguageSelectionSample.app */; 145 | productType = "com.apple.product-type.application"; 146 | }; 147 | /* End PBXNativeTarget section */ 148 | 149 | /* Begin PBXProject section */ 150 | 764007A41A2713AC00D10B9D /* Project object */ = { 151 | isa = PBXProject; 152 | attributes = { 153 | LastUpgradeCheck = 0610; 154 | ORGANIZATIONNAME = "Albert Chu"; 155 | TargetAttributes = { 156 | 764007AB1A2713AC00D10B9D = { 157 | CreatedOnToolsVersion = 6.1; 158 | }; 159 | }; 160 | }; 161 | buildConfigurationList = 764007A71A2713AC00D10B9D /* Build configuration list for PBXProject "ManualLanguageSelectionSample" */; 162 | compatibilityVersion = "Xcode 3.2"; 163 | developmentRegion = English; 164 | hasScannedForEncodings = 0; 165 | knownRegions = ( 166 | Base, 167 | "zh-Hant", 168 | "zh-Hans", 169 | en, 170 | ); 171 | mainGroup = 764007A31A2713AC00D10B9D; 172 | productRefGroup = 764007AD1A2713AC00D10B9D /* Products */; 173 | projectDirPath = ""; 174 | projectRoot = ""; 175 | targets = ( 176 | 764007AB1A2713AC00D10B9D /* ManualLanguageSelectionSample */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | 764007AA1A2713AC00D10B9D /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | 764007C01A2713AC00D10B9D /* LaunchScreen.xib in Resources */, 187 | 764007EC1A271C3A00D10B9D /* InfoPlist.strings in Resources */, 188 | 764007E91A271C2500D10B9D /* Localizable.strings in Resources */, 189 | 764007BD1A2713AC00D10B9D /* Images.xcassets in Resources */, 190 | 7680341A1A27231500C9D236 /* 3rdLib.bundle in Resources */, 191 | 76D94D121A2841E00014EA2B /* FromTable.strings in Resources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXResourcesBuildPhase section */ 196 | 197 | /* Begin PBXSourcesBuildPhase section */ 198 | 764007A81A2713AC00D10B9D /* Sources */ = { 199 | isa = PBXSourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | 764007B81A2713AC00D10B9D /* ViewController.m in Sources */, 203 | 764007B51A2713AC00D10B9D /* AppDelegate.m in Sources */, 204 | 764007B21A2713AC00D10B9D /* main.m in Sources */, 205 | 764007D71A2715A300D10B9D /* SettingsViewController.m in Sources */, 206 | 764007DD1A27199000D10B9D /* ACLanguageUtil.m in Sources */, 207 | ); 208 | runOnlyForDeploymentPostprocessing = 0; 209 | }; 210 | /* End PBXSourcesBuildPhase section */ 211 | 212 | /* Begin PBXVariantGroup section */ 213 | 764007BE1A2713AC00D10B9D /* LaunchScreen.xib */ = { 214 | isa = PBXVariantGroup; 215 | children = ( 216 | 764007F51A271C5700D10B9D /* zh-Hans */, 217 | 768034171A271D1B00C9D236 /* en */, 218 | 768034181A271D1C00C9D236 /* zh-Hant */, 219 | ); 220 | name = LaunchScreen.xib; 221 | sourceTree = ""; 222 | }; 223 | 764007EB1A271C2500D10B9D /* Localizable.strings */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 764007F01A271C4000D10B9D /* zh-Hant */, 227 | 764007F11A271C4100D10B9D /* zh-Hans */, 228 | 768034161A271CDE00C9D236 /* en */, 229 | ); 230 | name = Localizable.strings; 231 | sourceTree = ""; 232 | }; 233 | 764007EE1A271C3A00D10B9D /* InfoPlist.strings */ = { 234 | isa = PBXVariantGroup; 235 | children = ( 236 | 764007F31A271C4E00D10B9D /* zh-Hant */, 237 | 764007F41A271C4E00D10B9D /* zh-Hans */, 238 | 768034151A271CDE00C9D236 /* en */, 239 | ); 240 | name = InfoPlist.strings; 241 | sourceTree = ""; 242 | }; 243 | 76D94D0E1A2841E00014EA2B /* FromTable.strings */ = { 244 | isa = PBXVariantGroup; 245 | children = ( 246 | 76D94D0F1A2841E00014EA2B /* en */, 247 | 76D94D101A2841E00014EA2B /* zh-Hans */, 248 | 76D94D111A2841E00014EA2B /* zh-Hant */, 249 | ); 250 | name = FromTable.strings; 251 | sourceTree = ""; 252 | }; 253 | /* End PBXVariantGroup section */ 254 | 255 | /* Begin XCBuildConfiguration section */ 256 | 764007CD1A2713AC00D10B9D /* Debug */ = { 257 | isa = XCBuildConfiguration; 258 | buildSettings = { 259 | ALWAYS_SEARCH_USER_PATHS = NO; 260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 261 | CLANG_CXX_LIBRARY = "libc++"; 262 | CLANG_ENABLE_MODULES = YES; 263 | CLANG_ENABLE_OBJC_ARC = YES; 264 | CLANG_WARN_BOOL_CONVERSION = YES; 265 | CLANG_WARN_CONSTANT_CONVERSION = YES; 266 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 267 | CLANG_WARN_EMPTY_BODY = YES; 268 | CLANG_WARN_ENUM_CONVERSION = YES; 269 | CLANG_WARN_INT_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_UNREACHABLE_CODE = YES; 272 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 273 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 274 | COPY_PHASE_STRIP = NO; 275 | ENABLE_STRICT_OBJC_MSGSEND = YES; 276 | GCC_C_LANGUAGE_STANDARD = gnu99; 277 | GCC_DYNAMIC_NO_PIC = NO; 278 | GCC_OPTIMIZATION_LEVEL = 0; 279 | GCC_PREPROCESSOR_DEFINITIONS = ( 280 | "DEBUG=1", 281 | "$(inherited)", 282 | ); 283 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 286 | GCC_WARN_UNDECLARED_SELECTOR = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 288 | GCC_WARN_UNUSED_FUNCTION = YES; 289 | GCC_WARN_UNUSED_VARIABLE = YES; 290 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 291 | MTL_ENABLE_DEBUG_INFO = YES; 292 | ONLY_ACTIVE_ARCH = YES; 293 | SDKROOT = iphoneos; 294 | }; 295 | name = Debug; 296 | }; 297 | 764007CE1A2713AC00D10B9D /* Release */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ALWAYS_SEARCH_USER_PATHS = NO; 301 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 302 | CLANG_CXX_LIBRARY = "libc++"; 303 | CLANG_ENABLE_MODULES = YES; 304 | CLANG_ENABLE_OBJC_ARC = YES; 305 | CLANG_WARN_BOOL_CONVERSION = YES; 306 | CLANG_WARN_CONSTANT_CONVERSION = YES; 307 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 308 | CLANG_WARN_EMPTY_BODY = YES; 309 | CLANG_WARN_ENUM_CONVERSION = YES; 310 | CLANG_WARN_INT_CONVERSION = YES; 311 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 312 | CLANG_WARN_UNREACHABLE_CODE = YES; 313 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 314 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 315 | COPY_PHASE_STRIP = YES; 316 | ENABLE_NS_ASSERTIONS = NO; 317 | ENABLE_STRICT_OBJC_MSGSEND = YES; 318 | GCC_C_LANGUAGE_STANDARD = gnu99; 319 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 320 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 321 | GCC_WARN_UNDECLARED_SELECTOR = YES; 322 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 323 | GCC_WARN_UNUSED_FUNCTION = YES; 324 | GCC_WARN_UNUSED_VARIABLE = YES; 325 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 326 | MTL_ENABLE_DEBUG_INFO = NO; 327 | SDKROOT = iphoneos; 328 | VALIDATE_PRODUCT = YES; 329 | }; 330 | name = Release; 331 | }; 332 | 764007D01A2713AC00D10B9D /* Debug */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 336 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 337 | GCC_PREFIX_HEADER = ManualLanguageSelectionSample/PrefixHeader.pch; 338 | INFOPLIST_FILE = ManualLanguageSelectionSample/Info.plist; 339 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 340 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 341 | PRODUCT_NAME = "$(TARGET_NAME)"; 342 | }; 343 | name = Debug; 344 | }; 345 | 764007D11A2713AC00D10B9D /* Release */ = { 346 | isa = XCBuildConfiguration; 347 | buildSettings = { 348 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 349 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 350 | GCC_PREFIX_HEADER = ManualLanguageSelectionSample/PrefixHeader.pch; 351 | INFOPLIST_FILE = ManualLanguageSelectionSample/Info.plist; 352 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 353 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 354 | PRODUCT_NAME = "$(TARGET_NAME)"; 355 | }; 356 | name = Release; 357 | }; 358 | /* End XCBuildConfiguration section */ 359 | 360 | /* Begin XCConfigurationList section */ 361 | 764007A71A2713AC00D10B9D /* Build configuration list for PBXProject "ManualLanguageSelectionSample" */ = { 362 | isa = XCConfigurationList; 363 | buildConfigurations = ( 364 | 764007CD1A2713AC00D10B9D /* Debug */, 365 | 764007CE1A2713AC00D10B9D /* Release */, 366 | ); 367 | defaultConfigurationIsVisible = 0; 368 | defaultConfigurationName = Release; 369 | }; 370 | 764007CF1A2713AC00D10B9D /* Build configuration list for PBXNativeTarget "ManualLanguageSelectionSample" */ = { 371 | isa = XCConfigurationList; 372 | buildConfigurations = ( 373 | 764007D01A2713AC00D10B9D /* Debug */, 374 | 764007D11A2713AC00D10B9D /* Release */, 375 | ); 376 | defaultConfigurationIsVisible = 0; 377 | defaultConfigurationName = Release; 378 | }; 379 | /* End XCConfigurationList section */ 380 | }; 381 | rootObject = 764007A41A2713AC00D10B9D /* Project object */; 382 | } 383 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/3rdLib.bundle/Resources/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albertgh/ManualLanguageSelectionSample/5b4306c65fdd600db38b6b22581cfbc9780e9367/ManualLanguageSelectionSample/3rdLib.bundle/Resources/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/3rdLib.bundle/Resources/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | 2 | "a2a_d2d" = "尘归尘,\r\n 土归土。"; -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/3rdLib.bundle/Resources/zh-Hant.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | 2 | "a2a_d2d" = "塵歸塵,\r\n 土歸土。"; -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/3rdLib_Assets/en.lproj/FromTable.strings: -------------------------------------------------------------------------------- 1 | "Sample" = "Sample"; 2 | 3 | "Language" = "Language"; 4 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/3rdLib_Assets/zh-Hans.lproj/FromTable.strings: -------------------------------------------------------------------------------- 1 | "Sample" = "示例"; 2 | 3 | "Language" = "语言"; -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/3rdLib_Assets/zh-Hant.lproj/FromTable.strings: -------------------------------------------------------------------------------- 1 | "Sample" = "範例"; 2 | 3 | "Language" = "語言"; -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/ACLanguageUtil/ACLanguageUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACLanguageUtil.h 3 | // 4 | // Created by Albert Chu on 14/11/27. 5 | // 6 | 7 | #import 8 | 9 | 10 | #undef NSLocalizedString 11 | #define NSLocalizedString(key, comment) \ 12 | [[ACLanguageUtil sharedInstance] localizedStringForKey:(key)] 13 | 14 | #undef NSLocalizedStringFromTable 15 | #define NSLocalizedStringFromTable(key, tbl, comment) \ 16 | [[ACLanguageUtil sharedInstance] localizedStringForKey:(key) fromTable:(tbl)] 17 | 18 | #undef NSLocalizedStringFromTableInBundle 19 | #define NSLocalizedStringFromTableInBundle(key, tbl, bundle, comment) \ 20 | [[[ACLanguageUtil sharedInstance] manualLanguageBundle:(bundle)] localizedStringForKey:(key) value:@"" table:(tbl)] 21 | 22 | #undef NSLocalizedStringWithDefaultValue 23 | #define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) \ 24 | [[[ACLanguageUtil sharedInstance] manualLanguageBundle:(bundle)] localizedStringForKey:(key) value:(val) table:(tbl)] 25 | 26 | 27 | static NSString * const ACLanguageUtilLanguageIdentifier = @"ACLanguageUtilLanguageIdentifier"; 28 | 29 | @interface ACLanguageUtil : NSObject 30 | 31 | @property (nonatomic, retain) NSString *currentLanguage; 32 | 33 | + (ACLanguageUtil*)sharedInstance; 34 | 35 | - (void)setLanguage:(NSString *)language; 36 | 37 | 38 | #pragma mark - For Macros 39 | 40 | - (NSString *)localizedStringForKey:(NSString *)key; 41 | - (NSString *)localizedStringForKey:(NSString *)key fromTable:(NSString *)table; 42 | - (NSBundle *)manualLanguageBundle:(NSBundle *)bundle; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/ACLanguageUtil/ACLanguageUtil.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACLanguageUtil.m 3 | // 4 | // Created by Albert Chu on 14/11/27. 5 | // 6 | 7 | #import "ACLanguageUtil.h" 8 | 9 | 10 | static NSString * const ACLanguageUtilDefaultLanguage = @"en"; 11 | 12 | static NSString * const ACLanguageUtilSupportLanguages = @"en, zh-Hans, zh-Hant"; 13 | 14 | 15 | @implementation ACLanguageUtil 16 | 17 | #pragma mark - Singleton 18 | 19 | + (ACLanguageUtil*)sharedInstance { 20 | static ACLanguageUtil *_sharedInstance = nil; 21 | static dispatch_once_t onceToken; 22 | dispatch_once(&onceToken, ^{ 23 | _sharedInstance = [[ACLanguageUtil alloc] init]; 24 | }); 25 | return _sharedInstance; 26 | } 27 | 28 | #pragma mark - Public 29 | 30 | - (void)setLanguage:(NSString *)language { 31 | if ([self doSupportTheNewLanguage:language]) { 32 | self.currentLanguage = language; 33 | [[NSUserDefaults standardUserDefaults] setObject:language forKey:ACLanguageUtilLanguageIdentifier]; 34 | [[NSUserDefaults standardUserDefaults] synchronize]; 35 | } 36 | } 37 | 38 | #pragma mark - For Macros 39 | 40 | - (NSString *)localizedStringForKey:(NSString *)key { 41 | return [[self manualLanguageBundle:[NSBundle mainBundle]] localizedStringForKey:(key) value:@"" table:nil]; 42 | } 43 | 44 | - (NSString *)localizedStringForKey:(NSString *)key fromTable:(NSString *)table { 45 | return [[self manualLanguageBundle:[NSBundle mainBundle]] localizedStringForKey:(key) value:@"" table:table]; 46 | } 47 | 48 | - (NSBundle *)manualLanguageBundle:(NSBundle *)bundle { 49 | NSBundle *newBundle = bundle; 50 | 51 | NSString *currentLanguageString = [[NSUserDefaults standardUserDefaults] objectForKey:ACLanguageUtilLanguageIdentifier]; 52 | 53 | // path to this languages bundle 54 | NSString *path = [bundle pathForResource:currentLanguageString ofType:@"lproj" ]; 55 | 56 | if (path) { 57 | newBundle = [NSBundle bundleWithPath:path]; 58 | } 59 | 60 | return newBundle; 61 | } 62 | 63 | #pragma mark - Init 64 | 65 | - (id)init { 66 | self = [super init]; 67 | if (self) { 68 | NSString *currentLanguageString = 69 | [[NSUserDefaults standardUserDefaults] objectForKey:ACLanguageUtilLanguageIdentifier]; 70 | if (currentLanguageString.length > 0) { 71 | self.currentLanguage = currentLanguageString; 72 | } 73 | else { 74 | // first init 75 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 76 | NSArray *languages = [defaults objectForKey:@"AppleLanguages"]; 77 | NSString *currentLanguage = languages[0]; 78 | 79 | // use english default 80 | NSString *newLanguage = 81 | [ACLanguageUtilDefaultLanguage stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 82 | if ([self doSupportTheNewLanguage:currentLanguage]) { 83 | newLanguage = currentLanguage; 84 | } 85 | 86 | [self setLanguage:newLanguage]; 87 | } 88 | } 89 | return self; 90 | } 91 | 92 | #pragma mark - Private 93 | 94 | - (BOOL)doSupportTheNewLanguage:(NSString *)newLanguage { 95 | NSArray *supportLanguagesArray = [ACLanguageUtilSupportLanguages componentsSeparatedByString:@","]; 96 | for (NSString *language in supportLanguagesArray) { 97 | NSString *cleanLanguage = [language stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 98 | if ([newLanguage isEqualToString:cleanLanguage]) { 99 | return YES; 100 | } 101 | } 102 | return NO; 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ManualLanguageSelectionSample 4 | // 5 | // Created by Albert Chu on 14/11/27. 6 | // Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | - (void)reDrawAllUIForLanguage:(NSString *)language; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ManualLanguageSelectionSample 4 | // 5 | // Created by Albert Chu on 14/11/27. 6 | // Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | #import "ViewController.h" 12 | 13 | 14 | @interface AppDelegate () 15 | 16 | @end 17 | 18 | 19 | @implementation AppDelegate 20 | 21 | 22 | #pragma mark - Language Public 23 | 24 | - (void)reDrawAllUIForLanguage:(NSString *)language { 25 | [[ACLanguageUtil sharedInstance] setLanguage:language]; 26 | 27 | self.window.rootViewController = nil; 28 | 29 | [self setRootVC]; 30 | } 31 | 32 | 33 | #pragma mark - Private 34 | 35 | - (void)setRootVC { 36 | ViewController *viewController = [[ViewController alloc] initWithNibName:nil bundle:nil]; 37 | self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:viewController]; 38 | } 39 | 40 | 41 | #pragma mark - Application 42 | 43 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 44 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 45 | // Override point for customization after application launch. 46 | 47 | [self setRootVC]; 48 | 49 | 50 | self.window.backgroundColor = [UIColor whiteColor]; 51 | [self.window makeKeyAndVisible]; 52 | 53 | return YES; 54 | } 55 | 56 | - (void)applicationWillResignActive:(UIApplication *)application { 57 | // 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. 58 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 59 | } 60 | 61 | - (void)applicationDidEnterBackground:(UIApplication *)application { 62 | // 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. 63 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 64 | } 65 | 66 | - (void)applicationWillEnterForeground:(UIApplication *)application { 67 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 68 | } 69 | 70 | - (void)applicationDidBecomeActive:(UIApplication *)application { 71 | // 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. 72 | } 73 | 74 | - (void)applicationWillTerminate:(UIApplication *)application { 75 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "filename" : "Default@2x.png", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "extent" : "full-screen", 13 | "idiom" : "iphone", 14 | "subtype" : "retina4", 15 | "filename" : "Default-568h@2x.png", 16 | "minimum-system-version" : "7.0", 17 | "orientation" : "portrait", 18 | "scale" : "2x" 19 | } 20 | ], 21 | "info" : { 22 | "version" : 1, 23 | "author" : "xcode" 24 | } 25 | } -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albertgh/ManualLanguageSelectionSample/5b4306c65fdd600db38b6b22581cfbc9780e9367/ManualLanguageSelectionSample/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/Images.xcassets/LaunchImage.launchimage/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albertgh/ManualLanguageSelectionSample/5b4306c65fdd600db38b6b22581cfbc9780e9367/ManualLanguageSelectionSample/Images.xcassets/LaunchImage.launchimage/Default@2x.png -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.test.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/PrefixHeader.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PrefixHeader.pch 3 | // ManualLanguageSelectionSample 4 | // 5 | // Created by Albert Chu on 14/11/27. 6 | // Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | // 8 | 9 | #ifndef ManualLanguageSelectionSample_PrefixHeader_pch 10 | #define ManualLanguageSelectionSample_PrefixHeader_pch 11 | 12 | // Include any system framework and library headers here that should be included in all compilation units. 13 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. 14 | 15 | 16 | #import "ACLanguageUtil.h" 17 | 18 | 19 | #import "AppDelegate.h" 20 | 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/SettingsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SettingsViewController.h 3 | // ManualLanguageSelectionSample 4 | // 5 | // Created by Albert Chu on 14/11/27. 6 | // Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SettingsViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/SettingsViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SettingsViewController.m 3 | // ManualLanguageSelectionSample 4 | // 5 | // Created by Albert Chu on 14/11/27. 6 | // Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | // 8 | 9 | #import "SettingsViewController.h" 10 | 11 | 12 | @interface SettingsViewController () 13 | 14 | @property (nonatomic, retain) UITableView *tableView; 15 | 16 | @property (nonatomic, retain) NSString *switchToLanguageCodeString; 17 | 18 | @property (nonatomic, assign) NSInteger selectedRow; 19 | 20 | @end 21 | 22 | 23 | @implementation SettingsViewController 24 | 25 | 26 | #pragma mark - Action 27 | 28 | - (void)switchButtonTapped:(UIBarButtonItem *)sender { 29 | if (![self.switchToLanguageCodeString isEqualToString:[ACLanguageUtil sharedInstance].currentLanguage]) { 30 | AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; 31 | 32 | [appDelegate reDrawAllUIForLanguage:self.switchToLanguageCodeString]; 33 | } 34 | else { 35 | [self.navigationController popViewControllerAnimated:YES]; 36 | } 37 | } 38 | 39 | 40 | #pragma mark - 41 | 42 | - (void)viewDidLoad { 43 | [super viewDidLoad]; 44 | // Do any additional setup after loading the view. 45 | 46 | self.title = NSLocalizedString(@"Settings", nil); 47 | 48 | [self createTableView]; 49 | } 50 | 51 | - (void)createTableView { 52 | self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds 53 | style:UITableViewStyleGrouped]; 54 | 55 | self.tableView.dataSource = self; 56 | self.tableView.delegate = self; 57 | 58 | [self.view addSubview:self.tableView]; 59 | } 60 | 61 | - (void)didReceiveMemoryWarning { 62 | [super didReceiveMemoryWarning]; 63 | // Dispose of any resources that can be recreated. 64 | } 65 | 66 | #pragma mark - UITableViewDataSource 67 | 68 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 69 | return 1; 70 | } 71 | 72 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 73 | return 3; 74 | } 75 | 76 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 77 | NSString *DoNotReuseIdentifier = 78 | [NSString 79 | stringWithFormat:@"LanguageCellIdentifier__%ld__%ld", 80 | (long)indexPath.section, 81 | (long)indexPath.row]; 82 | 83 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DoNotReuseIdentifier]; 84 | 85 | if ( nil == cell ) { 86 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:DoNotReuseIdentifier]; 87 | } 88 | 89 | // config cell 90 | NSString *languageString = @""; 91 | 92 | NSString *languageCodeString = @""; 93 | 94 | switch (indexPath.row) { 95 | case 0: { 96 | languageString = @"简体中文"; 97 | languageCodeString = @"zh-Hans"; 98 | } 99 | break; 100 | case 1: { 101 | languageString = @"繁體中文"; 102 | languageCodeString = @"zh-Hant"; 103 | } 104 | break; 105 | case 2: { 106 | languageString = @"English"; 107 | languageCodeString = @"en"; 108 | } 109 | break; 110 | 111 | default: 112 | break; 113 | } 114 | 115 | cell.textLabel.text = languageString; 116 | 117 | NSString *currentLanguageString = [[NSUserDefaults standardUserDefaults] objectForKey:ACLanguageUtilLanguageIdentifier]; 118 | if ([languageCodeString isEqualToString:currentLanguageString]) { 119 | cell.accessoryType = UITableViewCellAccessoryCheckmark; 120 | self.selectedRow = indexPath.row; 121 | } else { 122 | cell.accessoryType = UITableViewCellAccessoryNone; 123 | } 124 | 125 | return cell; 126 | } 127 | 128 | #pragma mark - UITableViewDelegate 129 | 130 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 131 | return 44.0f; 132 | } 133 | 134 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 135 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 136 | 137 | self.navigationItem.rightBarButtonItem = 138 | [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done", nil) 139 | style:UIBarButtonItemStylePlain 140 | target:self 141 | action:@selector(switchButtonTapped:)]; 142 | 143 | 144 | UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:self.selectedRow inSection:0]]; 145 | selectedCell.accessoryType = UITableViewCellAccessoryNone; 146 | 147 | UITableViewCell *newSelectedCell = [tableView cellForRowAtIndexPath:indexPath]; 148 | self.selectedRow = indexPath.row; 149 | 150 | switch (indexPath.row) { 151 | case 0: { 152 | newSelectedCell.accessoryType = UITableViewCellAccessoryCheckmark; 153 | self.switchToLanguageCodeString = @"zh-Hans"; 154 | } 155 | break; 156 | case 1: { 157 | newSelectedCell.accessoryType = UITableViewCellAccessoryCheckmark; 158 | self.switchToLanguageCodeString = @"zh-Hant"; 159 | } 160 | break; 161 | case 2: { 162 | newSelectedCell.accessoryType = UITableViewCellAccessoryCheckmark; 163 | self.switchToLanguageCodeString = @"en"; 164 | } 165 | break; 166 | 167 | default: 168 | break; 169 | } 170 | 171 | } 172 | 173 | 174 | @end 175 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ManualLanguageSelectionSample 4 | // 5 | // Created by Albert Chu on 14/11/27. 6 | // Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ManualLanguageSelectionSample 4 | // 5 | // Created by Albert Chu on 14/11/27. 6 | // Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | #import "SettingsViewController.h" 12 | 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | 19 | @implementation ViewController 20 | 21 | #pragma mark - Action 22 | 23 | - (void)languageButtonTapped:(UIBarButtonItem *)sender { 24 | SettingsViewController *userPageVC = [[SettingsViewController alloc] init]; 25 | [self.navigationController pushViewController:userPageVC animated:YES]; 26 | } 27 | 28 | #pragma mark - 29 | 30 | - (void)viewDidLoad { 31 | [super viewDidLoad]; 32 | // Do any additional setup after loading the view, typically from a nib. 33 | 34 | self.view.backgroundColor = [UIColor whiteColor]; 35 | 36 | self.title = NSLocalizedStringFromTable(@"Sample", @"FromTable", nil); 37 | 38 | NSString *rightBarButtomTitle = 39 | NSLocalizedStringFromTableInBundle(@"Language", 40 | @"FromTable", 41 | [NSBundle mainBundle], 42 | nil); 43 | 44 | self.navigationItem.rightBarButtonItem = 45 | [[UIBarButtonItem alloc] initWithTitle:rightBarButtomTitle 46 | style:UIBarButtonItemStylePlain 47 | target:self 48 | action:@selector(languageButtonTapped:)]; 49 | 50 | 51 | UILabel *label = [[UILabel alloc] init]; 52 | label.frame = self.view.bounds; 53 | 54 | label.backgroundColor = [UIColor whiteColor]; 55 | label.textColor = [UIColor blackColor]; 56 | 57 | label.font = [UIFont boldSystemFontOfSize:40.0f]; 58 | label.textAlignment = NSTextAlignmentCenter; 59 | label.numberOfLines = 2; 60 | label.text = 61 | NSLocalizedStringWithDefaultValue(@"a2a_d2d", 62 | nil, 63 | [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"3rdLib" ofType:@"bundle"]], 64 | @"", 65 | nil); 66 | 67 | [self.view addSubview:label]; 68 | } 69 | 70 | - (void)didReceiveMemoryWarning { 71 | [super didReceiveMemoryWarning]; 72 | // Dispose of any resources that can be recreated. 73 | } 74 | 75 | 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* 2 | InfoPlist.strings 3 | ManualLanguageSelectionSample 4 | 5 | Created by Albert Chu on 14/11/27. 6 | Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | */ 8 | 9 | 10 | CFBundleDisplayName = "LanguageSelection"; 11 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/en.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | ManualLanguageSelectionSample 4 | 5 | Created by Albert Chu on 14/11/27. 6 | Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | */ 8 | 9 | 10 | 11 | 12 | "Settings" = "Settings"; 13 | 14 | "Done" = "Done"; 15 | 16 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ManualLanguageSelectionSample 4 | // 5 | // Created by Albert Chu on 14/11/27. 6 | // Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/zh-Hans.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* 2 | InfoPlist.strings 3 | ManualLanguageSelectionSample 4 | 5 | Created by Albert Chu on 14/11/27. 6 | Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | */ 8 | 9 | 10 | CFBundleDisplayName = "语言选择"; 11 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/zh-Hans.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | ManualLanguageSelectionSample 4 | 5 | Created by Albert Chu on 14/11/27. 6 | Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | */ 8 | 9 | 10 | 11 | 12 | "Settings" = "设置"; 13 | 14 | "Done" = "完成"; 15 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/zh-Hant.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* 2 | InfoPlist.strings 3 | ManualLanguageSelectionSample 4 | 5 | Created by Albert Chu on 14/11/27. 6 | Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | */ 8 | 9 | 10 | CFBundleDisplayName = "語言選擇"; 11 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/zh-Hant.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ManualLanguageSelectionSample/zh-Hant.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | ManualLanguageSelectionSample 4 | 5 | Created by Albert Chu on 14/11/27. 6 | Copyright (c) 2014年 Albert Chu. All rights reserved. 7 | */ 8 | 9 | 10 | 11 | 12 | "Settings" = "設定"; 13 | 14 | "Done" = "完成"; 15 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## ACLanguageUtil 2 | 3 | Manual Language Selection Sample 4 | 5 | By redefining all four `NSLocalizedString` `NSLocalizedStringFromTable` `NSLocalizedStringFromTableInBundle` `NSLocalizedStringWithDefaultValue` macros, 6 | 7 | so that you can make your project able to select language manually 8 | 9 | without change any other code even 3rd party code. 10 | 11 | 12 | ## Installing 13 | 14 | 15 | Drag `ACLanguageUtil` folder into your project. 16 | 17 | 18 | ```objective-c 19 | #import "ACLanguageUtil.h" in your PrefixHeader.pch 20 | ``` 21 | 22 | 23 | ## Usage 24 | 25 | * Default Language & Support Languages 26 | 27 | You should replace the value of `ACLanguageUtilSupportLanguages` to your own language list in `ACLanguageUtil.m` at line 12. 28 | 29 | In case of other languages that your project doesn't support will be set to some default language. 30 | 31 | And the default language is `ACLanguageUtilDefaultLanguage` at line 10, you may replace the value of it too. 32 | 33 | ```objc 34 | static NSString * const ACLanguageUtilDefaultLanguage = @"en"; 35 | 36 | static NSString * const ACLanguageUtilSupportLanguages = @"en,zh-Hans,zh-Hant"; 37 | ``` 38 | 39 | * Set Language 40 | 41 | ```objc 42 | NSString *newLanguage = @"zh-Hans"; 43 | 44 | [[ACLanguageUtil sharedInstance] setLanguage:newLanguage]; 45 | ``` 46 | 47 | After that you need to recreate the whole UI to see the change. 48 | 49 | Like reset `self.window.rootViewController` in your `AppDelegate.m`. 50 | 51 | 52 | 53 | #### Requirements 54 | 55 | * ARC 56 | 57 | 58 | 59 | #### License 60 | 61 | * WTFPL 62 | 63 | 64 | --------------------------------------------------------------------------------