• Stars
    star
    137
  • Rank 265,115 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Localize UI Components in a simple and declarative way

Localizable: Localize UI Components in a simple and declarative way

Installation

Version License Platform

Pods

pod 'LocalizedSwift'

Swift package manager

From Xcode, select File β†’ Swift Packages β†’ Add Package Dependency β†’ Select your project β†’ Search LocalizedSwift

Usage

It is possible to localize a class that conforms Localizable adding @Localized("YouKey") before the component declaration. UILabel, UIButton, UITextField and UIImageView already conform Localizable.

// In the following example the string for the key "Label.Title" will be searched in the file "Localizable.strings".
@Localized("Label.Title")
@IBOutlet private var label: UILabel!

If the strings are defined in a file different fromΒ Localizable.strings set the parameter stringsFileName with the name of the file.

// In the following example the string for the key "Label.Title" will be searched in the file "AFile.strings".
@Localized("Label.Title", stringsFileName: "AFile") 
@IBOutlet private var label: UILabel!

If the .strings file is in a bundle other than .main set the parameter bundle with the bundle where the file is embedded.

// In the following example the string for the key "Label.Title" will be searched in the file "AFile.strings" in the bundle `.anotherBundle`.
@Localized("Label.Title", stringsFileName: "AFile", bundle: .anotherBundle) 
@IBOutlet private var label: UILabel!

Set strings for state

It is possible to set different localized strings for different UIControl.State using the declaration @Localized(.key(, for:), .key(, for:) ..., stringsFileName:, bundle:).

The method .key(:, for: ) is a factory method to instantiate the object that associate a key to a state LocalizedConfiguration.

// In the following example the string for the key "Button.Title" will be set for the normal state and the string for the key "Button.Highlighted.Title" will be set for the highlighted state.
@Localized(.key("Button.Title", for: .normal),
           .key("Button.Highlighted.Title", for: .highlighted))
@IBOutlet private var button: UIButton!

It is possible to set stringsFileName and bundle just like in the examples above.

Info

Made with ❀️ and β˜•οΈ by @MarioIannotta

More Repositories

1

PullUpController

Pull up controller with multiple sticky points like in iOS Maps
Swift
1,243
star
2

MIBlurPopup

MIBlurPopup lets you create popups with a blurred background
Swift
605
star
3

SplitViewDragAndDrop

Drag and drop between your apps in split view mode on iOS 9
Swift
330
star
4

ShyView

A UI component that avoids screenshots and recordings
Swift
194
star
5

SwizzleSwift

Swizzle selectors with just one clean and elegant API
Swift
155
star
6

LoadingPlaceholderView

Non-blocking animated gradient placeholder view for your async tasks.
Swift
132
star
7

SwiftyContextMenu

UIContextMenu backporting with Swifter API
Swift
123
star
8

MIPivotPageController

MIPivotPageController allows switching view controllers with an horizontal swipe
Swift
89
star
9

MIAlertController

A simple fully customizable alert controller
Swift
54
star
10

BlurView

Custom blur radius for your UIKit views
Swift
39
star
11

Sivire

Record videos of your simulators from the mac menu bar
JavaScript
10
star
12

QuickLookFramework

A quick look plugin to inspect Frameworks
Swift
9
star
13

SwiftAcknowledgements

Extract your SPM dependencies licenses and add them to the Settings.bundle of your app
Swift
8
star
14

Nomosi

Declarative plug and play network services for your iOS and MacOS apps
Swift
7
star
15

SivireSDK

Add gesture to your video recorded with Sivire
Swift
4
star
16

GitProjects

A Swift script to extract stats from multiple git repositories
Swift
4
star
17

MIPlotter

Draw your histograms quickly and easily.
Objective-C
3
star
18

MIJsonParser

Just like json_encode, simple convert your arrays in valid json string.
PHP
1
star
19

Postfix-expression-evaluator

A script to evaluate mathematical expression in postfix notation
Python
1
star
20

MarioIannotta

1
star