Swiftpack.co - HongliYu/DPLocalized as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by HongliYu.
HongliYu/DPLocalized 0.1.0
Change languages inside the app, no need to wait the screen to reboot any more
⭐️ 11
🕓 3 years ago
.package(url: "https://github.com/HongliYu/DPLocalized.git", from: "0.1.0")

DPLocalized

Change languages inside the app, no need to wait the screen to reboot any more.

Cocoapods Pod License Swift-5.3 Carthage Compatible

alt text

Usage

First of all, the app needs to support multi-language, or another professional word "Localizations" in Xcode project.

Add notifications, to reload data of current page, or previous pages in the memory

  func addNotifications() {
    NotificationCenter
      .default
      .addObserver(self, selector: #selector(languageDidChange(_:)),
                   name: DPNotification.languageDidChange, object: nil)
  }

  deinit {
    NotificationCenter
      .default
      .removeObserver(self, name: DPNotification.languageDidChange, object: nil)
  }

  @objc func languageDidChange(_ notification: Notification) {
    tableView.reloadData()
  }

Then add this line to the entry, it will open the language setting menu

  DPLanguageManager.shared.popup(self)

And for the strings need to be localized, there is a syntax sugar in extension

  "puppy".localized

And that's all. Thanks

GitHub

link
Stars: 11
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics