Giter Club home page Giter Club logo

rails-i18n's Introduction

Rails Locale Data Repository

Gem Version CI

Centralization of locale data collection for Ruby on Rails.

Gem Installation

Include the gem to your Gemfile:

gem 'rails-i18n', '~> 7.0.0' # For 7.0.0
gem 'rails-i18n', '~> 6.0' # For 6.x
gem 'rails-i18n', '~> 5.1' # For 5.0.x, 5.1.x and 5.2.x
gem 'rails-i18n', '~> 4.0' # For 4.0.x
gem 'rails-i18n', '~> 3.0' # For 3.x
gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'master' # For 5.x
gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'rails-4-x' # For 4.x
gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'rails-3-x' # For 3.x

Alternatively, execute the following command:

gem install rails-i18n -v '~> 7.0.0' # For 7.0.0
gem install rails-i18n -v '~> 6.0' # For 6.x
gem install rails-i18n -v '~> 5.1' # For  For 5.0.x, 5.1.x and 5.2.x
gem install rails-i18n -v '~> 4.0' # For 4.0.x
gem install rails-i18n -v '~> 3.0' # For 3.x

Note that your Ruby on Rails version must be 3.0 or higher in order to install the rails-i18n gem. For rails 2.x, install it manually as described in the Manual Installation section below.

Configuration

Enabled modules

By default, all rails-i18n modules (locales, pluralization, transliteration, ordinals) are enabled.

If you would like to only enable specific modules, you can do so in your Rails configuration:

# to enable only pluralization rules, but disable all other features
config.rails_i18n.enabled_modules = [:pluralization]

# to enable pluralization and ordinals
config.rails_i18n.enabled_modules = [:pluralization, :ordinals]

The possible module names:

  • :locale
  • :ordinals
  • :pluralization
  • :transliteration

Setting enabled_modules will restrict the gem's loaded features to only the specific types.

Available locales

rails-i18n gem initially loads all available locale files, pluralization and transliteration rules. This default behaviour can be changed. If you specify in config/environments/* the locales which have to be loaded via I18n.available_locales option:

config.i18n.available_locales = ['es-CO', :de]

or

config.i18n.available_locales = :nl

Manual Installation

Download desired locale files found in rails/locale directory and move them into the config/locales directory of your Rails application.

If any translation doesn't suit well to the requirements of your application, edit them or add your own locale files.

For more information, visit Rails Internationalization (I18n) API on the RailsGuides.

Usage on Rails 2.3

Locale data whose structure is compatible with Rails 2.3 are available on the separate branch rails-2-3.

Available Locales

Available locales:

af, ar, az, be, bg, bn, bs, ca, cs, cy, csb, da, de, de-AT, de-CH, de-DE, dsb, dz, el, el-CY, en, en-AU, en-CA, en-CY, en-GB, en-IE, en-IN, en-NZ, en-TT, en-US, en-ZA, eo, es, es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, et, eu, fa, fi, fr, fr-CA, fr-CH, fr-FR, fur, fy, gd, gl, gsw-CH, he, hi, hi-IN, hr, hsb, hu, id, is, it, it-CH, ja, ka, kk, km, kn, ko, lb, lo, lt, lv, mg, mk, ml, mn, mr-IN, ms, nb, ne, nl, nn, oc, or, pa, pap-AW, pap-CW, pl, pt, pt-BR, rm, ro, ru, sc, scr, sk, sl, sq, sr, st, sv, sv-FI, sv-SE, sw, ta, te, th, tl, tr, tt, ug, uk, ur, uz, vi, wo, zh-CN, zh-HK, zh-TW, zh-YUE

Complete locales:

en, en-US, es, es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, fr, fr-CA, fr-CH, fr-FR, gd, ja, pt, pt-BR, ru, sc

Locales with missing pluralization rules

af, csb, dsb, dz, fur, gsw-CH, lb, rm, scr, sq, sv-FI, te, tt, ug, uz

Removed pluralizations:

ak, am, bh, bm, bo, br, by, cy, dz, ff, ga, gd, guw, gv, ig, ii, iu, jv, kab, kde, kea, ksh, kw, lag, ln, mo, mt, my, naq, nso, root, sah, se, ses, sg, sh, shi, sma, smi, smj, smn, sms, ti, to, tzm, wa, yo, zh

The above pluralization rules were removed because they did not have corresponding locale files.

Currently, most locales are incomplete. Typically they lack the following keys:

  • activerecord.errors.messages.record_invalid
  • activerecord.errors.messages.restrict_dependent_destroy.has_one
  • activerecord.errors.messages.restrict_dependent_destroy.has_many

The following keys should NOT be included:

  • errors.messages.model_invalid
  • errors.messages.required

We always welcome your contributions!

Currency Symbols

Some locales have the symbol of the currency (e.g. ) under the key number.currency.format.unit, while others have the code (e.g. CHF). The value of the key depends on the widespread adoption of the unicode currency symbols by fonts.

For example the Turkish Lira sign () was recently added in Unicode 6.2 and while most popular fonts have a glyph, there are still many fonts that will not render the character correctly.

If you want to provide a different value, you can create a custom locale file under config/locales/tr.yml and override the respective key:

tr:
  number:
    currency:
      format:
        unit: TL

How to Contribute

Quick Contribution

If you are familiar with GitHub operations, then follow the procedures described in the subsequent sections.

If not,

  • Save your locale data in a Gist.
  • Open an issue with reference to the Gist you created.

Fetching the rails-i18n Repository

  • Get a github account and Git program if you haven't. See Help.Github for instructions.
  • Fork svenfuchs/rails-i18n repository and clone it into your PC.

Creating or Editing your Locale File

  • Have a look in rails/locale/en.yml, which should be used as the base of your translation.
  • Create or edit your locale file. Please pay attention to save your files as UTF-8.

Testing your Locale File

Before committing and pushing your changes, test the integrity of your locale file. (You can also run the tests using Docker, see below)

bundle exec rake spec

Make sure you have included all translations with:

bundle exec rake i18n-spec:completeness rails/locale/en.yml rails/locale/YOUR_NEW_LOCALE.yml

Make sure it is normalized with:

thor locales:normalize LOCALE # or "thor locales:normalize_all"

You can list all complete and incomplete locales:

thor locales:complete
thor locales:incomplete

Also, you can list all available locales:

thor locales:list

You can list all missing keys:

i18n-tasks missing es

Edit README.md

Add your locale name to the list in README.md if it isn't there.

Send pull request

If 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.

Add an informative title to your pull request or issue

If your pull request or issue concerns a specific locale - please indicate the relevant locale in the issue or pull request title in order to facilitate triage.

Best:

Danish: change da.errors.messages.required to "skal udfyldes"

Good:

Human precision in Swedish locale file is set to 1

Update es-PE.yml, the currency unit is incorrect

Bad:

Changing some string about validation

Docker

Build the image:

docker build --tag=railsi18n .

Run the tests:

docker run railsi18n

To run the other commands described above:

docker run railsi18n bundle exec rake i18n-spec:completeness rails/locale/en.yml rails/locale/YOUR_NEW_LOCALE.yml

See also

License

MIT

Contributors

See https://github.com/svenfuchs/rails-i18n/contributors

Special thanks

Tsutomu Kuroda for untiringly taking care of this repository, issues and pull requests

rails-i18n's People

Contributors

acesuares avatar amatsuda avatar ariejan avatar c960657 avatar digitalex avatar digitalfrost avatar fotos avatar gunchleoc avatar huerlisi avatar jlduran avatar jofi avatar johnnyshields avatar jolll4 avatar kfl62 avatar kuroda avatar moskitohero avatar nashbridges avatar neydroid avatar nkokkos avatar ozataman avatar pama avatar sikachu avatar silex avatar sunny avatar tigrish avatar tomhughes avatar toncid avatar tsechingho avatar weppos avatar yaroslav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rails-i18n's Issues

es-CO sintax error

Hi I was unable to use the locale file es-CO, because an sintax error in the line 91~
The key and the value on inclusion are together.
I also run the structure test for es-CO and change some compatibility issues. Can I send You guys the modified file?
Thanks.

activerecord.errors.messages.taken

It seems that in Rails 3 activerecord.errors.messages.taken will not resolve for uniqueness errors. errors.messages.taken on the other hand does work.

i18n version conflict

While rails-i18n depends on i18n > 0.6 currently stable rails (> 3.0) still depends on i18n ~> 0.5 making it impossible to use latest rails-i18n with stable rails.
Is there a reason for this?

rake spec fails on Ruby 1.8.7

On Ruby 1.8.7, I got following result:

% rake spec --trace
rake aborted!
no such file to load -- psych
/home/kuroda/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/home/kuroda/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/i18n-spec-0.1.2/lib/i18n-spec.rb:1
/home/kuroda/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/home/kuroda/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/i18n-spec-0.1.2/lib/i18n-spec/tasks.rb:1
/home/kuroda/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60:in `gem_original_require'
/home/kuroda/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60:in `require'
/home/kuroda/github/rails-i18n/repo/Rakefile:34
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/gems/rake-0.9.2.2/bin/rake:33
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/bin/rake:19:in `load'
/home/kuroda/.rvm/gems/ruby-1.8.7-p358/bin/rake:19

I want to run a test on Ruby 1.8.7 in order to fix #208. Please help.

Issue in Italian locale

As you can see here:

1994 The Italian government confirmed their official usage of the long scale.

So, it.number.human.decimal_units shall be:
unit: ""
thousand: "Mila"
million: "Milioni"
billion: "Miliardi"
trillion: "Bilioni"
quadrillion: "Biliardi"

jruby-1.6.0.RC3 cannot read mn.yml.

jruby-1.6.0.RC3 :001 > I18n.t('ala')
ArgumentError: syntax error in "", line 76, column 35:
half_a_minute: "хагас минут"
^
from org/jruby/ext/psych/PsychParser.java:251:in parse' from /home/rupert/.rvm/rubies/jruby-1.6.0.RC3/lib/ruby/1.9/psych.rb:148:inparse_stream'
from /home/rupert/.rvm/rubies/jruby-1.6.0.RC3/lib/ruby/1.9/psych.rb:119:in parse' from /home/rupert/.rvm/rubies/jruby-1.6.0.RC3/lib/ruby/1.9/psych.rb:106:inload'
from /home/rupert/.rvm/rubies/jruby-1.6.0.RC3/lib/ruby/1.9/psych.rb:205:in load_file' from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/base.rb:170:inload_yml'
from org/jruby/RubyBasicObject.java:1671:in __send__' from org/jruby/RubyKernel.java:2063:insend'
from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/base.rb:156:in load_file' from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/base.rb:15:inload_translations'
from org/jruby/RubyArray.java:1572:in each' from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/base.rb:15:inload_translations'
from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/simple.rb:55:in init_translations' from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/simple.rb:69:inlookup'
from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/base.rb:26:in translate' from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/fallbacks.rb:45:intranslate'
from org/jruby/RubyArray.java:1572:in each' from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n/backend/fallbacks.rb:43:intranslate'
from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/i18n-0.5.0/lib/i18n.rb:155:in translate' from (irb):1:inevaluate'
from org/jruby/RubyKernel.java:1092:in eval' from org/jruby/RubyKernel.java:1417:inloop'
from org/jruby/RubyKernel.java:1204:in catch' from org/jruby/RubyKernel.java:1204:incatch'
from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/railties-3.0.5/lib/rails/commands/console.rb:44:in start' from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/railties-3.0.5/lib/rails/commands/console.rb:8:instart'
from /home/rupert/.rvm/gems/jruby-1.6.0.RC3/gems/railties-3.0.5/lib/rails/commands.rb:23:in (root)' from org/jruby/RubyKernel.java:1046:inrequire'

extract - nothing executed :-(

Proceed step by step by guide. But in the end always get something like this just on place of selected string for extract:

/Users/pepe/Library/Application Support/TextMate/Pristine Copy/Bundles/Rails I18n.tmbundle/Support/lib/rails-i18n.rb:25: warning: method redefined; discarding old to_yaml
/Users/pepe/Library/Application Support/TextMate/Pristine Copy/Bundles/Rails I18n.tmbundle/Support/lib/rails-i18n.rb:27:in `to_yaml': undefined local variable or method `taguri' for {"en"=>{"test"=>"test"}}:Hash (NameError)
from /Users/pepe/Library/Application Support/TextMate/Pristine Copy/Bundles/Rails I18n.tmbundle/Support/lib/rails-i18n.rb:26:in `call'
from /usr/lib/ruby/1.8/yaml.rb:373:in `quick_emit'
from /Users/pepe/Library/Application Support/TextMate/Pristine Copy/Bundles/Rails I18n.tmbundle/Support/lib/rails-i18n.rb:26:in `to_yaml'
from /usr/lib/ruby/1.8/yaml.rb:103:in `dump'
from /Users/pepe/Library/Application Support/TextMate/Pristine Copy/Bundles/Rails I18n.tmbundle/Support/lib/rails-i18n.rb:118:in `add_yaml_translation'
from /Users/pepe/Library/Application Support/TextMate/Pristine Copy/Bundles/Rails I18n.tmbundle/Support/lib/rails-i18n.rb:118:in `open'
from /Users/pepe/Library/Application Support/TextMate/Pristine Copy/Bundles/Rails I18n.tmbundle/Support/lib/rails-i18n.rb:118:in `add_yaml_translation'
from /Users/pepe/Library/Application Support/TextMate/Pristine Copy/Bundles/Rails I18n.tmbundle/Support/lib/rails-i18n.rb:77:in `execute'
from /tmp/temp_textmate.kepADj:3

I am crazy from this, please help :-(

Expose as a gem

Hi,

Could this plz be exposed as a gem? Adding it to the Gemfile should do it, and makes keeping up to date a lot easier.

Thnx,
Lawrence

Please check my Greek translation

Hi all Greek speakers,

I just pushed a changeset that updates Greek locale file.

I am a Japanese, but have some knowledge on this language because I lived there for some years as a student.
As a repository maintainer, I am sad to see the Greek language left behind.
So, I did update it.

Correct me if I commit mistakes, please.

Selective locale loading

Currently gem loads all existing locales, which consumes at least 350kb of memory and takes some (maybe not significant) time to compile, whereas application usually needs only couple of locales.

We could rely on I18n.available_locales to prevent loading unused ones, but I think it would be not backward compatible. Maybe we should introduce configuration rule like

config.rails_i18n.load_only_available_locales = true

Any thoughts?

Add timezone translations

There are currently missing timezone translations. Trying something like the following you'll only get the English translations for all the timezones:

= f.time_zone_select :timezone, ActiveSupport::TimeZone.all

Basically we need to add translations for all the timezones in ActiveSupport::TimeZone.all

French helpers translations

Seems to be a problem with fr.helpers.submit.*

Ce problem is : Does having something like "Créer un(e) %{model}" would make sense ? (Not that clean)
The model name can be male or female so how shall we handle this best ?

Warnings in uk transliteration code

Loading the uk transliteration code produces two warnings:

/usr/lib/ruby/gems/1.8/gems/rails-i18n-0.6.0/lib/rails_i18n/../../rails/transliteration/uk.rb:72: warning: regexp has invalid interval
/usr/lib/ruby/gems/1.8/gems/rails-i18n-0.6.0/lib/rails_i18n/../../rails/transliteration/uk.rb:72: warning: regexp has `}' without escape

Numbers as translation keys

Would be neat if this worked. Ran into it setting up translations for different error pages (404, 500 etc.)

>> I18n.t "test"
=> {100=>"dont work", :hundred=>"works"}
>> I18n.t "test.100"
=> "translation missing: sv, test, 100"
>> I18n.t "test.hundred"
=> "works"

Reflexive Interpolation

Further to a very brief twitter exchange I just had with @svenfuchs on Twitter, I thought I would write this here, that there might be a discussion about the merits of this option.

Given the following YAML file:

de:
  virtual_currency:
    one: "Jelly Bean"
    other: "Jelly Beans"
  products:
    index:
      title: "Earn Jelly Beans by retweeting @svenfuchs"
    show:
      title: "Earn Jelly Beans by retweeting @svenfuchs, spend your Jelly Beans on %{product_name}"

A naturally stupid and contrived example, not the frequent duplication of Jelly Beans.

Whilst it's clear that I18n isn't DRY, the name of our virtual currency is re-re-reused in a multitude of places, and it's always the .other subkey. There's one edge-case when it's only one Jelly Bean.

Our solution so far, then looks like this:

de:
  virtual_currency:
    one: "Jelly Bean"
    other: "Jelly Beans"
  products:
    index:
      title: "Earn %{virtual_currency} by retweeting @svenfuchs"
    show:
      title: "Earn %{virtual_currency} by retweeting @svenfuchs, spend your %{virtual_currency} on %{product_name}"

And in every place it's used, t(:'.title', virtual_currency: t('virtual_currency'), product_name: @product.name). This is a little tedious.

To that end, I have a modification to I18n::Backend::Simple (WIP, will probably become a Defaultnterpolations backend in it's own right) that looks something like this:

module I18n
  module Backend
    class Simple
      def interpolate(locale, string, values = {})
        super(locale, string, values.merge({
          virtual_currency: I18n.t('virtual_currency.other')
        }))
      end
    end
  end
end

Would it be possible, advisable, or well received to implement an alternative interpolation syntax, perhaps the immortal {{…}} which would do what I want to call reflexive interpolation, here's an example, only YAML, there's no code changes:

de:
  virtual_currency:
    one: "Jelly Bean"
    other: "Jelly Beans"
  products:
    index:
      title: "Earn {{virtual_currency.other}} by retweeting @svenfuchs"
    show:
      title: "Earn {{virtual_currency.other}} by retweeting @svenfuchs, spend your {{virtual_currency.other}} on %{product_name}"

There's some flaws, I am sure, and one broken, yet seemingly similarly targeted implementation here. From which I drew the original idea for --the solution-- my hack.

I haven't yet explored this enough to know if I18n backends can modify, and pass-on the string in question, to the next backend in the chain, that's some investigation I need to do before I decided if this can be simply a chainable backend, or whether it requires a change to an existing backend.

%d or %e for day?

I see that the day format used in most locale files is %d, e.g.

en-US.yml

  long: ! '%B %d, %Y'
  short: ! '%b %d'

ru.yml

  long: ! '%d %B %Y'
  short: ! '%d %b'

but fr.yml

  long: ! '%e %B %Y'
  short: ! '%e %b'

Is there any reason for using %d (which preserves leading zero) in expected-to-be-natural long and short forms? I do not know if "January 01, 2011" is natural in English, but for Russian "01 января" is definitely weird.

If it is OK I can provide pull request with the change, but there are so many languages I cannot be sure if any of them really need to preserve leading zeros.

When using es.yml in Rails 2.3.11 ActiveRecord#errors#full_messages miss a space

It looks like commit 94230b6 changed activerecord:errors:full_messages:format key from "%{attribute} %{message}" to "%{attribute}%{message}" (no space between attribute and message).

With Rails 2.3.11 this will produce wrongly formatted error messages (for example: 'Nombreno puede estar en blanco', the space between 'Nombre' and 'no' is missing).

I noticed that several other files have the same format for this key, but not all (for some languages this is probably correct, but most european languages probably need a space inbetween the words)

Break out translations for rails 2.3 and rails 3

I'm wondering about what the structure would look like if rails 2.3 and rails 3 translations were separate.

I can see a few advantages to marking a separation :

  • We only need to include localizations for 1 version - we can remove the current duplication/aliasing between versions.
  • The two files can evolve independently - rails 2.3 has been parked, rails 3 is the current and maybe we can think about having a "pre" branch for upcoming rails implementations. The main point is that we should be able to evolve without having to think about breaking backwards compatibility.

I'd be happy to generate the files for each version and for each locale if there's interest in this, my question is more what should the folder structure look like?

As a side note, I see this as being a workable solution to fix #127 and #136 - just saying' :)

Plural rules with one form

When I was creating common pluralization rules, I used CLDR as a specification. So languages with one plural form (like Azerbaijani, Japanese and so on) got :other single key.

But then I noticed commit 64b2b3d by @hron84, which changes :other to :one for Hungarian. I'm not familiar with any mentioned language, but it seems reasonable to use :one in case language has only one plural form.

If so, it would be great to convert all plural rules in one commit, rather then merge about 30 commits.

On the contrary, there's no negative feedback from other natives on this topic (maybe they don't use rails-i18n at all? :)) Does :other key produce any inconvenience/errors in AR?

Fallbacks on t([])

Fallbacks are not working when fetching multiple strings.

Steps to reproduce:

  1. set up fallback to default language:
    • require "i18n/backend/fallbacks" I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
  2. try to fetch multiple strings that are missing in the current locale, but present in the default locale:
    • I18n.t([:missing, :missing2])

Internationalize boolean values

How do I internationalize boolean values like true and false in active_record?
Inserting: true: "Sim"
false: "Não"
does not work when displaying the value of some boolean field.

Thanks

Remove translations for will_paginate gem

We have translations for will_paginate gem with in rails-i18n, but for this gem, there is a specialized repository, will_paginate-i18n.

I think we should remove will_paginate related files from rails-i18n and urge developers to use will_paginate-i18n, devise-i18n, etc on README.md.

Error with errors.template.body in the mn locale?

I think the errors.template.body string in the mn locale is probably wrong, as it uses %{count} as if it was a pluralizable string, but no other locale seems to do so.

I can't actually find where rails uses this resource (or either of it's aliases) though so it's hard to be sure.

Move the taken validation message?

Current the "taken" validation message (used by validates_uniqueness_of) is in the activerecord section of the yml files.

However I think this should be moved into the general "errors" section above its current location since it is also used by other non-activerecord ORMs / ODMs (Mongoid comes to mind) so having it in activerecord section is misleading.

I know some people delete the whole activerecord section since they are using mongoid and believe those translations are specific to activerecord only (Not generally in activemodel).

rake spec fails

rake spec produces following result:

rake aborted!
no such file to load -- i18n-spec/tasks

(See full trace by running task with --trace)

de-capitalization problem

Hi!

I have the following problem with I18n and the "label" form helper:

in my de.yml I have:

de:
  activerecord:
    attributes:
      feedback:
        email: 'E-Mail-Adresse'

In my form I have

<% form_for(@feedback) do |f| %>
    <%= f.label :email %>
    <%= f.text_field :email %>
<% end %>

What happens is that the label method de-capitalizes the string returned by I18n so I get 'E-mail-adresse' in the output which unfortunately is wrong in German.
It is easy to work around this by manually creating an html label tag with a <%= I18n.t 'activerecord.attributes.feedback.email' %> inside.

I think the label form helper should not touch the string returned by I18n.

Cheers,
Patrick

PS: my Rails version is 2.3.4

Help us to complete Rails-3 support

Hi, folks!

We have incomplete translations (from the point of view of Rails 3) for following languages:

  • Arabic [ar]
  • Bengali (India) [bn-IN]
  • Czeck [cs]
  • Welsh [cy]
  • Lower Serbian [dsb]
  • Spanish (Peru) [es-PE]
  • Galician (Spain) [gl-ES]
  • Upper Sorbian [hsb]
  • Indonesian [id]
  • Lao [lo]
  • Lithuanian [lt]
  • Macedonian [mk]
  • Mongolian [mn]
  • Norwegian [nn]
  • Polish [pl]
  • Romansh [rm]
  • Romanian [ro]
  • Serbian [sr]
  • Serbian (Latin) [sr-Latn]
  • Turkish [tr]

Please help us to complete them by making necessary modifications and submitting pull requests.

If you are not familiar with YAML syntax or GitHub operations, send me a message.

Thanks a lot, in advance.

transliteration/ru.rb gives warning: already initialized constant

When I run my test or load my environment, I get:

.../gems/rails-i18n-0.5.1/lib/rails_i18n/../../rails/transliteration/ru.rb:7: warning: already initialized constant LOWER_SINGLE
.../gems/rails-i18n-0.5.1/lib/rails_i18n/../../rails/transliteration/ru.rb:18: warning: already initialized constant LOWER_MULTI
.../gems/rails-i18n-0.5.1/lib/rails_i18n/../../rails/transliteration/ru.rb:23: warning: already initialized constant UPPER_SINGLE
.../gems/rails-i18n-0.5.1/lib/rails_i18n/../../rails/transliteration/ru.rb:34: warning: already initialized constant UPPER_MULTI
.../gems/rails-i18n-0.5.1/lib/rails_i18n/../../rails/transliteration/ru.rb:39: warning: already initialized constant LOWER
.../gems/rails-i18n-0.5.1/lib/rails_i18n/../../rails/transliteration/ru.rb:40: warning: already initialized constant UPPER
.../gems/rails-i18n-0.5.1/lib/rails_i18n/../../rails/transliteration/ru.rb:41: warning: already initialized constant MULTI_KEYS

Anyone else seeing this?

activerecord.errors.template.header is ignored (Validation error message header not translated)

Here are the steps to reproduce the problem:

$ rails new test_localisation
$ cd test_localisation/
$ rails generate scaffold User name:string
$ rake db:migrate

Edit user.rb:

class User < ActiveRecord::Base
  validates_presence_of :name
end

Edit en.yml (copy and paste from https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en-US.yml):

en:
  errors:
    format: "%{attribute} %{message}"

    messages: &errors_messages
      blank: "can't be blank"

  activerecord:
    errors:
      template:
        header:
          one:    "1error prohibited this %{model} from being saved"
          other:  "%{count} errors prohibited this %{model} from being saved"
        body: "There were problems with the following fields:"

      messages:
        record_invalid: "Validation failed: %{errors}"
        <<: *errors_messages

      full_messages:
        format: "%{attribute} %{message}"

Start the server:

$ rails s

Go to http://localhost:3000/users/new and submit the empty form.
Do the same after changing activerecord.errors.template.header translation.
There is no effect, the translation is not used in rendering the header of the error messages.
(However, .messages.blank translation is used.)

I observed this problem when my French localization did not translate the header of the error messages.

Thank you.

Alexey.

Thor tasks not working

Hi Sven, the thor tasks seems not to work on my env:

[paolo@winkle:~/prj/abc] $ thor locales:test_all
/Library/Ruby/Gems/1.8/gems/thor-0.14.6/lib/thor/runner.rb:34:in method_missing': undefined methodstart' for nil:NilClass (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:in send' from /Library/Ruby/Gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:inrun'
from /Library/Ruby/Gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:108:in run' from /Library/Ruby/Gems/1.8/gems/thor-0.14.6/lib/thor/invocation.rb:118:ininvoke_task'
from /Library/Ruby/Gems/1.8/gems/thor-0.14.6/lib/thor.rb:263:in dispatch' from /Library/Ruby/Gems/1.8/gems/thor-0.14.6/lib/thor/base.rb:389:instart'
from /Library/Ruby/Gems/1.8/gems/thor-0.14.6/bin/thor:6
from /usr/bin/thor:19:in `load'
from /usr/bin/thor:19

I'm running on:
Rails 2.3.5
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Thor 0.14.6

-- not sure exactly how to fix the problem or work around it.. any clues?

No en-GB

There doesn't appear to be a en-GB translation? If nothing else this is difficult for the £ to $ difference which is used within NumberSupport.

Invalid mn YAML in 0.6.0

When I updated the gem to 0.6.0 I got the following error:

/Users/Simon/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych.rb:154:in `parse': (/Users/Simon/.rvm/gems/ruby-1.9.3-p0/gems/rails-i18n-0.6.0/lib/rails_i18n/../../rails/locale/mn.yml): couldn't parse YAML at line 125 column 11 (Psych::SyntaxError)

Downgraded to 0.5.2 and it went away again. I guess there's something wrong with the new mn localisation file.

Travis doesn't build rails-i18n

I don't know why, documentation says that even travis.yml is invalid, it defaults to Ruby. So maybe something regarding administration rights?

%{count} errors prohibited this %{model} from being saved:

Hi,

I use your translation for multi-language application RoR. I've generated a scaffold. During the validation of model. I have a partial content translate in my language but it stays a part in english ?

I'm looked the sentence and I can't find in the fr.yml.

Exemple (we can see that the first line is not translated)

5 errors prohibited this client from being saved:

  • Le XXX doit être rempli(e)
  • Le XXX doit être rempli(e)
  • Le XXX doit être rempli(e)
  • Le XXX n'est pas valide
  • Le XXX n'est pas valide

Wrong decimal_units for rails/locale/is.yml

million: milljón should be
million:
one:
milljón
other:
milljónir

billion: billjón should be
billion:
one:
milliarður
other:
milliarðar

trillion: trilljón should be
trillion:
one:
billjón
other:
billjónir

quadrillion: grasilljón should be
quadrillion:
one:
billjarður
other:
billjarðar

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.