{"id":18839758,"url":"https://github.com/maximbilan/language-manager-ios","last_synced_at":"2026-03-15T07:05:40.459Z","repository":{"id":24977337,"uuid":"28395718","full_name":"maximbilan/Language-Manager-iOS","owner":"maximbilan","description":"Language Manager iOS","archived":false,"fork":false,"pushed_at":"2018-09-22T07:23:27.000Z","size":167,"stargazers_count":230,"open_issues_count":10,"forks_count":34,"subscribers_count":11,"default_branch":"master","last_synced_at":"2026-01-14T05:52:29.519Z","etag":null,"topics":["apple","ios","language","languages","localization","objective-c","tutorial"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximbilan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-23T11:59:24.000Z","updated_at":"2026-01-07T22:33:47.000Z","dependencies_parsed_at":"2022-08-22T22:41:06.886Z","dependency_job_id":null,"html_url":"https://github.com/maximbilan/Language-Manager-iOS","commit_stats":null,"previous_names":["maximbilan/ios_language_manager"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maximbilan/Language-Manager-iOS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FLanguage-Manager-iOS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FLanguage-Manager-iOS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FLanguage-Manager-iOS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FLanguage-Manager-iOS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximbilan","download_url":"https://codeload.github.com/maximbilan/Language-Manager-iOS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2FLanguage-Manager-iOS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30537152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-15T06:53:40.532Z","status":"ssl_error","status_checked_at":"2026-03-15T06:51:47.131Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple","ios","language","languages","localization","objective-c","tutorial"],"created_at":"2024-11-08T02:43:59.238Z","updated_at":"2026-03-15T07:05:40.445Z","avatar_url":"https://github.com/maximbilan.png","language":"Objective-C","readme":"How to change localization internally in your iOS application\n============\n\nUnfortunately, there’s no official way provided by \u003ci\u003eApple\u003c/i\u003e for this purpose. Let’s look at two methods for solving this problem.\n\n## Method #1\n\n\u003ci\u003eApple\u003c/i\u003e provides a way to specify an application-specific language, by updating the \u003ci\u003e“AppleLanguages”\u003c/i\u003e key in \u003cb\u003eNSUserDefaults\u003c/b\u003e. For example:\n\n\u003cpre\u003e\n[[NSUserDefaults standardUserDefaults] setObject:@\"fr\" forKey:@\"AppleLanguages\"];\n[[NSUserDefaults standardUserDefaults] synchronize];\n\u003c/pre\u003e\n\nFor working this method, you’ll have to set it before \u003cb\u003eUIKit\u003c/b\u003e initialized.\n\n\u003cpre\u003e\n#import \u0026#60;UIKit/UIKit.h\u0026#62;\n#import \"AppDelegate.h\"\n#import \"LanguageManager.h\"\n\nint main(int argc, char * argv[]) {\n    @autoreleasepool {\n        [[NSUserDefaults standardUserDefaults] setObject:@\"fr\" forKey:@\"AppleLanguages\"];\n        [[NSUserDefaults standardUserDefaults] synchronize];\n        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));\n    }\n}\n\n\u003c/pre\u003e\n\nThe problem of this method is that the app has to be relaunched to take effect.\n\n## Method #2\n\nThe solution is to swap the \u003cb\u003emainBundle\u003c/b\u003e of our application as soon as the user changes their language preferences inside the app.\n\nSee the category for \u003cb\u003eNSBundle\u003c/b\u003e.\n\nHeader:\n\n\u003cpre\u003e\n#import \u0026#60;Foundation/Foundation.h\u0026#62;\n\n@interface NSBundle (Language)\n\n+ (void)setLanguage:(NSString *)language;\n\n@end\n\u003c/pre\u003e\n\nImplementation:\n\n\u003cpre\u003e\n#import \"NSBundle+Language.h\"\n#import \u0026#60;objc/runtime.h\u0026#62;\n\nstatic const char kBundleKey = 0;\n\n@interface BundleEx : NSBundle\n\n@end\n\n@implementation BundleEx\n\n- (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName\n{\n    NSBundle *bundle = objc_getAssociatedObject(self, \u0026kBundleKey);\n    if (bundle) {\n        return [bundle localizedStringForKey:key value:value table:tableName];\n    }\n    else {\n        return [super localizedStringForKey:key value:value table:tableName];\n    }\n}\n\n@end\n\n@implementation NSBundle (Language)\n\n+ (void)setLanguage:(NSString *)language\n{\n    static dispatch_once_t onceToken;\n    dispatch_once(\u0026onceToken, ^{\n        object_setClass([NSBundle mainBundle],[BundleEx class]);\n    });\n    id value = language ? [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:language ofType:@\"lproj\"]] : nil;\n    objc_setAssociatedObject([NSBundle mainBundle], \u0026kBundleKey, value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);\n}\n\n@end\n\u003c/pre\u003e\n\nIn this method, a problem that may arise is updating elements on active screens. You can reload your \u003cb\u003erootViewController\u003c/b\u003e from our application delegate, will always work reliably.\n\n\u003cpre\u003e\n- (void)reloadRootViewController\n{\n    AppDelegate *delegate = [UIApplication sharedApplication].delegate;\n    NSString *storyboardName = @\"Main\";\n    UIStoryboard *storybaord = [UIStoryboard storyboardWithName:storyboardName bundle:nil];\n    delegate.window.rootViewController = [storybaord instantiateInitialViewController];\n}\n\u003c/pre\u003e\n\nAll code you can see in this repository. With a simple example.\n\n![alt tag](https://raw.github.com/maximbilan/ios_language_manager/master/img/1.png)\n\nPlease, use for free and like it ☺.\n\n\u003cb\u003eNote:\u003c/b\u003e In the example project by default the app uses \u003ci\u003emethod #2\u003c/i\u003e. You can disable this. Just comment define \u003cb\u003eUSE_ON_FLY_LOCALIZATION\u003c/b\u003e.\n\nMore details on the blog \u003ca href=\"http://www.factorialcomplexity.com/blog/2015/01/28/how-to-change-localization-internally-in-your-ios-application.html\"\u003ehere\u003c/a\u003e.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximbilan%2Flanguage-manager-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximbilan%2Flanguage-manager-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximbilan%2Flanguage-manager-ios/lists"}