-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
556 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
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 was deleted.
Oops, something went wrong.
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,30 +1,14 @@ | |||
require 'rubygems' | require 'rubygems' | ||
require 'i18n' | require 'i18n' | ||
require 'initializers/i18n' | require 'i18n/backend/pluralization' | ||
require 'active_support/inflector' | require 'active_support/inflector' | ||
|
|
||
require 'numbers_and_words/version' | |||
|
|||
require 'numbers_and_words/translations_helpers' | require 'numbers_and_words/translations_helpers' | ||
require 'numbers_and_words/strategies' | require 'numbers_and_words/strategies' | ||
require 'numbers_and_words/array_additions' | require 'numbers_and_words/array_additions' | ||
require 'numbers_and_words/figures_array' | require 'numbers_and_words/figures_array' | ||
require 'numbers_and_words/core_ext' | |||
require 'numbers_and_words/i18n' | |||
require 'numbers_and_words/version' | |||
|
|
||
require 'numbers_and_words/core_ext/integer' | NumbersAndWords::I18n::Initialization.init | ||
require 'numbers_and_words/core_ext/array' | |||
|
|||
module NumbersAndWords | |||
module I18nInitialization | |||
extend self | |||
|
|||
def init | |||
locale_files.each { |locale_file| I18n.load_path << locale_file } | |||
end | |||
|
|||
def locale_files | |||
Dir[File.join(File.dirname(__FILE__), 'locales', '**/*')] | |||
end | |||
end | |||
end | |||
|
|||
NumbersAndWords::I18nInitialization.init |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
require 'numbers_and_words/core_ext/integer' | |||
require 'numbers_and_words/core_ext/array' |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
require 'numbers_and_words/i18n/pluralization' | |||
require 'numbers_and_words/i18n/initialization' | |||
|
|||
module NumbersAndWords | |||
module I18n | |||
extend self | |||
|
|||
def files directory, ext | |||
Dir[File.join File.dirname(__FILE__), "i18n/#{directory}", "**/#{ext}"] | |||
end | |||
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
module NumbersAndWords | |||
module I18n | |||
module Initialization | |||
extend self | |||
|
|||
def init | |||
locale_files.each { |locale_file| ::I18n.load_path << locale_file} | |||
NumbersAndWords::I18n::Pluralization.init | |||
end | |||
|
|||
private | |||
|
|||
def locale_files | |||
I18n.files 'locales', '*.*' | |||
end | |||
|
|||
def languages | |||
locale_files.map{|path| path.split /[\/.]/}[-2] | |||
end | |||
end | |||
end | |||
end |
File renamed without changes.
File renamed without changes.
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
tr: | |||
numbers: | |||
ones: [sıfır, bir, iki, üç, dört, beş, altı, yedi, sekiz, dokuz] | |||
teens: ['on', on bir, on iki, on üç, on dört, on beş, on altı, on yedi, on sekiz, on dokuz] | |||
tens: [sıfır, 'on', yirmi, otuz, kırk, elli, altmış, yetmiş, seksen, doksan] | |||
hundreds: yüz | |||
mega: [bir, bin, milyon, milyar, trilyon, katrilyon, kentilyon, seksilyon, septilyon, oktilyon, nonilyon, desilyon] |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,52 @@ | |||
ua: | |||
numbers: | |||
ones_male: [нуль, один, два, три, чотири, п’ять, шiсть, сiм, вiсiм, дев’ять] | |||
ones_female: [нуль, однa, двi, три, чотири, п’ять, шiсть, сiм, вiсiм, дев’ять] | |||
teens: [десять, одинадцять, дванадцять, тринадцять, чотирнадцять, п’ятнадцять, шiстнадцять, сiмнадцять, вiсiмнадцять, дев’ятнадцять] | |||
tens: [нуль, десять, двадцять, тридцять, сорок, п’ятдесят, шiстдесят, сiмдесят, вiсiмдесят, дев’яносто] | |||
hundreds: [нуль, сто, двiстi, триста, чотириста, п’ятсот, шiстсот, сiмсот, вiсiмсот, дев’ятсот] | |||
thousands: | |||
one: тисяча | |||
few: тисячi | |||
many: тисяч | |||
millions: | |||
one: мiльйон | |||
few: мiльйона | |||
many: мiльйонiв | |||
billions: | |||
one: мiльярд | |||
few: мiльярда | |||
many: мiльярдiв | |||
trillions: | |||
one: трильйон | |||
few: трильйона | |||
many: трильйонiв | |||
quadrillions: | |||
one: квадрильйон | |||
few: квадрильйона | |||
many: квадрильйонiв | |||
quintillions: | |||
one: квiнтильйон | |||
few: квiнтильйона | |||
many: квiнтильйонiв | |||
sextillions: | |||
one: секстильйон | |||
few: секстильйона | |||
many: секстильйонiв | |||
septillions: | |||
one: септильйон | |||
few: септильйона | |||
many: септильйонiв | |||
octillions: | |||
one: октильйон | |||
few: октильйона | |||
many: октильйонiв | |||
nonillions: | |||
one: нонильйон | |||
few: нонильйона | |||
many: нонильйонiв | |||
decillions: | |||
one: децильйон | |||
few: децильйона | |||
many: децильйонiв | |||
mega: [ones, thousands, millions, billions, trillions, quadrillions, quintillion, sextillions, septillions, octillions, nonillions, decillions] |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
require 'numbers_and_words/i18n/plurals/ru' | |||
require 'numbers_and_words/i18n/plurals/ua' | |||
|
|||
module NumbersAndWords | |||
module I18n | |||
module Pluralization | |||
extend self | |||
|
|||
def init | |||
::I18n.load_path << config_file | |||
::I18n::Backend::Simple.send :include, ::I18n::Backend::Pluralization | |||
end | |||
|
|||
def files | |||
I18n.files 'plurals', '*.*' | |||
end | |||
|
|||
def config_file | |||
I18n.files('plurals', 'plurals.rb').first | |||
end | |||
|
|||
def plurals_files | |||
files - [config_file] | |||
end | |||
|
|||
def languages | |||
plurals_files.map{|path| path.split(/[\/.]/)[-2]} | |||
end | |||
end | |||
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
Hash[ | |||
NumbersAndWords::I18n::Pluralization.languages.map { |language| | |||
[language.to_sym, {:i18n => {:plural => { | |||
:rule => "NumbersAndWords::I18n::Plurals::#{language.titleize}::RULE".constantize | |||
}}}] | |||
} | |||
] |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
module NumbersAndWords | |||
module I18n | |||
module Plurals | |||
module Ru | |||
RULE = lambda do |n| | |||
one_conditions(n) ? | |||
:one : few_conditions(n) ? | |||
:few : many_conditions(n) ? | |||
:many : :other | |||
end | |||
|
|||
extend self | |||
|
|||
def one_conditions n | |||
n % 10 == 1 && n % 100 != 11 | |||
end | |||
|
|||
def few_conditions n | |||
[2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) | |||
end | |||
|
|||
def many_conditions n | |||
n % 10 == 0 || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100) | |||
end | |||
end | |||
end | |||
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
module NumbersAndWords | |||
module I18n | |||
module Plurals | |||
module Ua | |||
RULE = Ru::RULE | |||
end | |||
end | |||
end | |||
end |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,5 @@ | |||
require 'numbers_and_words/strategies/base' | require 'numbers_and_words/strategies/base' | ||
require 'numbers_and_words/strategies/ru' | require 'numbers_and_words/strategies/ru' | ||
require 'numbers_and_words/strategies/en' | require 'numbers_and_words/strategies/en' | ||
require 'numbers_and_words/strategies/ua' | |||
require 'numbers_and_words/strategies/tr' |
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
Oops, something went wrong.