Giter Site home page Giter Site logo

i18n-tools's Introduction

I18n Tools

Tools useful for working with Ruby/Rails I18n. Currently contains only the source parser tool.

I18n Keys Source Parser

(You can always have a look at thor -T for the current list of available Thor commands.)

Requirements

You need to use Ruby 1.9 because we depend on Ripper2Ruby which requires Ripper. If you happen to know a way to compile/use Ripper for Ruby 1.8.x please let me know.

Also, the library currently expects to find the gems I18n and Ripper2Ruby frozen to vendor/.

You also need Thor to use the command line tool. You might experience problems getting Thor to behave under Ruby 1.9. Please let me know when I can remove this notice ;)

Installation

install i18n-tools (should require and install ripper2ruby)
install thor
thor install http://github.com/svenfuchs/i18n-tools/raw/master/i18n-tools.thor --as i18n-tools

Usage

thor i18n:keys:find KEYS [--index] [--dir=DIR] [--pattern=PATTERN] [--context=N] 
thor i18n:keys:find SEARCH REPLACE [--index] [--dir=DIR] [--pattern=PATTERN] [--context=N] [--verbose]

Key Pattern

foo   - finds all calls to I18n.t with the key 'foo'
foo*  - finds all calls to I18n.t with keys starting with 'foo'
*foo  - finds all calls to I18n.t with keys ending with 'foo'
*foo* - finds all calls to I18n.t with keys containing 'foo'

In most situations it might make sense to also use a dot, as in:
foo.*, *.foo, *.foo.*

Options

--index
	Build and/or use an index. When you use --index for the first time
	an index will be built. On subsequent usages the existing index will
	be used (largely speeding up the command).
	
--dir
	Root directory where files matching the pattern are searched for. If you
	use a saved index this is also the directory where a .i18n/ directory
	will be created for the index file.
	
--pattern
	Glob pattern that is used to find
	
--context
	Output the given number of lines of context before and after occurences.

--verbose
	Output additional information (e.g. while index being built). (Currently
	not supported)

Examples

thor i18n:keys:find foo.* --index --dir=path/to/project --pattern=**/*.{rb,erb} --context=2
thor i18n:keys:find foo.* bar --index --dir=path/to/project --pattern=**/*.{rb,erb} --context=2

Notes

If you're using zsh arguments given with a wildcard are expanded to filenames before being passed. So i18n-keys find foo.* won't work. You can either use quotes as in i18n-keys find "foo.*" or turn zsh filename generation off with: unsetopt GLOB.

If you have Ruby 1.9 installed in parallel to 1.8.x you might want to install Thor with the -E option to make the executable wrapper use /usr/bin/env instead of hardcoding the path to your Ruby executable. E.g.:

sudo gem install wycats-thor -E --source=http://gems.github.com

i18n-tools's People

Stargazers

Kristian Mandrup avatar

Watchers

Kristian Mandrup avatar James Cloos 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.