isodoc-i18n 1.1.9 → 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/date.rb +60 -0
- data/lib/isodoc/i18n/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17fcd1159b3550278a757d9bf50e2fde08d83b1c2be92b14f3ad6789dc509f20
|
4
|
+
data.tar.gz: fce8b97a8ac2f5df8754eb62b5994a74a5983098c00c259a5d751da9b30a3f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18cc15dbfc165f6b0428ecb40a804065f1493c7c3fb77dd98a944f6613c8cf18c93920c559b5354eea818f4623d43e6be7dd1c58979556739bd4935811e0f935
|
7
|
+
data.tar.gz: 8d1e430afb9e49a7a82868c2987266fac810c0b4bf4e30df2e67965ed3462e5dcaa289199fa9fc29e9bbe306cca427ee6b7c712821c1ec424a1f20dcf548aee3
|
data/lib/isodoc/date.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require "date"
|
2
|
+
|
3
|
+
module IsoDoc
|
4
|
+
class I18n
|
5
|
+
def date(value, format)
|
6
|
+
date_i18n(DateTime.iso8601(value)
|
7
|
+
.strftime(convert_date_format(format)))
|
8
|
+
end
|
9
|
+
|
10
|
+
def convert_date_format(fmt)
|
11
|
+
fmt.gsub(/%_/, " ")
|
12
|
+
.gsub(/%(\^?)([BbhPpAa])/, "%\u200c\\1\\2<%\\2>")
|
13
|
+
end
|
14
|
+
|
15
|
+
def date_i18n(val)
|
16
|
+
day_i18n(month_i18n(am_pm_i18n(val)))
|
17
|
+
end
|
18
|
+
|
19
|
+
def am_pm_i18n(val)
|
20
|
+
val.gsub(/%\u200cP<am>/, @cal.periods[:am].downcase)
|
21
|
+
.gsub(/%\u200cP<pm>/, @cal.periods[:pm].downcase)
|
22
|
+
.gsub(/%\u200cp<AM>/, @cal.periods[:am].upcase)
|
23
|
+
.gsub(/%\u200cp<PM>/, @cal.periods[:pm].upcase)
|
24
|
+
end
|
25
|
+
|
26
|
+
def month_i18n(val)
|
27
|
+
{ B: :wide, b: :abbreviated, h: :abbreviated }.each do |f, t|
|
28
|
+
@cal_en.calendar_data[:months][:format][t].each do |k, v|
|
29
|
+
m = @cal.calendar_data[:months][:format][t][k]
|
30
|
+
val.gsub!(/%\u200c#{f}<#{v}>/, m)
|
31
|
+
val.gsub!(/%\u200c\^#{f}<#{v}>/, m.upcase)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
val
|
35
|
+
end
|
36
|
+
|
37
|
+
def day_i18n(val)
|
38
|
+
{ A: :wide, a: :abbreviated }.each do |f, t|
|
39
|
+
@cal_en.calendar_data[:days][:format][t].each do |k, v|
|
40
|
+
m = @cal.calendar_data[:days][:format][t][k]
|
41
|
+
val.gsub!(/%\u200c#{f}<#{v}>/, m)
|
42
|
+
val.gsub!(/%\u200c\^#{f}<#{v}>/, m.upcase)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
val
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# %B - The full month name (``January'')
|
51
|
+
# %^B uppercased (``JANUARY'')
|
52
|
+
# %b - The abbreviated month name (``Jan'')
|
53
|
+
# %^b uppercased (``JAN'')
|
54
|
+
# %h - Equivalent to %b
|
55
|
+
# %P - Meridian indicator, lowercase (``am'' or ``pm'')
|
56
|
+
# %p - Meridian indicator, uppercase (``AM'' or ``PM'')
|
57
|
+
# %A - The full weekday name (``Sunday'')
|
58
|
+
# %^A uppercased (``SUNDAY'')
|
59
|
+
# %a - The abbreviated name (``Sun'')
|
60
|
+
# %^a uppercased (``SUN'')
|
data/lib/isodoc/i18n/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- isodoc-i18n.gemspec
|
211
211
|
- lib/isodoc-i18n.rb
|
212
212
|
- lib/isodoc-yaml/i18n-en.yaml
|
213
|
+
- lib/isodoc/date.rb
|
213
214
|
- lib/isodoc/i18n-yaml.rb
|
214
215
|
- lib/isodoc/i18n.rb
|
215
216
|
- lib/isodoc/i18n/version.rb
|