parsi-localize 0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +30 -2
- data/init.rb +1 -0
- data/lib/parsi_localize.rb +3 -1
- data/lib/version.rb +1 -1
- data/locale/en.yml +0 -0
- data/parsi-localize.gemspec +2 -2
- data/test/parsi_localize_test.rb +7 -2
- metadata +43 -17
- data/LICENSE +0 -20
data/README.markdown
CHANGED
@@ -1,6 +1,33 @@
|
|
1
1
|
ParsiLocalize
|
2
2
|
=============
|
3
3
|
|
4
|
+
Change I18n localize to use parsi digits and jalaly dates in farsi (فارسی) locale.
|
5
|
+
This gem contains two sections
|
6
|
+
|
7
|
+
ParsiDigits
|
8
|
+
-----------
|
9
|
+
Simply change digits in a string/integer/float to unicode parsi digits:
|
10
|
+
|
11
|
+
require 'parsi_digits'
|
12
|
+
"15,000 تومان".with_parsi_digits
|
13
|
+
=> "۱۵,۰۰۰ تومان"
|
14
|
+
123.25.with_parsi_digits
|
15
|
+
=> "۱۲۳/۲۵"
|
16
|
+
|
17
|
+
It also dose the reverse action:
|
18
|
+
|
19
|
+
"۱۲۳۴۵".with_western_digits
|
20
|
+
=> "12345"
|
21
|
+
|
22
|
+
And it undersanad parsi digits (which is useful especially for input forms):
|
23
|
+
|
24
|
+
"۱۲۳۴۵".to_i
|
25
|
+
=> 12345
|
26
|
+
"۱۹/۸".to_f
|
27
|
+
=> 19.8
|
28
|
+
|
29
|
+
ParsiLocalize
|
30
|
+
-------------
|
4
31
|
Change behaivor of I18n#localize so that it localize digits and dates in 'farsi' locale.
|
5
32
|
|
6
33
|
require 'parsi_localize'
|
@@ -9,7 +36,8 @@ Change behaivor of I18n#localize so that it localize digits and dates in 'farsi'
|
|
9
36
|
I18n.l Time.now, fromat: "%y/%m/%d %H:%M:%S"
|
10
37
|
=> "۹۰/۱۰/۱۳ ۰۵:۴۳:۳۲"
|
11
38
|
|
12
|
-
If you don't set date format, it uses the default locale format, wich you can set in your locale file.
|
39
|
+
If you don't set date format, it uses the default locale format, wich you can set in your locale file.
|
40
|
+
For example with
|
13
41
|
|
14
42
|
fa:
|
15
43
|
time:
|
@@ -41,6 +69,6 @@ in your locale file you will get:
|
|
41
69
|
I18n.l time, format: :long
|
42
70
|
=> "یکشنبه، ۱۶ بهمن ۱۳۹۰، ساعت ۱۵:۴۳:۳۰ (IRST)"
|
43
71
|
|
44
|
-
For more info on dateformating
|
72
|
+
For more info on dateformating see 'jalalidate' docs
|
45
73
|
|
46
74
|
Copyright (c) 2012 Hassan Zamani, released under the MIT license.
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'parsi_localize'
|
data/lib/parsi_localize.rb
CHANGED
data/lib/version.rb
CHANGED
data/locale/en.yml
ADDED
File without changes
|
data/parsi-localize.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.author = 'Hassan Zamani'
|
11
11
|
s.email = 'hsn.zamani@gmail.com'
|
12
12
|
s.homepage = 'http://github.com/hzamani/parsi_localize'
|
13
|
-
s.summary = '
|
13
|
+
s.summary = 'Change I18n localize to use parsi digits and jalaly dates in farsi locale'
|
14
14
|
s.description = 'Change I18n localize to use parsi digits and jalaly dates in farsi locale'
|
15
15
|
|
16
16
|
|
@@ -25,6 +25,6 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency("bundler")
|
26
26
|
s.add_development_dependency("rake")
|
27
27
|
s.add_dependency("i18n")
|
28
|
-
s.add_dependency("jalalidate")
|
29
28
|
s.add_dependency("parsi-digits")
|
29
|
+
s.add_dependency("jalalidate")
|
30
30
|
end
|
data/test/parsi_localize_test.rb
CHANGED
@@ -9,11 +9,16 @@ class ParsiLocalizeTest < Test::Unit::TestCase
|
|
9
9
|
assert_equal "۹/۰۸۷۶۵۴۳۲۱", I18n.l(9.087654321)
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_localize_format
|
13
|
+
time = Time.new(2012, 2, 5, 15, 43, 30)
|
14
|
+
assert_equal "۹۰/۱۱/۱۶", I18n.l(time, format: "%y/%m/%d")
|
15
|
+
end
|
16
|
+
|
12
17
|
def test_localize_date_format
|
13
18
|
date = Date.new(2012, 2, 5)
|
14
19
|
assert_equal "۹۰/۱۱/۱۶", I18n.l(date)
|
15
20
|
assert_equal "۹۰/۱۱/۱۶", I18n.l(date, format: :default)
|
16
|
-
assert_equal "۱۶ بهمن",
|
21
|
+
assert_equal "۱۶ بهمن", I18n.l(date, format: :short)
|
17
22
|
assert_equal "یکشنبه، ۱۶ بهمن ۱۳۹۰", I18n.l(date, format: :long)
|
18
23
|
end
|
19
24
|
|
@@ -21,7 +26,7 @@ class ParsiLocalizeTest < Test::Unit::TestCase
|
|
21
26
|
time = Time.new(2012, 2, 5, 15, 43, 30)
|
22
27
|
assert_equal "۹۰/۱۱/۱۶ ۱۵:۴۳:۳۰", I18n.l(time)
|
23
28
|
assert_equal "۹۰/۱۱/۱۶ ۱۵:۴۳:۳۰", I18n.l(time, format: :default)
|
24
|
-
assert_equal "۱۶ بهمن، ۱۵:۴۳",
|
29
|
+
assert_equal "۱۶ بهمن، ۱۵:۴۳", I18n.l(time, format: :short)
|
25
30
|
assert_equal "یکشنبه، ۱۶ بهمن ۱۳۹۰، ساعت ۱۵:۴۳:۳۰ (IRST)", I18n.l(time, format: :long)
|
26
31
|
end
|
27
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parsi-localize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rake
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: i18n
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement:
|
63
|
+
name: parsi-digits
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement:
|
79
|
+
name: jalalidate
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,7 +85,12 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :runtime
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
description: Change I18n localize to use parsi digits and jalaly dates in farsi locale
|
70
95
|
email: hsn.zamani@gmail.com
|
71
96
|
executables: []
|
@@ -74,11 +99,12 @@ extra_rdoc_files: []
|
|
74
99
|
files:
|
75
100
|
- .gitignore
|
76
101
|
- Gemfile
|
77
|
-
- LICENSE
|
78
102
|
- README.markdown
|
79
103
|
- Rakefile
|
104
|
+
- init.rb
|
80
105
|
- lib/parsi_localize.rb
|
81
106
|
- lib/version.rb
|
107
|
+
- locale/en.yml
|
82
108
|
- locale/fa.yml
|
83
109
|
- parsi-localize.gemspec
|
84
110
|
- test/parsi_localize_test.rb
|
@@ -103,10 +129,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
129
|
version: '0'
|
104
130
|
requirements: []
|
105
131
|
rubyforge_project:
|
106
|
-
rubygems_version: 1.8.
|
132
|
+
rubygems_version: 1.8.24
|
107
133
|
signing_key:
|
108
134
|
specification_version: 3
|
109
|
-
summary:
|
135
|
+
summary: Change I18n localize to use parsi digits and jalaly dates in farsi locale
|
110
136
|
test_files:
|
111
137
|
- test/parsi_localize_test.rb
|
112
138
|
- test/test_helper.rb
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2012 Hassan Zamani
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|