https://github.com/janlionly/swiftyinapplocalization
Support for switching the language at run time.
https://github.com/janlionly/swiftyinapplocalization
changelanguage in-app l10n l10n-runtime language localization localization-runtime objective-c runtime swift
Last synced: about 1 month ago
JSON representation
Support for switching the language at run time.
- Host: GitHub
- URL: https://github.com/janlionly/swiftyinapplocalization
- Owner: janlionly
- License: mit
- Created: 2020-07-21T05:12:48.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-31T19:21:10.000Z (almost 5 years ago)
- Last Synced: 2025-06-17T11:17:19.969Z (about 1 year ago)
- Topics: changelanguage, in-app, l10n, l10n-runtime, language, localization, localization-runtime, objective-c, runtime, swift
- Language: Objective-C
- Homepage: https://github.com/janlionly/InAppLocalization
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftyInAppLocalization
[](https://cocoapods.org/pods/SwiftyInAppLocalization)
[](https://github.com/Carthage/Carthage)
[](https://github.com/janlionly/SwiftyInAppLocalization/blob/master/LICENSE)
[](https://github.com/janlionly/SwiftyInAppLocalization)

## Description
**SwiftyInAppLocalization** which supports to switch the language at run time. Compatible with both Swift and Objective-C.
## Installation
### CocoaPods
```swift
pod 'SwiftyInAppLocalization'
```
### Carthage
```swift
github "janlionly/SwiftyInAppLocalization"
```
### Swift Package Manager
- iOS: Open Xcode, File->Swift Packages, search input **https://github.com/janlionly/SwiftyInAppLocalization.git**, and then select Version Up to Next Major **1.0.0** < .
- Or add dependencies in your `Package.swift`:
```swift
.package(url: "https://github.com/janlionly/SwiftyInAppLocalization.git", .upToNextMajor(from: "1.0.0")),
```
## Usage
Before do this, Firstly, you should set your **localizations** in your Xcode project; Secondly, add **Localizable.strings** and localize it.
```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Set you default language after launching
SwiftyInAppLocalization.shared().defaultLanguageCode = "en"
return true
}
// somewhere you want to change language call "setCurrentLanguageCode", and must reload your view controller.
let ctrl = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()!
SwiftyInAppLocalization.shared().setCurrentLanguageCode("ja", reload: ctrl) { (view) in
view.alpha = 0
}
// or set the parameter of 'reload' to nil, then you do reload your view controller by yourself
SwiftyInAppLocalization.shared().setCurrentLanguageCode(language.languageCode, reload: nil, animation: nil)
// reload your view controller here
// ...
```
## Requirements
- iOS 8.0+
- Swift 4.2 to 5.2
## Author
Visit my github: [janlionly](https://github.com/janlionly)
Contact with me by email: janlionly@gmail.com
## Contribute
I would love you to contribute to **SwiftyInAppLocalization**
## License
**SwiftyInAppLocalization** is available under the MIT license. See the [LICENSE](https://github.com/janlionly/SwiftyInAppLocalization/blob/master/LICENSE) file for more info.