Git Product home page Git Product logo

iblocalizable's Introduction

IBLocalizable

Localize your views easily in Interface Builder with IBLocalizable.

codecov.io Language CocoaPods Compatible Awesome GitHub license

With IBLocalizable, you can localize your views in Interface Builder easily. Simply set the new Localizable String property that shows up in Interface builder to the value that you added in your Localizable .string file. Most views can be localized this way without a single line of code.

Installation

Add .Package(url: "https://github.com/PiXeL16/IBLocalizable.git",majorVersion: 1) to your Package.swift

Add pod 'IBLocalizable' to your Podfile.

Add github "PiXeL16/IBLocalizable" to your Cartfile.

Manual Installation

  • Please note, installation via CocoaPods or Carthage is much simpler and recommended.

Download and drop /IBLocalizable in your project.

Supported Views

  • UILabel
  • UIButton
  • UINavigationItem (Navigation titles)
  • UIBarItem (BarButton, TabBarItem, etc)
  • UITextField
  • UITextView
  • UISearchBar

Supporting custom views

Custom views can be supported easily. Just create an extension and implement the Localizable Protocol.

If your custom view extends from UIView you only need to extend your custom view and implement the localizableProperty.

For example: lets say that I have a custom view that contains several UILabel and a UIImageView. I will like to localize one of the UILabel.

import UIKit
extension MyCustomView {

    public override var localizableProperty: String?{

        get{
            return self.label.text
        }
        set{
            self.label.text = newValue
        }
    }
}

Thats it! ๐Ÿ˜„.

Usage

After the package its installed simply open your Storyboard or Interface Builder. All of the supported views will show a new Localizable String property.

interfaceBuilder

Since everything is extension based, IBLocalizable should play nice with other libraries or pods that you are using.

Build Performance

Since IBLocalizable only uses IBInspectable and never IBDesignable, your incremental builds will continue to work. (http://www.openradar.me/20690594)

Sample Project

In the Xcode Project you can find a sample project of a simple Login view controller. All of this is automatically localizable in English and Spanish by just using IBLocalizable.

English

english

Spanish

spanish

To do

  • Support more views (TableView Cells, etc)
  • Improve sample project.

Author

Chris Jimenez - http://code.chrisjimenez.net, @chrisjimeneznat

๐Ÿบ Donate

If you want to buy me a beer, you can donate to my coin addresses below:

BTC

1BeGBew4CBdLgUSmvoyiU1LrM99GpkXgkj

ETH

0xa59a3793E3Cb5f3B1AdE6887783D225EDf67192d

LTC

Ld6FB3Tqjf6B8iz9Gn9sMr7BnowAjSUXaV

License

IBLocalizable is released under the MIT license. See LICENSE for details.

iblocalizable's People

Contributors

dum4ll3 avatar gabrielvieira avatar geoffrey-t avatar jaharabari avatar ktakayama avatar pixel16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iblocalizable's Issues

Change Language by manually

Hi,
i tried to implement your lib. but i have serval doubts, how i can change lng by manually .
do have any method to pass lng short to access Localizable.string file.

Improve Sample Project

Currently Sample project is very simple / ugly. We should be able to improve it and make it show the localizable controls in a better way.

Swift 4 issue: Declarations in extensions cannot override yet

Hey!

There is an issue with Swift 4 and extension overrides: Declarations in extensions cannot override yet (see attached picture).

error

This is a non-blocking issue as it continue to work with Xcode 9 and the Swift 3 mode we can set manually, and for now the issue is related to Cocoapods.

Have a good day!
Best regards.

Thomas

Not working with Carthage installation

I wanted to use IBLocalizable with option to install via Carthage, but it didn't work.
Tried it in a small sample App.
Tried the same with the CocoaPods installation and it worked.

Uppercase and Capitalized?

I have been using a similar solution to what IBLocalizable does for quite some time using user defined attributes, although not having to define user defined attributes myself is admittedly so much cooler!

Over time, I realized that I was creating outlets just so I can capitalize or uppercase the localizable properties of UI elements, so I added a few extra methods for handling that. Something like:

func setLocalizedUppercaseText(_ text: String) {
    text = NSLocalizedString(text, comment: "").uppercased(with: Locale.current)
}

Do you think something like that, implemented according to IBLocalizable's architecture would make sense to be added?

Manual Installation

CocoaPods and Carthage are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.

It would be cool to add the Manual installation guide in your README.md. You can take a look at my iOS Readme Template to see how you can do it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.