💡 Shared instance 🔗
To start using the Swift SDK, access singleton instance by:
Localazy.shared
⌨️ Basic usage 🔗
Use String extension to get localized String:
"Hello".localazyLocalized
Use Text (SwiftUI) constructor to get localized String:
Text(localazyKey: "Hello")
Enable method swizzling (Beta) to enable Localazy functionality on system methods:
Bundle.swizzleLocalizationWithLocalazy()
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 servergetString
: Get translated StringgetArrayList
: Translated ListgetPlural
: Translated String with pluralssetEnabled
: If Localazy is disabled, translations are obtained by the default system mechanism.getProjectUrl
: Project URLgetCurrentLocale
: Current system localegetCurrentLocalazyLocale
: Current Localazy localeisFullyTranslated
: To get information about whether the current internally resolved locale is fully translatedgetLocales
: To list all locales known to LocalazyisStatsEnabled
: Statistics are enabledsetStatsEnabled
: 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