rails-i18n 0.4.0 → 0.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/lib/rails_i18n/common_pluralizations/east_slavic.rb +35 -0
- data/lib/rails_i18n/common_pluralizations/one_two_other.rb +30 -0
- data/lib/rails_i18n/common_pluralizations/one_upto_two_other.rb +19 -0
- data/lib/rails_i18n/common_pluralizations/one_with_zero_other.rb +20 -0
- data/lib/rails_i18n/common_pluralizations/other.rb +17 -0
- data/lib/rails_i18n/common_pluralizations/romanian.rb +27 -0
- data/lib/rails_i18n/common_pluralizations/west_slavic.rb +27 -0
- data/lib/rails_i18n/railtie.rb +18 -5
- data/rails/locale/ja.yml +1 -1
- data/rails/pluralization/ak.rb +3 -0
- data/rails/pluralization/am.rb +3 -0
- data/rails/pluralization/ar.rb +31 -0
- data/rails/pluralization/az.rb +3 -0
- data/rails/pluralization/be.rb +3 -0
- data/rails/pluralization/bh.rb +3 -0
- data/rails/pluralization/bm.rb +3 -0
- data/rails/pluralization/bo.rb +3 -0
- data/rails/pluralization/br.rb +30 -0
- data/rails/pluralization/bs.rb +3 -0
- data/rails/pluralization/cs.rb +3 -0
- data/rails/pluralization/cy.rb +24 -0
- data/rails/pluralization/dz.rb +3 -0
- data/rails/pluralization/fa.rb +3 -0
- data/rails/pluralization/ff.rb +3 -0
- data/rails/pluralization/fil.rb +3 -0
- data/rails/pluralization/fr.rb +3 -0
- data/rails/pluralization/ga.rb +27 -0
- data/rails/pluralization/gd.rb +25 -0
- data/rails/pluralization/guw.rb +3 -0
- data/rails/pluralization/gv.rb +21 -0
- data/rails/pluralization/hi.rb +3 -0
- data/rails/pluralization/hr.rb +3 -0
- data/rails/pluralization/hu.rb +3 -0
- data/rails/pluralization/id.rb +3 -0
- data/rails/pluralization/ig.rb +3 -0
- data/rails/pluralization/ii.rb +3 -0
- data/rails/pluralization/iu.rb +3 -0
- data/rails/pluralization/ja.rb +3 -0
- data/rails/pluralization/jv.rb +3 -0
- data/rails/pluralization/ka.rb +3 -0
- data/rails/pluralization/kab.rb +3 -0
- data/rails/pluralization/kde.rb +3 -0
- data/rails/pluralization/kea.rb +3 -0
- data/rails/pluralization/km.rb +3 -0
- data/rails/pluralization/kn.rb +3 -0
- data/rails/pluralization/ko.rb +3 -0
- data/rails/pluralization/ksh.rb +23 -0
- data/rails/pluralization/kw.rb +3 -0
- data/rails/pluralization/lag.rb +23 -0
- data/rails/pluralization/ln.rb +3 -0
- data/rails/pluralization/lo.rb +3 -0
- data/rails/pluralization/lt.rb +26 -0
- data/rails/pluralization/lv.rb +23 -0
- data/rails/pluralization/mg.rb +3 -0
- data/rails/pluralization/mk.rb +21 -0
- data/rails/pluralization/mo.rb +3 -0
- data/rails/pluralization/ms.rb +3 -0
- data/rails/pluralization/mt.rb +27 -0
- data/rails/pluralization/my.rb +3 -0
- data/rails/pluralization/naq.rb +3 -0
- data/rails/pluralization/nso.rb +3 -0
- data/rails/pluralization/pl.rb +28 -0
- data/rails/pluralization/ro.rb +3 -0
- data/rails/pluralization/root.rb +3 -0
- data/rails/pluralization/ru.rb +3 -0
- data/rails/pluralization/sah.rb +3 -0
- data/rails/pluralization/se.rb +3 -0
- data/rails/pluralization/ses.rb +3 -0
- data/rails/pluralization/sg.rb +3 -0
- data/rails/pluralization/sh.rb +3 -0
- data/rails/pluralization/shi.rb +3 -0
- data/rails/pluralization/sk.rb +3 -0
- data/rails/pluralization/sl.rb +27 -0
- data/rails/pluralization/sma.rb +3 -0
- data/rails/pluralization/smi.rb +3 -0
- data/rails/pluralization/smj.rb +3 -0
- data/rails/pluralization/smn.rb +3 -0
- data/rails/pluralization/sms.rb +3 -0
- data/rails/pluralization/sr.rb +3 -0
- data/rails/pluralization/th.rb +3 -0
- data/rails/pluralization/ti.rb +3 -0
- data/rails/pluralization/tl.rb +3 -0
- data/rails/pluralization/to.rb +3 -0
- data/rails/pluralization/tr.rb +3 -0
- data/rails/pluralization/tzm.rb +21 -0
- data/rails/pluralization/uk.rb +3 -0
- data/rails/pluralization/vi.rb +3 -0
- data/rails/pluralization/wa.rb +3 -0
- data/rails/pluralization/wo.rb +3 -0
- data/rails/pluralization/yo.rb +3 -0
- data/rails/pluralization/zh.rb +3 -0
- data/rails/transliteration/bg.yml +64 -0
- data/rails/transliteration/ru.rb +72 -0
- metadata +107 -24
- data/will_paginate/bg.yml +0 -4
- data/will_paginate/en-GB.yml +0 -18
- data/will_paginate/en-US.yml +0 -18
- data/will_paginate/hu.yml +0 -5
- data/will_paginate/ja.yml +0 -18
- data/will_paginate/nl.yml +0 -5
- data/will_paginate/ro.yml +0 -4
- data/will_paginate/sk.yml +0 -19
data/README.md
CHANGED
@@ -118,6 +118,11 @@ If you are ready, push the repository into the Github and send us a pull request
|
|
118
118
|
|
119
119
|
We will do the formality check and publish it as quick as we can.
|
120
120
|
|
121
|
+
## See also
|
122
|
+
|
123
|
+
* [devise-i18n](https://github.com/tigrish/devise-i18n)
|
124
|
+
* [will-paginate-i18n](https://github.com/tigrish/will-paginate-i18n)
|
125
|
+
|
121
126
|
## License
|
122
127
|
|
123
128
|
[MIT](https://github.com/svenfuchs/rails-i18n/blob/master/MIT-LICENSE.txt)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Originally was implemented by Yaroslav Markin in "russian" gem
|
2
|
+
# (http://github.com/yaroslav/russian)
|
3
|
+
#
|
4
|
+
# Used for Belarusian, Bosnian, Croatian, Russian, Serbian, Serbo-Croatian, Ukrainian.
|
5
|
+
|
6
|
+
module RailsI18n
|
7
|
+
module Pluralization
|
8
|
+
module EastSlavic
|
9
|
+
def self.rule
|
10
|
+
lambda do |n|
|
11
|
+
mod10 = n % 10
|
12
|
+
mod100 = n % 100
|
13
|
+
|
14
|
+
if mod10 == 1 && mod100 != 11
|
15
|
+
:one
|
16
|
+
elsif [2, 3, 4].include?(mod10) && ![12, 13, 14].include?(mod100)
|
17
|
+
:few
|
18
|
+
elsif mod10 == 0 || (5..9).to_a.include?(mod10) || (11..14).to_a.include?(mod100)
|
19
|
+
:many
|
20
|
+
else
|
21
|
+
:other
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.with_locale(locale)
|
27
|
+
{ locale => {
|
28
|
+
:'i18n' => {
|
29
|
+
:plural => {
|
30
|
+
:keys => [:one, :few, :many, :other],
|
31
|
+
:rule => rule }}}}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Used for Cornish, Inari Sami, Inuktitut, Lule Sami, Nama, Northern Sami,
|
2
|
+
# Sami Language, Skolt Sami, Southern Sami.
|
3
|
+
|
4
|
+
module RailsI18n
|
5
|
+
module Pluralization
|
6
|
+
module OneTwoOther
|
7
|
+
def self.rule
|
8
|
+
def self.rule
|
9
|
+
lambda do |n|
|
10
|
+
if n == 1
|
11
|
+
:one
|
12
|
+
elsif n == 2
|
13
|
+
:two
|
14
|
+
else
|
15
|
+
:other
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.with_locale(locale)
|
22
|
+
{ locale => {
|
23
|
+
:'i18n' => {
|
24
|
+
:plural => {
|
25
|
+
:keys => [:one, :two, :other],
|
26
|
+
:rule => rule }}}}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Used for French, Fulah, Kabyle.
|
2
|
+
|
3
|
+
module RailsI18n
|
4
|
+
module Pluralization
|
5
|
+
module OneUptoTwoOther
|
6
|
+
def self.rule
|
7
|
+
lambda { |n| (0...2).cover?(n) ? :one : :other }
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.with_locale(locale)
|
11
|
+
{ locale => {
|
12
|
+
:'i18n' => {
|
13
|
+
:plural => {
|
14
|
+
:keys => [:one, :other],
|
15
|
+
:rule => rule }}}}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Used in Akan, Amharic, Bihari, Filipino, guw, Hindi, Lingala, Malagasy,
|
2
|
+
# Northen Sotho, Tachelhit, Tagalog, Tigrinya, Walloon.
|
3
|
+
|
4
|
+
module RailsI18n
|
5
|
+
module Pluralization
|
6
|
+
module OneWithZeroOther
|
7
|
+
def self.rule
|
8
|
+
lambda { |n| n == 0 || n == 1 ? :one : :other }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.with_locale(locale)
|
12
|
+
{ locale => {
|
13
|
+
:'i18n' => {
|
14
|
+
:plural => {
|
15
|
+
:keys => [:one, :other],
|
16
|
+
:rule => rule }}}}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RailsI18n
|
2
|
+
module Pluralization
|
3
|
+
module Other
|
4
|
+
def self.rule
|
5
|
+
Proc.new { :other }
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.with_locale(locale)
|
9
|
+
{ locale => {
|
10
|
+
:'i18n' => {
|
11
|
+
:plural => {
|
12
|
+
:keys => [:other],
|
13
|
+
:rule => rule }}}}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Used for Moldavian, Romanian.
|
2
|
+
|
3
|
+
module RailsI18n
|
4
|
+
module Pluralization
|
5
|
+
module Romanian
|
6
|
+
def self.rule
|
7
|
+
lambda do |n|
|
8
|
+
if n == 1
|
9
|
+
:one
|
10
|
+
elsif n == 0 || (1..19).to_a.include?(n % 100)
|
11
|
+
:few
|
12
|
+
else
|
13
|
+
:other
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.with_locale(locale)
|
19
|
+
{ locale => {
|
20
|
+
:'i18n' => {
|
21
|
+
:plural => {
|
22
|
+
:keys => [:one, :few, :other],
|
23
|
+
:rule => rule }}}}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Used for Czech, Slovak.
|
2
|
+
|
3
|
+
module RailsI18n
|
4
|
+
module Pluralization
|
5
|
+
module WestSlavic
|
6
|
+
def self.rule
|
7
|
+
lambda do |n|
|
8
|
+
if n == 1
|
9
|
+
:one
|
10
|
+
elsif [2, 3, 4].include?(n)
|
11
|
+
:few
|
12
|
+
else
|
13
|
+
:other
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.with_locale(locale)
|
19
|
+
{ locale => {
|
20
|
+
:'i18n' => {
|
21
|
+
:plural => {
|
22
|
+
:keys => [:one, :few, :other],
|
23
|
+
:rule => rule }}}}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/rails_i18n/railtie.rb
CHANGED
@@ -2,12 +2,25 @@ require 'rails'
|
|
2
2
|
|
3
3
|
module RailsI18n
|
4
4
|
class Railtie < ::Rails::Railtie #:nodoc:
|
5
|
-
initializer 'rails-i18n' do
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
initializer 'rails-i18n' do
|
6
|
+
RailsI18n::Railtie.instance_eval do
|
7
|
+
add('rails/locale/*.yml')
|
8
|
+
add('rails/pluralization/*.rb')
|
9
|
+
add('rails/transliteration/*.{rb,yml}')
|
10
|
+
|
11
|
+
init_pluralization_module
|
9
12
|
end
|
10
|
-
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def self.add(pattern)
|
18
|
+
files = Dir[File.join(File.dirname(__FILE__), '../..', pattern)]
|
19
|
+
I18n.load_path.concat(files)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.init_pluralization_module
|
23
|
+
I18n.backend.class.send(:include, I18n::Backend::Pluralization)
|
11
24
|
end
|
12
25
|
end
|
13
26
|
end
|
data/rails/locale/ja.yml
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
module RailsI18n
|
2
|
+
module Pluralization
|
3
|
+
module Arabic
|
4
|
+
def self.rule
|
5
|
+
lambda do |n|
|
6
|
+
mod100 = n % 100
|
7
|
+
|
8
|
+
if n == 0
|
9
|
+
:zero
|
10
|
+
elsif n == 1
|
11
|
+
:one
|
12
|
+
elsif n == 2
|
13
|
+
:two
|
14
|
+
elsif (3..10).to_a.include?(mod100)
|
15
|
+
:few
|
16
|
+
elsif (11..99).to_a.include?(mod100)
|
17
|
+
:many
|
18
|
+
else
|
19
|
+
:other
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
{ :ar => {
|
28
|
+
:'i18n' => {
|
29
|
+
:plural => {
|
30
|
+
:keys => [:zero, :one, :two, :few, :many, :other],
|
31
|
+
:rule => RailsI18n::Pluralization::Arabic.rule }}}}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RailsI18n
|
2
|
+
module Pluralization
|
3
|
+
module Breton
|
4
|
+
def self.rule
|
5
|
+
lambda do |n|
|
6
|
+
mod10 = n % 10
|
7
|
+
mod100 = n % 100
|
8
|
+
|
9
|
+
if mod10 == 1 && ![11,71,91].include?(mod100)
|
10
|
+
:one
|
11
|
+
elsif mod10 == 2 && ![12,72,92].include?(mod100)
|
12
|
+
:two
|
13
|
+
elsif [3,4,9].include?(mod10) && !((10..19).to_a + (70..79).to_a + (90..99).to_a).include?(mod100)
|
14
|
+
:few
|
15
|
+
elsif n % 1000000 == 0 && n != 0
|
16
|
+
:many
|
17
|
+
else
|
18
|
+
:other
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
{ :br => {
|
27
|
+
:'i18n' => {
|
28
|
+
:plural => {
|
29
|
+
:keys => [:one, :two, :few, :many, :other],
|
30
|
+
:rule => RailsI18n::Pluralization::Breton.rule }}}}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RailsI18n
|
2
|
+
module Pluralization
|
3
|
+
module Welsh
|
4
|
+
def self.rule
|
5
|
+
lambda do |n|
|
6
|
+
case n
|
7
|
+
when 0 then :zero
|
8
|
+
when 1 then :one
|
9
|
+
when 2 then :two
|
10
|
+
when 3 then :few
|
11
|
+
when 6 then :many
|
12
|
+
else :other
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
{ :cy => {
|
21
|
+
:'i18n' => {
|
22
|
+
:plural => {
|
23
|
+
:keys => [:zero, :one, :two, :few, :many, :other],
|
24
|
+
:rule => RailsI18n::Pluralization::Welsh.rule }}}}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RailsI18n
|
2
|
+
module Pluralization
|
3
|
+
module Irish
|
4
|
+
def self.rule
|
5
|
+
lambda do |n|
|
6
|
+
if n == 1
|
7
|
+
:one
|
8
|
+
elsif n == 2
|
9
|
+
:two
|
10
|
+
elsif (3..6).to_a.include?(n)
|
11
|
+
:few
|
12
|
+
elsif (7..10).to_a.include?(n)
|
13
|
+
:many
|
14
|
+
else
|
15
|
+
:other
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
{ :ga => {
|
24
|
+
:'i18n' => {
|
25
|
+
:plural => {
|
26
|
+
:keys => [:one, :two, :few, :many, :other],
|
27
|
+
:rule => RailsI18n::Pluralization::Irish.rule }}}}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RailsI18n
|
2
|
+
module Pluralization
|
3
|
+
module ScottishGaelic
|
4
|
+
def self.rule
|
5
|
+
lambda do |n|
|
6
|
+
if n == 1 || n == 11
|
7
|
+
:one
|
8
|
+
elsif n == 2 || n == 12
|
9
|
+
:two
|
10
|
+
elsif ((3..10).to_a + (13..19).to_a).include?(n)
|
11
|
+
:few
|
12
|
+
else
|
13
|
+
:other
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
{ :gd => {
|
22
|
+
:'i18n' => {
|
23
|
+
:plural => {
|
24
|
+
:keys => [:one, :two, :few, :other],
|
25
|
+
:rule => RailsI18n::Pluralization::ScottishGaelic.rule }}}}
|