Coder Social home page Coder Social logo

vincentneo / localecomplete Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 0.0 388 KB

Autocomplete Swift Locale identifiers.

License: MIT License

Objective-C 2.10% Swift 97.09% Ruby 0.81%
locale localisation swift ios watchos osx tvos autocomplete identifiers strongly-typed

localecomplete's Introduction

LocaleComplete

CI Status Swift Version License Platform Version Carthage compatible Swift Package Manager compatible

Easily use Locale in Swift, without needing to deal with String based identifiers!

How to use

Ever spent time finding the right identifier for the right Locale language/region? Ever misspelt a Locale identifier?

With LocaleComplete, you do not have to deal with that anymore. Simply type what you think would be right, and let the system auto complete it for you. This library extends Locale and NSLocale to allow easier use of Locale, with code completion support, via two enum containing all Locale identifiers.

So you can turn this:

      let locale = Locale(identifier: "en_SG")

into this:

      let locale = Locale(id: .en_SG)

or this:

      let locale = Locale(key: .englishSingapore)

Pretty easy and readable, isn't it?

Inspiration

If you're wondering why I would create this project, here's why: I always felt that it was a pain to deal with Locale identifiers. Searching on the web, and there doesn't seem to be a project like this, which made me develop this.

It's entire concept is inspired by the following great projects:

Do check them out! These are cool and helpful libraries to make development easier.

To install

LocaleComplete works in all Apple platforms, and supports Swift Package Manager, CocoaPods and Carthage.

By CocoaPods, add the following to your Podfile:

pod 'LocaleComplete'

By Carthage, add the following to your Cartfile:

github "vincentneo/LocaleComplete"

Contributing

Contributions to this project will be more than welcomed. Feel free to add a pull request or open an issue. If you require a feature that has yet to be available, do open an issue, describing why and what the feature could bring and how it would help you!

License

LocaleComplete is available under the MIT license. See the LICENSE file for more info.

localecomplete's People

Contributors

vincentneo avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

localecomplete's Issues

LocaleID's with Cyrl/Latn script designators are designed not in accordance with documentation

Hey there!

First of all, thanks for such a useful project. These tiny tools make work with old APIs much less frustrating!

I must admit i didn't manage to use this package in my project yet, so this issue might be irrelevant.

I checked the use of Cyrl/Latn script designators in LocaleID.swift and noticed that an underscore is used instead of a hyphen to separate language designator and script designator:

case sr_Cyrl
case sr_Cyrl_BA
case sr_Latn
case sr_Latn_BA

while in Internationalization and Localization Guide - Appendix B: Language and Locale IDs - Locale IDs there is a following schema for ID's featuring a scrip designator:

[language designator]-[script designator] //az-Arab, zh-Hans
[language designator]-[script designator]_[region designator] //zh-Hans_HK

Notice the use of hyphen to separate language and script designators.

I believe there is possibility that for specific case of locale with a script designator this package will not produce a valid instance.

I may test this case in the future and provide a fix but cannot promise as of now.

Again, thanks for this tiny yet very useful package!

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.