polish 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +14 -0
- data/README.md +9 -10
- data/Rakefile +25 -46
- data/VERSION +1 -0
- data/lib/polish.rb +5 -64
- data/lib/polish/locale/actionview.yml +5 -1
- data/lib/polish/locale/activerecord.yml +6 -1
- data/lib/polish/locale/datetime.rb +44 -0
- data/lib/polish/locale/datetime.yml +6 -15
- data/lib/polish/locale/pluralize.rb +16 -11
- data/lib/polish/proxies.rb +45 -0
- data/lib/proxies.rb +2 -0
- data/polish.gemspec +75 -0
- data/rails/init.rb +1 -0
- data/spec/fixtures/en.yml +2 -1
- data/spec/i18n/locale/datetime_spec.rb +30 -13
- data/spec/locale_spec.rb +23 -10
- data/spec/polish_spec.rb +11 -59
- data/spec/proxies_spec.rb +66 -0
- data/spec/spec_helper.rb +2 -0
- metadata +44 -79
- data/init.rb +0 -1
- data/lib/polish/backend/advanced.rb +0 -107
- data/lib/vendor/i18n/CHANGELOG.textile +0 -57
- data/lib/vendor/i18n/MIT-LICENSE +0 -20
- data/lib/vendor/i18n/README.textile +0 -42
- data/lib/vendor/i18n/Rakefile +0 -21
- data/lib/vendor/i18n/VERSION +0 -1
- data/lib/vendor/i18n/i18n.gemspec +0 -141
- data/lib/vendor/i18n/lib/i18n.rb +0 -270
- data/lib/vendor/i18n/lib/i18n/backend/base.rb +0 -251
- data/lib/vendor/i18n/lib/i18n/backend/cache.rb +0 -71
- data/lib/vendor/i18n/lib/i18n/backend/chain.rb +0 -64
- data/lib/vendor/i18n/lib/i18n/backend/fallbacks.rb +0 -53
- data/lib/vendor/i18n/lib/i18n/backend/gettext.rb +0 -65
- data/lib/vendor/i18n/lib/i18n/backend/pluralization.rb +0 -56
- data/lib/vendor/i18n/lib/i18n/backend/simple.rb +0 -23
- data/lib/vendor/i18n/lib/i18n/exceptions.rb +0 -61
- data/lib/vendor/i18n/lib/i18n/gettext.rb +0 -25
- data/lib/vendor/i18n/lib/i18n/helpers/gettext.rb +0 -35
- data/lib/vendor/i18n/lib/i18n/locale/fallbacks.rb +0 -100
- data/lib/vendor/i18n/lib/i18n/locale/tag.rb +0 -27
- data/lib/vendor/i18n/lib/i18n/locale/tag/parents.rb +0 -24
- data/lib/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb +0 -78
- data/lib/vendor/i18n/lib/i18n/locale/tag/simple.rb +0 -44
- data/lib/vendor/i18n/lib/i18n/string.rb +0 -95
- data/lib/vendor/i18n/test/all.rb +0 -5
- data/lib/vendor/i18n/test/api/basics.rb +0 -15
- data/lib/vendor/i18n/test/api/interpolation.rb +0 -85
- data/lib/vendor/i18n/test/api/lambda.rb +0 -52
- data/lib/vendor/i18n/test/api/link.rb +0 -47
- data/lib/vendor/i18n/test/api/localization/date.rb +0 -65
- data/lib/vendor/i18n/test/api/localization/date_time.rb +0 -63
- data/lib/vendor/i18n/test/api/localization/lambda.rb +0 -26
- data/lib/vendor/i18n/test/api/localization/time.rb +0 -63
- data/lib/vendor/i18n/test/api/pluralization.rb +0 -37
- data/lib/vendor/i18n/test/api/translation.rb +0 -51
- data/lib/vendor/i18n/test/backend/cache/cache_test.rb +0 -57
- data/lib/vendor/i18n/test/backend/chain/api_test.rb +0 -80
- data/lib/vendor/i18n/test/backend/chain/chain_test.rb +0 -64
- data/lib/vendor/i18n/test/backend/fallbacks/api_test.rb +0 -79
- data/lib/vendor/i18n/test/backend/fallbacks/fallbacks_test.rb +0 -29
- data/lib/vendor/i18n/test/backend/pluralization/api_test.rb +0 -81
- data/lib/vendor/i18n/test/backend/pluralization/pluralization_test.rb +0 -39
- data/lib/vendor/i18n/test/backend/simple/all.rb +0 -5
- data/lib/vendor/i18n/test/backend/simple/api_test.rb +0 -90
- data/lib/vendor/i18n/test/backend/simple/lookup_test.rb +0 -24
- data/lib/vendor/i18n/test/backend/simple/setup.rb +0 -147
- data/lib/vendor/i18n/test/backend/simple/translations_test.rb +0 -89
- data/lib/vendor/i18n/test/fixtures/locales/de.po +0 -61
- data/lib/vendor/i18n/test/fixtures/locales/en.rb +0 -3
- data/lib/vendor/i18n/test/fixtures/locales/en.yml +0 -3
- data/lib/vendor/i18n/test/fixtures/locales/plurals.rb +0 -112
- data/lib/vendor/i18n/test/gettext/api_test.rb +0 -78
- data/lib/vendor/i18n/test/gettext/backend_test.rb +0 -35
- data/lib/vendor/i18n/test/i18n_exceptions_test.rb +0 -97
- data/lib/vendor/i18n/test/i18n_load_path_test.rb +0 -23
- data/lib/vendor/i18n/test/i18n_test.rb +0 -163
- data/lib/vendor/i18n/test/locale/fallbacks_test.rb +0 -128
- data/lib/vendor/i18n/test/locale/tag/rfc4646_test.rb +0 -147
- data/lib/vendor/i18n/test/locale/tag/simple_test.rb +0 -35
- data/lib/vendor/i18n/test/string_test.rb +0 -94
- data/lib/vendor/i18n/test/test_helper.rb +0 -71
- data/lib/vendor/i18n/test/with_options.rb +0 -34
- data/lib/vendor/i18n/vendor/po_parser.rb +0 -329
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -8,23 +8,22 @@ Based on [Russian](http://github.com/yaroslav/russian/) by [yaroslav](http://git
|
|
8
8
|
|
9
9
|
Install
|
10
10
|
-------
|
11
|
-
|
11
|
+
*Warning*: as of version 0.1.0, polish is only tested with Rails 3 and Bundler. Use with caution, might give unexpected results.
|
12
12
|
|
13
|
-
|
13
|
+
To add Polish to your Rails app, simply add it to your Gemfile:
|
14
14
|
|
15
|
-
|
16
|
-
config.gem 'polish', :source => 'http://gemcutter.org'
|
17
|
-
end
|
15
|
+
gem "polish", ">= 0.1.0"
|
18
16
|
|
19
|
-
|
20
|
-
rake gems:install
|
17
|
+
Additionally, if you change the backend of I18n, you will need to make sure it includes the Pluralization module:
|
21
18
|
|
19
|
+
I18n.backend.class.send(:include, I18n::Backend::Pluralization)
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
script/plugin install git://github.com/grk/polish.git
|
21
|
+
What it does
|
22
|
+
------------
|
26
23
|
|
24
|
+
The main feature of polish is fixing the date formats. It does that by setting the date.month\_names and date.day\_names translations to Procs that can detect the proper form.
|
27
25
|
|
26
|
+
Polish also adds correct pluralization rules.
|
28
27
|
|
29
28
|
Overrides
|
30
29
|
---------
|
data/Rakefile
CHANGED
@@ -1,40 +1,30 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
AUTHOR = "Grzesiek Kolodziejczyk"
|
11
|
-
EMAIL = "gkolodziejczyk@gmail.com"
|
12
|
-
HOMEPAGE = "http://github.com/grk/polish/"
|
13
|
-
SUMMARY = "Polish language support for Ruby and Rails"
|
14
|
-
|
15
|
-
spec = Gem::Specification.new do |s|
|
16
|
-
s.name = GEM
|
17
|
-
s.version = GEM_VERSION
|
18
|
-
s.platform = Gem::Platform::RUBY
|
19
|
-
s.has_rdoc = true
|
20
|
-
s.extra_rdoc_files = ["README.md", "LICENSE", "TODO"]
|
21
|
-
s.summary = SUMMARY
|
22
|
-
s.description = s.summary
|
23
|
-
s.author = AUTHOR
|
24
|
-
s.email = EMAIL
|
25
|
-
s.homepage = HOMEPAGE
|
26
|
-
|
27
|
-
# Uncomment this to add a dependency
|
28
|
-
# s.add_dependency "foo"
|
29
|
-
|
30
|
-
s.require_path = 'lib'
|
31
|
-
s.autorequire = GEM
|
32
|
-
s.files = %w(LICENSE README.md Rakefile TODO init.rb) + Dir.glob("{lib,spec}/**/*")
|
1
|
+
require 'rake'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:runtime, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
33
10
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift('lib')
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gemspec|
|
16
|
+
gemspec.name = "polish"
|
17
|
+
gemspec.summary = "Polish language support for Ruby and Rails"
|
18
|
+
gemspec.email = "gkolodziejczyk@gmail.com"
|
19
|
+
gemspec.homepage = "http://github.com/grk/polish"
|
20
|
+
gemspec.authors = ["Grzesiek Kolodziejczyk"]
|
21
|
+
|
22
|
+
gemspec.add_dependency("i18n", ">= 0.3.3")
|
37
23
|
end
|
24
|
+
|
25
|
+
Jeweler::GemcutterTasks.new
|
26
|
+
|
27
|
+
require 'spec/rake/spectask'
|
38
28
|
|
39
29
|
task :default => :spec
|
40
30
|
desc "Run specs"
|
@@ -43,14 +33,3 @@ Spec::Rake::SpecTask.new do |t|
|
|
43
33
|
t.spec_opts = %w(-fs --color)
|
44
34
|
end
|
45
35
|
|
46
|
-
desc "install the gem locally"
|
47
|
-
task :install => [:package] do
|
48
|
-
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "create a gemspec file"
|
52
|
-
task :make_spec do
|
53
|
-
File.open("#{GEM}.gemspec", "w") do |file|
|
54
|
-
file.puts spec.to_ruby
|
55
|
-
end
|
56
|
-
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/polish.rb
CHANGED
@@ -4,32 +4,19 @@ if RUBY_VERSION < "1.9"
|
|
4
4
|
$KCODE = 'u'
|
5
5
|
end
|
6
6
|
|
7
|
-
$:.push File.join(File.dirname(__FILE__), 'polish')
|
8
|
-
|
9
|
-
# I18n require
|
10
|
-
unless defined?(I18n)
|
11
|
-
$:.push File.join(File.dirname(__FILE__), 'vendor', 'i18n', 'lib')
|
12
|
-
require 'i18n'
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
# Advanced backend
|
17
|
-
require 'backend/advanced'
|
18
|
-
|
19
7
|
# Rails hacks
|
20
8
|
if defined?(ActionView::Helpers)
|
21
9
|
require 'action_view_ext/helpers/date_helper'
|
22
10
|
end
|
11
|
+
|
12
|
+
require 'polish/proxies'
|
23
13
|
|
24
14
|
module Polish
|
25
15
|
extend self
|
26
16
|
|
27
17
|
module VERSION
|
28
|
-
|
29
|
-
MINOR =
|
30
|
-
TINY = 5
|
31
|
-
|
32
|
-
STRING = [MAJOR, MINOR, TINY].join('.')
|
18
|
+
STRING = File.open(File.dirname(__FILE__) + "/../VERSION").gets.chomp
|
19
|
+
MAJOR, MINOR, TINY = STRING.split('.')
|
33
20
|
end
|
34
21
|
|
35
22
|
# Polish locale
|
@@ -40,64 +27,18 @@ module Polish
|
|
40
27
|
LOCALE
|
41
28
|
end
|
42
29
|
|
43
|
-
# Returns custom backend class for usage with Polish library
|
44
|
-
#
|
45
|
-
# See I18n::Backend
|
46
|
-
def i18n_backend_class
|
47
|
-
I18n::Backend::Advanced
|
48
|
-
end
|
49
|
-
|
50
30
|
# Init Polish i18n: set custom backend,
|
51
31
|
# load all translations shipped with library.
|
52
32
|
def init_i18n
|
53
|
-
I18n.backend
|
33
|
+
I18n.backend.class.send(:include, I18n::Backend::Pluralization)
|
54
34
|
I18n.load_path.unshift(*locale_files)
|
55
35
|
end
|
56
|
-
|
57
|
-
# See I18n::translate
|
58
|
-
def translate(key, options = {})
|
59
|
-
I18n.translate(key, options.merge({ :locale => LOCALE }))
|
60
|
-
end
|
61
|
-
alias :t :translate
|
62
|
-
|
63
|
-
# See I18n::localize
|
64
|
-
def localize(object, options = {})
|
65
|
-
I18n.localize(object, options.merge({ :locale => LOCALE }))
|
66
|
-
end
|
67
|
-
alias :l :localize
|
68
|
-
|
69
|
-
# strftime() proxy with Polish localization
|
70
|
-
def strftime(object, format = :default)
|
71
|
-
localize(object, { :format => format })
|
72
|
-
end
|
73
|
-
|
74
|
-
# Simple pluralization proxy
|
75
|
-
#
|
76
|
-
# Usage:
|
77
|
-
# Polish.pluralize(1, "dom", "domy", "domów")
|
78
|
-
def pluralize(n, *variants)
|
79
|
-
raise ArgumentError, "Must have a Numeric as a first parameter" unless n.is_a?(Numeric)
|
80
|
-
raise ArgumentError, "Must have 3 variants for pluralization" if variants.size < 3
|
81
|
-
variants_hash = pluralization_variants_to_hash(*variants)
|
82
|
-
I18n.backend.send(:pluralize, LOCALE, variants_hash, n)
|
83
|
-
end
|
84
|
-
alias :p :pluralize
|
85
36
|
|
86
37
|
protected
|
87
38
|
# Returns all locale files shipped with library
|
88
39
|
def locale_files
|
89
40
|
Dir[File.join(File.dirname(__FILE__), "polish", "locale", "**/*")]
|
90
41
|
end
|
91
|
-
|
92
|
-
# Converts an array of pluralization variants to a Hash that can be used
|
93
|
-
# with I18n pluralization.
|
94
|
-
def pluralization_variants_to_hash(*variants)
|
95
|
-
{
|
96
|
-
:one => variants[0],
|
97
|
-
:few => variants[1],
|
98
|
-
:other => variants[2]
|
99
|
-
}
|
100
|
-
end
|
101
42
|
end
|
102
43
|
|
103
44
|
Polish.init_i18n
|
@@ -96,10 +96,14 @@ pl:
|
|
96
96
|
update: 'Aktualizuj %{model}'
|
97
97
|
submit: 'Zapisz %{model}'
|
98
98
|
|
99
|
-
|
99
|
+
activemodel:
|
100
100
|
errors:
|
101
101
|
template:
|
102
102
|
header:
|
103
103
|
one: "{{model}} nie został zachowany z powodu jednego błędu"
|
104
104
|
other: "{{model}} nie został zachowany z powodu {{count}} błędów"
|
105
105
|
body: "Błędy dotyczą następujących pól:"
|
106
|
+
|
107
|
+
attributes:
|
108
|
+
created_at: "Czas utworzenia"
|
109
|
+
updated_at: "Czas aktualizacji"
|
@@ -1,6 +1,11 @@
|
|
1
1
|
pl:
|
2
2
|
activerecord:
|
3
3
|
errors:
|
4
|
+
template:
|
5
|
+
header:
|
6
|
+
one: "{{model}} nie został zachowany z powodu jednego błędu"
|
7
|
+
other: "{{model}} nie został zachowany z powodu {{count}} błędów"
|
8
|
+
body: "Błędy dotyczą następujących pól:"
|
4
9
|
messages:
|
5
10
|
record_invalid: "Znaleziono błędy: %{errors}"
|
6
11
|
inclusion: "nie znajduje się na liście dopuszczalnych wartości"
|
@@ -19,7 +24,7 @@ pl:
|
|
19
24
|
few: "jest za krótkie (minimalnie {{count}} znaki)"
|
20
25
|
other: "jest za krótkie (minimalnie {{count}} znaków)"
|
21
26
|
wrong_length: "jest nieprawidłowej długości (powinna wynosić {{count}} znaków)"
|
22
|
-
taken: "
|
27
|
+
taken: "zostało już zajęte"
|
23
28
|
not_a_number: "nie jest liczbą"
|
24
29
|
greater_than: "musi być większe niż {{count}}"
|
25
30
|
greater_than_or_equal_to: "musi być większe lub równe {{count}}"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
{
|
4
|
+
:'pl' => {
|
5
|
+
:date => {
|
6
|
+
:month_names => lambda { |date_or_time, opts|
|
7
|
+
if opts[:format] =~ /(%d|%e)(.*)(%B)/
|
8
|
+
[nil, 'stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca',
|
9
|
+
'lipca', 'sierpnia', 'września', 'października', 'listopada',
|
10
|
+
'grudnia']
|
11
|
+
else
|
12
|
+
[nil, 'Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec',
|
13
|
+
'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad',
|
14
|
+
'Grudzień']
|
15
|
+
end
|
16
|
+
},
|
17
|
+
:abbr_month_names => lambda { |date_or_time, opts|
|
18
|
+
if opts[:format] =~ /(%d|%e)(.*)(%b)/
|
19
|
+
[nil, 'sty.', 'lut.', 'mar.', 'kwi.', 'maj.', 'cze.', 'lip.', 'sie.',
|
20
|
+
'wrz.', 'paź.', 'lis.', 'gru.']
|
21
|
+
else
|
22
|
+
[nil, 'Sty.', 'Lut.', 'Mar.', 'Kwi.', 'Maj', 'Cze.', 'Lip.', 'Sie.',
|
23
|
+
'Wrz.', 'Paź.', 'Lis.', 'Gru.']
|
24
|
+
end
|
25
|
+
},
|
26
|
+
:day_names => lambda { |date_or_time, opts|
|
27
|
+
if opts[:format] =~ /^%A/
|
28
|
+
['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek',
|
29
|
+
'Piątek', 'Sobota']
|
30
|
+
else
|
31
|
+
['niedziela', 'poniedziałek', 'wtorek', 'środa', 'czwartek',
|
32
|
+
'piątek', 'sobota']
|
33
|
+
end
|
34
|
+
},
|
35
|
+
:abbr_day_names => lambda { |date_or_time, opts|
|
36
|
+
if opts[:format] =~ /^%a/
|
37
|
+
['Niedz.', 'Pon.', 'Wt.', 'Śr.', 'Czw.', 'Pt.', 'Sob.']
|
38
|
+
else
|
39
|
+
['niedz.', 'pon.', 'wt.', 'śr.', 'czw.', 'pt.', 'sob.']
|
40
|
+
end
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
@@ -2,24 +2,15 @@ pl:
|
|
2
2
|
date:
|
3
3
|
formats:
|
4
4
|
default: "%d.%m.%Y"
|
5
|
-
short: "%
|
6
|
-
long: "%
|
5
|
+
short: "%e %b"
|
6
|
+
long: "%e %B %Y"
|
7
7
|
|
8
|
-
day_names: [niedziela, poniedziałek, wtorek, środa, czwartek, piątek, sobota]
|
9
|
-
standalone_day_names: [Niedziela, Poniedziałek, Wtorek, Środa, Czwartek, Piątek, Sobota]
|
10
|
-
abbr_day_names: [nie., pon., wto., śro., czw., pią., sob.]
|
11
|
-
standalone_abbr_day_names: [Nie., Pon., Wto., Śro., Czw., Pią., Sob.]
|
12
|
-
|
13
|
-
month_names: [~, stycznia, lutego, marca, kwietnia, maja, czerwca, lipca, sierpnia, września, października, listpoada, grudnia]
|
14
|
-
standalone_month_names: [~, Styczeń, Luty, Marzec, Kwiecień, Maj, Czerwiec, Lipiec, Sierpień, Wrzesień, Październik, Listopad, Grudzień]
|
15
|
-
abbr_month_names: [~, sty., lut., mar., kwi., maj., cze., lip., sie., wrz., paź., lis., gru.]
|
16
|
-
standalone_abbr_month_names: [~, Sty., Lut., Mar., Kwi., Maj., Cze., Lip., Sie., Wrz., Paź., Lis., Gru.]
|
17
8
|
order: [ :day, :month, :year ]
|
18
9
|
|
19
10
|
time:
|
20
11
|
formats:
|
21
|
-
default: "%a, %
|
22
|
-
short: "%
|
23
|
-
long: "%
|
12
|
+
default: "%a, %e %B %Y, %H:%M:%S"
|
13
|
+
short: "%e %b, %H:%M"
|
14
|
+
long: "%e %B %Y, %H:%M"
|
24
15
|
am: "przed południem"
|
25
|
-
pm: "po południu"
|
16
|
+
pm: "po południu"
|
@@ -1,16 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
|
3
3
|
{
|
4
4
|
:'pl' => {
|
5
|
-
:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
:i18n => {
|
6
|
+
:plural => {
|
7
|
+
:rule => lambda { |n|
|
8
|
+
# taken from http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
|
9
|
+
# TODO: check if they're really wrong about 22..24
|
10
|
+
#
|
11
|
+
# one -> n is 1;
|
12
|
+
# few -> n mod 10 in 2..4 and n mod 100 not in 12..14;
|
13
|
+
# other -> everything else
|
14
|
+
#
|
15
|
+
n == 1 ? :one : [2, 3, 4].include?(n % 10) &&
|
16
|
+
![12, 13, 14].include?(n % 100) ? :few : :other
|
17
|
+
}
|
18
|
+
}
|
14
19
|
}
|
15
20
|
}
|
16
|
-
}
|
21
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Polish
|
2
|
+
module Proxies
|
3
|
+
# See I18n::translate
|
4
|
+
def translate(key, options = {})
|
5
|
+
I18n.translate(key, options.merge({ :locale => LOCALE }))
|
6
|
+
end
|
7
|
+
alias :t :translate
|
8
|
+
|
9
|
+
# See I18n::localize
|
10
|
+
def localize(object, options = {})
|
11
|
+
I18n.localize(object, options.merge({ :locale => LOCALE }))
|
12
|
+
end
|
13
|
+
alias :l :localize
|
14
|
+
|
15
|
+
# strftime() proxy with Polish localization
|
16
|
+
def strftime(object, format = :default)
|
17
|
+
localize(object, { :format => format })
|
18
|
+
end
|
19
|
+
|
20
|
+
# Simple pluralization proxy
|
21
|
+
#
|
22
|
+
# Usage:
|
23
|
+
# Polish.pluralize(1, "dom", "domy", "domów")
|
24
|
+
def pluralize(n, *variants)
|
25
|
+
raise ArgumentError, "Must have a Numeric as a first parameter" unless n.is_a?(Numeric)
|
26
|
+
raise ArgumentError, "Must have 3 variants for pluralization" if variants.size < 3
|
27
|
+
variants_hash = pluralization_variants_to_hash(*variants)
|
28
|
+
I18n.backend.send(:pluralize, LOCALE, variants_hash, n)
|
29
|
+
end
|
30
|
+
alias :p :pluralize
|
31
|
+
|
32
|
+
protected
|
33
|
+
# Converts an array of pluralization variants to a Hash that can be used
|
34
|
+
# with I18n pluralization.
|
35
|
+
def pluralization_variants_to_hash(*variants)
|
36
|
+
{
|
37
|
+
:one => variants[0],
|
38
|
+
:few => variants[1],
|
39
|
+
:other => variants[2]
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
include Proxies
|
45
|
+
end
|
data/lib/proxies.rb
ADDED
data/polish.gemspec
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{polish}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Grzesiek Kolodziejczyk"]
|
12
|
+
s.date = %q{2010-07-23}
|
13
|
+
s.email = %q{gkolodziejczyk@gmail.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.md",
|
17
|
+
"TODO"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"TODO",
|
26
|
+
"VERSION",
|
27
|
+
"lib/polish.rb",
|
28
|
+
"lib/polish/action_view_ext/helpers/date_helper.rb",
|
29
|
+
"lib/polish/locale/actionview.yml",
|
30
|
+
"lib/polish/locale/activerecord.yml",
|
31
|
+
"lib/polish/locale/activesupport.yml",
|
32
|
+
"lib/polish/locale/datetime.rb",
|
33
|
+
"lib/polish/locale/datetime.yml",
|
34
|
+
"lib/polish/locale/pluralize.rb",
|
35
|
+
"lib/polish/proxies.rb",
|
36
|
+
"lib/proxies.rb",
|
37
|
+
"polish.gemspec",
|
38
|
+
"rails/init.rb",
|
39
|
+
"spec/fixtures/en.yml",
|
40
|
+
"spec/fixtures/pl.yml",
|
41
|
+
"spec/i18n/locale/datetime_spec.rb",
|
42
|
+
"spec/i18n/locale/pluralization_spec.rb",
|
43
|
+
"spec/locale_spec.rb",
|
44
|
+
"spec/polish_spec.rb",
|
45
|
+
"spec/proxies_spec.rb",
|
46
|
+
"spec/spec_helper.rb"
|
47
|
+
]
|
48
|
+
s.homepage = %q{http://github.com/grk/polish}
|
49
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
50
|
+
s.require_paths = ["lib"]
|
51
|
+
s.rubygems_version = %q{1.3.7}
|
52
|
+
s.summary = %q{Polish language support for Ruby and Rails}
|
53
|
+
s.test_files = [
|
54
|
+
"spec/i18n/locale/datetime_spec.rb",
|
55
|
+
"spec/i18n/locale/pluralization_spec.rb",
|
56
|
+
"spec/locale_spec.rb",
|
57
|
+
"spec/polish_spec.rb",
|
58
|
+
"spec/proxies_spec.rb",
|
59
|
+
"spec/spec_helper.rb"
|
60
|
+
]
|
61
|
+
|
62
|
+
if s.respond_to? :specification_version then
|
63
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
64
|
+
s.specification_version = 3
|
65
|
+
|
66
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
|
+
s.add_runtime_dependency(%q<i18n>, [">= 0.3.3"])
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<i18n>, [">= 0.3.3"])
|
70
|
+
end
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<i18n>, [">= 0.3.3"])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|