Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHoste committed Dec 11, 2015
1 parent 6cf3e61 commit 4e0197a
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions README.md
Expand Up @@ -8,24 +8,24 @@ Add this gem to your [Rails](http://rubyonrails.org) app to translate it with [T

## Installation

Add the gem to your project's Gemfile :
Add the gem to your project's Gemfile:

gem 'translation'

Then :
Then:

* Create a translation project [from the UI](https://translation.io).
* Copy the initializer into your Rails app (`config/initializers/translation.rb`)

The initializer looks like this :
The initializer looks like this:

TranslationIO.configure do |config|
config.api_key = 'some api key which is very long'
config.source_locale = 'en'
config.target_locales = ['fr', 'nl', 'de', 'es']
end

And finish by inititalizing your translation project with :
And finish by inititalizing your translation project with:

bundle exec rake translation:init

Expand All @@ -34,36 +34,46 @@ If you later need to add/remove target languages, please read our

## Sync

To send new translatable keys/strings and get new translations from Translation.io, simply run :
To send new translatable keys/strings and get new translations from Translation.io, simply run:

bundle exec rake translation:sync

## Sync and Purge

If you also need to remove unused keys/strings from Translation.io using the current branch as reference :
If you also need to remove unused keys/strings from Translation.io using the current branch as reference:

bundle exec rake translation:sync_and_purge

As the name says, this operation will also perform a sync at the same time.

Warning : all keys that are not present in the current branch will be **permanently deleted both on Translation.io and in your app**.
Warning: all keys that are not present in the current branch will be **permanently deleted both on Translation.io and in your app**.

## Advanced Configuration Options

The `TranslationIO.configure` block in `config/initializers/translation.rb` can take several optional configuration options.

### Disable GetText

Sometimes, you only want to use YAML and don't want to be bothered by GetText at all.
For these cases, you just have to add `disable_gettext` in the config file.

For example:

TranslationIO.configure do |config|
...
config.disable_gettext = true
...
end

### Ignored YAML keys

Sometimes you would like to ignore some YAML keys coming from gems or so.
You can use the `ignored_key_prefixes` for that.

For example :
For example:

TranslationIO.configure do |config|
...

config.ignored_key_prefixes = [
'number.human.',
'admin.',
Expand All @@ -74,12 +84,13 @@ For example :
'views.pagination.',
'enumerize.visibility.'
]
...
end

### Custom localization key prefixes

Rails YAML files contain not only translation strings but also localization values (integers, arrays, booleans)
in the same place and that's bad. For example : date formats, number separators, default
in the same place and that's bad. For example: date formats, number separators, default
currency or measure units, etc.

A translator is supposed to translate, not localize. That's not his role to choose how you want your dates or
Expand All @@ -92,28 +103,28 @@ That's why these localization keys are detected and separated on a dedicated YAM
We automatically threat [known localization keys](lib/translation_io/yaml_entry.rb), but if you would like
to add some more, use the `localization_key_prefixes` option.

For example :
For example:

TranslationIO.configure do |config|
...

config.localization_key_prefixes = ['my_gem.date.formats']
...
end

### Paths where locales are stored (not recommended)

You can specify where your GetText and YAML files are on disk :
You can specify where your GetText and YAML files are on disk:

TranslationIO.configure do |config|
...

config.locales_path = 'some/path' # defaults to config/locales/gettext
config.yaml_locales_path = 'some/path' # defaults to config/locales
...
end

## Tests

To run the specs :
To run the specs:

bundle
bundle exec rspec
Expand Down

0 comments on commit 4e0197a

Please sign in to comment.