Install Localize-Swift via CocoaPods
masterAdd the following to your Podfile to install Localize-Swift using CocoaPods.
source 'https://github.com/CocoaPods/Specs.git'
pod 'Localize-Swift', '~> 3.2'repository·master·Indexed 25 days ago
https://github.com/marmelroy/localize-swiftA Swift framework for iOS applications that improves i18n and localization. It provides a .localized() method for string translation, enables in-app language switching via the Localize class without changing device settings, and includes a genstrings.swift script for string collection.
Add the following to your Podfile to install Localize-Swift using CocoaPods.
source 'https://github.com/CocoaPods/Specs.git'
pod 'Localize-Swift', '~> 3.2'Localize-Swift includes a custom genstrings.swift script that recognizes the .localized() syntax.
genstrings.swift into your project's root folder../genstrings.swiftLocalizable.strings file.Note: You can exclude specific directories or files by editing the script directly.
./genstrings.swiftFirst, ensure Carthage is installed via Homebrew. Then, add the repository to your Cartfile.
$ brew update
$ brew install carthagegithub "marmelroy/Localize-Swift"pod update.pod updateSwift Package Manager is the preferred method for installing Localize-Swift.
Using Xcode UI:
https://github.com/marmelroy/Localize-Swift.git.3.2.0.Localize-Swift library to your app target.Using Package.swift:
Add the dependency directly to your Package.swift file.
dependencies: [
.package(url: "https://github.com/marmelroy/Localize-Swift.git", .upToNextMajor(from: "3.2.0"))
]After importing the library, you can use the .localized() method on any String object to retrieve its translated value from your Localizable.strings file.
import Localize_Swift
textLabel.text = "Hello World".localized()Use the Localize class to query available languages, change the current language, or reset to the system default.
Localize.availableLanguages(): Returns an array of available localizations.Localize.setCurrentLanguage("code"): Changes the app's language to the specified code (e.g., "fr").Localize.resetCurrentLanguageToDefault(): Resets the language to the device's default language.To update your UI when the user changes the app language, observe the LCLLanguageChangeNotification via NotificationCenter.
NotificationCenter.default.addObserver(
self,
selector: #selector(setText),
name: NSNotification.Name(LCLLanguageChangeNotification),
object: nil
)