TIP: Check out the ios-demo example on Github.

💡 Shared instance #️⃣

To start using the Swift SDK, access singleton instance by:


⌨️ Basic usage #️⃣

Use String extension to get localized String:


Use Text (SwiftUI) constructor to get localized String:

Text(localazyKey: "Hello")

Enable method swizzling (Beta) to enable Localazy functionality on system methods:

NSLocalizedString("Hello", comment: "Hello")

NOTE: When using swizzling it’s important to understand that it will replace all calls to NSLocalizedString with the custom logic provided by Localazy SDK and will only fallback to system call if there is no Localazy based translation. For this reason, there may be more logs added to statistics about the missing and used keys.

🔌 Public API #️⃣

  • forceReload: Invalidate internal caches and reload data from server
  • getString: Get translated String
  • getArrayList: Translated List
  • getPlural: Translated String with plurals
  • setEnabled: If Localazy is disabled, translations are obtained by the default system mechanism.
  • getProjectUrl: Project URL
  • getCurrentLocale: Current system locale
  • getCurrentLocalazyLocale: Current Localazy locale
  • isFullyTranslated: To get information about whether the current internally resolved locale is fully translated
  • getLocales: To list all locales known to Localazy
  • isStatsEnabled: Statistics are enabled
  • setStatsEnabled: Enable / disable statistics

🔔 Notifications #️⃣

We provide several types of notifications which can be produced by the SDK. These notifications are published as a NSNotification objects and can be observed by the NotificationCenter. Some of these notifications can contain a userInfo dictionary to provide more context for you.

The key is not translated into the current language:

  • localazyMissingTextFound
  • userInfo dictionary:
	"id": LocalazyID, 
	"locale": LocalazyLocale, 
	"key": String

The library has started the update process:

  • localazyStringsUpdateStarted

The library has updated the translation data:

  • localazyStringsUpdateFinished

The data update process failed with an error:

  • localazyStringsUpdateFailed
  • userInfo dictionary:
	“error”: Localazy.LocalazyError

The library contacted the update server and found out that there is no change:

  • localazyStringsUpdateNotNecessary

The library has loaded data – this is called after initial load, strings update, etc:

  • localazyStringsLoaded

Resources #️⃣