ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - marmelroy/Localize-Swift: Swift friendly localization and i18n with in-app language switching
Swift friendly localization and i18n with in-app language switching - marmelroy/Localize-Swift
Visit Site

GitHub - marmelroy/Localize-Swift: Swift friendly localization and i18n with in-app language switching

GitHub - marmelroy/Localize-Swift: Swift friendly localization and i18n with in-app language switching

Platform Version Build Status Carthage compatible

Localize-Swift

Localize-Swift is a simple framework that improves i18n and localization in Swift iOS apps - providing cleaner syntax and in-app language switching.

Features

  • Keep the Localizable.strings file your app already uses.
  • Allow your users to change the app's language without changing their device language.
  • Use .localized() instead of NSLocalizedString(key,comment) - a more Swifty syntax.
  • Generate your strings with a new genstrings swift/python script that recognises .localized().

Usage

Import Localize at the top of each Swift file that will contain localized text.

If CocoaPods -

import Localize_Swift

Add .localized() following any String object you want translated:

textLabel.text = "Hello World".localized()

To get an array of available localizations:

Localize.availableLanguages()

To change the current language:

Localize.setCurrentLanguage("fr")

To update the UI in the view controller where a language change can take place, observe LCLLanguageChangeNotification:

NotificationCenter.default.addObserver(self, selector: #selector(setText), name: NSNotification.Name(LCLLanguageChangeNotification), object: nil)

To reset back to the default app language:

Localize.resetCurrentLanguageToDefault()

genstrings

To support this new i18n syntax, Localize-Swift includes custom genstrings swift script.

Copy the genstrings.swift file into your project's root folder and run with

./genstrings.swift

This will print the collected strings in the terminal. Select and copy to your default Localizable.strings.

The script includes the ability to specify excluded directories and files (by editing the script).

[Preferrred] Setting up with Swift Package Manager

The Swift Package Manager is now the preferred tool for distributing Localize-Swift.

From Xcode 11+ :

  1. Select File > Swift Packages > Add Package Dependency. Enter https://github.com/marmelroy/Localize-Swift.git in the "Choose Package Repository" dialog.
  2. In the next page, specify the version resolving rule as "Up to Next Major" with "3.2.0".
  3. After Xcode checked out the source and resolving the version, you can choose the "Localize-Swift" library and add it to your app target.

For more info, read Adding Package Dependencies to Your App from Apple.

Alternatively, you can also add Localize-Swift to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/marmelroy/Localize-Swift.git", .upToNextMajor(from: "3.2.0"))
]

Setting up with Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Localize-Swift into your Xcode project using Carthage, specify it in your Cartfile:

github "marmelroy/Localize-Swift"

Setting up with CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
pod 'Localize-Swift', '~> 3.2'

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory