Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created locales.thor to test locale files, list locale files ready for Rails 3, etc. Also replace README.textile with README.md, a markdowned text file.
- Loading branch information
Showing
5 changed files
with
186 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
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](http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale/) and put them into config/locales of your Rails application. | ||
|
||
If any translation doesn't suit well to the requirements of your application, edit them. | ||
|
||
Available locales are: | ||
> ar, bg, bn-IN, bs, ca, cz, da, de, de-AT, de-CH, dsb, el, en-GB, en-US, es, | ||
> es-AR, es-CO, es-MX, es-PE, et, eu, fa, fi, fr, fr-CH, fur, gl-ES, gsw-CH, he, | ||
> hi-IN, hr, hsb, hu, id, is, it, ja, ko, lo, lt, lv, mk, mn, nb, nl, nn, pl, | ||
> pt-BR, pt-PT, rm, ro, ru, sk, sl, sr, sr-Latn, sv-SE, sw, th, tr, uk, vi, | ||
> zh-CN, zh-TW | ||
Note that all locale files are not yet ready for Rails 3. Currently, following locales are ready for Rails 2 and 3: | ||
> en-US, es-MX, fr, gsw-CH, hi-IN, ja | ||
We always welcome your contributions! | ||
|
||
### How to contribute | ||
|
||
#### Creating or editing your locale file | ||
|
||
* Get a github account and Git program if you haven't. See [Help.Github](http://help.github.com/) for instructions. | ||
* Fork svenfuchs/rails-i18n repository and clone it into your PC. | ||
* Have a look in rails/locale/en-US.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 <code>&errors_messages</code> and <code><<: *errors_messages</code> 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 changes, test the integrity of your locale file. | ||
|
||
Make sure you have the <code>i18n</code> and <code>thor</code> installed. If you haven't, install them: | ||
|
||
sudo gem install i18n thor | ||
|
||
You can test your locale by running following command on the root directory of this repository: | ||
|
||
thor locales:test [your-locale] | ||
|
||
Assuming that there is a file <code>rails/locale/[your-locale].{rb,yml}</code> you will get a list of keys missing from your locale data. | ||
|
||
Invoke following command to test all locale files: | ||
|
||
thor locales:test_all | ||
|
||
You can list all locales that are ready both for Rails version 2 and 3: | ||
|
||
thor locales:ready | ||
|
||
You can also list the locales ready for a specific version of Rails. For example: | ||
|
||
thor locales:ready_for 3 | ||
|
||
Lastly, you can list all available locales: | ||
|
||
thor locales:list | ||
|
||
#### 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 <code>("|').*(\1)</code> as a search expression, tell it to use this as a "Regular expression" | ||
1. hit return and it will select the next string | ||
1. use shift-cmd-e to extract that string | ||
1. hit cmd-g to select the next string |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require File.dirname(__FILE__) + '/rails/test/lib/key_structure.rb' | ||
|
||
class Locales < Thor | ||
desc 'test_all', 'Check formality of all locale files.' | ||
def test_all | ||
Dir.glob(File.dirname(__FILE__) + '/rails/locale/*.{rb,yml}') do |filename| | ||
if md = filename.match(/([\w\-]+)\.(rb|yml)$/) | ||
locale = md[1] | ||
[2, 3].each do |version| | ||
unless KeyStructure.check(locale, version).empty? | ||
puts "[#{locale}] Some keys are missing for Rails #{version}." | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
desc 'test LOCALE', 'Check formality of a locale file.' | ||
def test(locale) | ||
good = true | ||
[2, 3].each do |version| | ||
missing_keys = KeyStructure.check(locale, version) | ||
unless missing_keys.empty? | ||
puts "The following keys are missing for Rails #{version}." | ||
missing_keys.each do |key| | ||
puts " " + key | ||
end | ||
good = false | ||
end | ||
end | ||
|
||
puts "The structure is good for Rails 2 and 3." if good | ||
end | ||
|
||
desc 'list', 'List locale names.' | ||
def list | ||
locales = [] | ||
Dir.glob(File.dirname(__FILE__) + '/rails/locale/*.{rb,yml}') do |filename| | ||
if md = filename.match(/([\w\-]+)\.(rb|yml)$/) | ||
locales << md[1] | ||
end | ||
end | ||
puts locales.sort.join(', ') | ||
end | ||
|
||
desc 'ready', 'List locales ready for Rails 2 and 3.' | ||
def ready | ||
locales = [] | ||
Dir.glob(File.dirname(__FILE__) + '/rails/locale/*.{rb,yml}') do |filename| | ||
if md = filename.match(/([\w\-]+)\.(rb|yml)$/) | ||
locale = md[1] | ||
if [2, 3].all? { |version| KeyStructure.check(locale, version).empty? } | ||
locales << locale | ||
end | ||
end | ||
end | ||
puts locales.sort.join(', ') | ||
end | ||
|
||
desc 'ready_for VERSION', 'List locales ready for a VERSION of Rails.' | ||
def ready_for(version) | ||
locales = [] | ||
Dir.glob(File.dirname(__FILE__) + '/rails/locale/*.{rb,yml}') do |filename| | ||
if md = filename.match(/([\w\-]+)\.(rb|yml)$/) | ||
locale = md[1] | ||
if KeyStructure.check(locale, version).empty? | ||
locales << locale | ||
end | ||
end | ||
end | ||
puts locales.sort.join(', ') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters