GithubHelp home page GithubHelp logo

suhinini / genloc Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 4.0 130 KB

GenLoc is a Ruby script that helps avoiding magic strings in iOS/OSX projects while using localization.

Ruby 30.02% Objective-C 69.98%

genloc's Introduction

GenLoc

GenLoc is a Ruby script that helps avoiding magic strings in iOS/OSX projects while using localization.

For each key in your Localizable.strings file it will generate an appropriate constant. This will allow you to avoid using magic strings in your code and use code completion for faster localized strings usage.

Installation

Installation is quite simple.

  1. Add genloc.rb to your project
  2. Add new "External Build System" target named "GenLoc" to your project
    • Set "Build Tool" to "/usr/bin/ruby"
    • Set "Arguments" to $(SRCROOT)/{path-to-genloc}/genloc.rb -o $(SRCROOT)/{path-to-output-file}/{output-file-name}.h -l $(SRCROOT)/{path-to-your-main-localizable-folder}/Localizable.strings
  3. In your main target, add your "GenLoc" target as a dependency ("Build Phases" tab, first block)
  4. Build your project. If all fine, you'll get your output file generated. Add it to the project.
  5. Add appropriate "#import" directive to your prefix file

Notes

  1. Use sample project as a guide
  2. Keys in Localizable.strings should consist of words separated by underscores, like this: "MY_PERFECT_KEY"
  3. If you name your output file as SMLocalized.h, then you'll get SMLocalizedMyPerfectKey constant
  4. Don't modify generated file. It contains a timestamp which is basically a last modified date of the original Localized.strings file. This avoids triggering total rebuild in most cases.

Questions

If you have any questions / want new feature / found a bug, reach me here, at Twitter (@suhinini) or by email (Twitter username at Gmail).

genloc's People

Contributors

suhinini avatar

Stargazers

Xie Wu avatar mayulu avatar Indragie Karunaratne avatar Jason Brennan avatar Flori avatar Romain Briche avatar Ari Braginsky avatar

Watchers

Flori avatar  avatar mayulu avatar

genloc's Issues

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.