Giter Club home page Giter Club logo

iiilocalizedindex's Introduction

IIILocalizedIndex


Summary

IIILocalizedIndex is a simple Objective-C class to index a localized data source array, it constructs indexes for both alphabetic and ideographic languages like CJK. You can use it to create indexed table view with multi-language support, as the 'Contacts' app.

This is still an init version, we need to add more supporting languages. So anyone who has knowledge in different languages is welcome to accomplish this class.

Supporting languages

  • en English
  • zh-Hans Simplified Chinese

Why need it

For alphabet based languages, it's easy to index an array and to get the common [A-Z] or localized index, UILocalizedIndexedCollation can do the job for you.

However, some languages are not based on alphabet (i.e. CJK), some based on ideographic writing system. It's kind of difficult to construct alphabetic index from ideographic characters. This is the case when you might need IIILocalizedIndex.

How it works

Theoretically, if a language supports 'localizedCaseInsensitiveCompare', then there is a certain order for all characters in that language. If this order makes sense to users (i.e. alphabetic order, pronouncing order), then it's possible to find a group of delimiters to partition all those characters into sections, and to provide an title for each section (i.e. for English, the section titles are [A-Z]).

IIILocalizedIndex provides a group of delimiters for every supported language, and a group of corresponding section titles. These section titles could be any characters, you can set them as [A-Z], [0-9], or any localized characters, or whatever.

Limitations

  • The precondition for IIILocalizedIndex is that the order for characters in that language is intelligible to users, and delimiters are obvious and reasonable for partitioning all characters.

    For example: There is a mapping relationship between [A-Z] alphabet and the pronunciation of Chinese characters, and it's evident to app users that the order of Chinese characters is generally based on pronunciation.

  • 'Generally' means not 100% based on that rule. There are few strange Chinese characters are not ordered based on pronunciation (They are so strange that you can think the pronunciation is a right rule). So another limitation is that order rule for a language should be consistent to users.

How to use it

  1. Add the IIILocalizedIndex folder to your project.
  2. Invoke the + (NSDictionary *)indexed:(NSArray *)data method to get a dictionary, use this dic to set data for table view.
  3. This method sends description message to items in data array. So if items are objects of custom classes, remember to implement your own description method for getting index.

Requirements

IIILocalizedIndex uses ARC. If you are not using ARC in your project, add '-fobjc-arc' as a compiler flag for all the files in IIILocalizedIndex.

Licenses

All source code is licensed under the [MIT License][3] [3]: https://raw.github.com/sehone/IIILocalizedIndex/master/LICENSE.md

iiilocalizedindex's People

Contributors

sehone avatar

Watchers

 avatar  avatar

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.