Skip to content

carvid/rails-i18n

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rails Locale Data Repository

Central point to collect locale data for use in Ruby on Rails.

Rails translations

How to use them

Download the locale files that are found in the directory rails/locale and put them into config/locales of your Rails application.

Note that all locale files are not yet ready for Rails 3. We always welcome your contributions.

How to contribute

How to create/edit your locale file

To begin with, you must have a github account and Git program. See Help.Github for instructions.

Then, fork svenfuchs/rails-i18n repository and clone it into your PC.

If you’ve got the repo, have a look in rails/locale/en.yml, which can be used as the base of your translation.

This file is a compound of all translation files in the Rails 2 and 3 packages.
Note that we use &errors_messages and <<: *errors_messages to anchor and merge a part of translation data.

Create or edit your translation file.

Please include a comment with the language/locale name and your name and email address (or other contact information like your github profile) to the locale file so people can come contact you and ask questions etc.

Also, please pay attention to save your files as UTF-8.

Testing your translation file

Before commit and push your change, use structure.rb, a simple tool for testing the integrity of your key structure.

Make sure you have the Ruby I18n gem installed. If you haven’t already you can try:

sudo gem install i18n

Then, standing in the root directory of this repository, do:

ruby rails/test/structure.rb [your-local]

Assuming that there is a file rails/locale/[your-locale].{rb,yml} you will get a list of missing keys in your locale data.

If you want to test all locale files, run:

rake

to invoke test task.

The test task will print many missing keys because few translation files are ready for Rails 3.

Sending pull request

I you are ready, push the repository into the Github and send us a pull request.

We will do the formality check and publish it as quick as we can.

Rails I18n Textmate bundle

The bundle adds the following commands:

Extract Translation (cmd-shift-e):

  • prompts you for a dot-separated key
  • adds the translation (mapping the dot-separated key to nested yaml keys)
  • replaces the selected string in your source-code with the dot-separated key wrapped into a call to t(your.key), if interpolations are detected within translation, the replacement text will prompt for them.

Look up Translation (cmd-shift-i):

  • Looks up the currently selected key if text is selected
  • If nothing is selected, it will look up all the keys in the currently selected file.

The bundle adds the following tab triggers:

tr:

  • Inserts I18n.translate("") or translate("") based on your context

The following properties are editable:

  • default locale
  • translation file path
  • whether extract inserts the long syntax (I18n.translate) or short syntax (I18n.t)
  • where and if translation changes are logged

Note that Textmate, while active, won’t reload the translations.yml for you if it’s already open. When you give the focus to another application and then go back to Textmate (e.g. with cmd-tab, cmd-tab) it will reload the file. I found it useful to have translations.yml open on a second monitor while extracting translations from my application.

I still have to figure out how to automatically select the next string after this command has run. It works well to just use Textmate’s “Find Next” though:

  1. hit cmd-f and give it ("|').*(\1) as a search expression, tell it to use this as a “Regular expression”
  2. hit return and it will select the next string
  3. use shift-cmd-e to extract that string
  4. hit cmd-g to select the next string

About

Repository for collecting Locale data for Ruby on Rails I18n as well as other interesting, Rails related I18n stuff

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 98.0%
  • JavaScript 2.0%