r18n-core 1.0.0 → 1.0.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/ChangeLog +9 -0
- data/README.md +17 -0
- data/base/mn.rb +19 -0
- data/lib/r18n-core/filters.rb +7 -6
- data/lib/r18n-core/utils.rb +4 -1
- data/lib/r18n-core/version.rb +1 -1
- data/lib/r18n-core.rb +11 -3
- data/locales/mn.rb +22 -0
- data/locales/pl.rb +1 -1
- data/locales/pt.rb +1 -1
- data/locales/th.rb +1 -1
- data/locales/zh-cn.rb +1 -1
- data/locales/zh-tw.rb +1 -1
- data/locales/zh.rb +1 -1
- data/spec/i18n_spec.rb +1 -1
- data/spec/r18n_spec.rb +11 -5
- data/spec/spec_helper.rb +1 -1
- metadata +6 -4
data/ChangeLog
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 1.0.1 (Phuket Town)
|
2
|
+
* Fix translation reloading in Rails and Sinatra.
|
3
|
+
* Use global R18n settings for Sinatra extension.
|
4
|
+
* Allow to override desktop autodetect by LANG environment on all platforms.
|
5
|
+
* Add support for JRuby in 1.9 mode.
|
6
|
+
* Rename R18n.reset to R18n.reset! and add R18n.clear_cache!.
|
7
|
+
* Fix Sinatra with loaded ActiveSupport.
|
8
|
+
* Add Mongolian locale (by Elias Klughammer).
|
9
|
+
|
1
10
|
== 1.0.0 (Bangkok)
|
2
11
|
* Add R18n.default_places.
|
3
12
|
* Rails SafeBuffer support.
|
data/README.md
CHANGED
@@ -204,6 +204,9 @@ The filter will receive at least two arguments:
|
|
204
204
|
* A Hash with translation `locale` and `path`.
|
205
205
|
* Parameters from translation request will be in the remaining arguments.
|
206
206
|
|
207
|
+
In Rails application put your filters to `app/i18n/filters.rb`, it will be
|
208
|
+
automatically reloaded in development.
|
209
|
+
|
207
210
|
#### HTML Escape
|
208
211
|
|
209
212
|
R18n contains 2 filters to escape HTML entities: by YAML type and global. If you
|
@@ -251,6 +254,20 @@ hi: !!markdown
|
|
251
254
|
t.hi #=> "<p><strong>Hi</strong>, people!</p>"
|
252
255
|
```
|
253
256
|
|
257
|
+
If you can’t use Kramdown you can redefine Markdown filter
|
258
|
+
to use your own parser:
|
259
|
+
|
260
|
+
```ruby
|
261
|
+
# Disable standard Markdown filter
|
262
|
+
Filters.off(:kramdown)
|
263
|
+
# Add new filter for !!markdown YAML type
|
264
|
+
Filters.add('markdown', :passive => true) do |content, config|
|
265
|
+
require 'redcarpet'
|
266
|
+
markdown = ::Redcarpet::Markdown.new(Redcarpet::Render::HTML)
|
267
|
+
markdown.render(content)
|
268
|
+
end
|
269
|
+
```
|
270
|
+
|
254
271
|
#### Textile
|
255
272
|
|
256
273
|
To use Textile in your translations you must install the RedCloth gem:
|
data/base/mn.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
ok: 'Сайн'
|
2
|
+
save: 'Хадгал'
|
3
|
+
cancel: 'Цуцлах'
|
4
|
+
'yes': 'Тийм'
|
5
|
+
'no': 'Үгүй'
|
6
|
+
exit: 'Гарц'
|
7
|
+
delete: 'Устга'
|
8
|
+
|
9
|
+
human_time:
|
10
|
+
after_days: '%1 Өдрийн дараа'
|
11
|
+
tomorrow: 'Маргааш'
|
12
|
+
after_hours: '%1 Цагийн дараа'
|
13
|
+
after_minutes: '%1 Минутны дараа'
|
14
|
+
now: 'Одоо'
|
15
|
+
today: 'Өнөөдөр'
|
16
|
+
minutes_ago: '%1 Минутны өмнө'
|
17
|
+
hours_ago: '%1 Цагийн өмнө'
|
18
|
+
yesterday: 'Өчигдөр'
|
19
|
+
days_ago: '%1 Өдрийн өмнө'
|
data/lib/r18n-core/filters.rb
CHANGED
@@ -246,14 +246,15 @@ module R18n
|
|
246
246
|
Filters.off(:untranslated_bash)
|
247
247
|
|
248
248
|
Filters.add(Untranslated, :untranslated_html) do |v, c, transl, untransl|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
249
|
+
prefix = '<span style="color: red">['
|
250
|
+
postfix = ']</span>'
|
251
|
+
if prefix.respond_to? :html_safe
|
252
|
+
prefix = prefix.html_safe
|
253
|
+
postfix = postfix.html_safe
|
254
|
+
transl << prefix << untransl << postfix
|
254
255
|
else
|
255
256
|
Utils.escape_html(transl) <<
|
256
|
-
|
257
|
+
prefix << Utils.escape_html(untransl) << postfix
|
257
258
|
end
|
258
259
|
end
|
259
260
|
Filters.off(:untranslated_html)
|
data/lib/r18n-core/utils.rb
CHANGED
@@ -69,7 +69,10 @@ module R18n
|
|
69
69
|
# Call +block+ with Syck yamler. It used to load RedCloth, which isn’t
|
70
70
|
# support Psych.
|
71
71
|
def self.use_syck(&block)
|
72
|
-
if '
|
72
|
+
if RUBY_PLATFORM == 'java' && defined?(YAML::ENGINE)
|
73
|
+
YAML::ENGINE.yamler = 'psych'
|
74
|
+
yield
|
75
|
+
elsif '1.8.' == RUBY_VERSION[0..3]
|
73
76
|
yield
|
74
77
|
else
|
75
78
|
origin_yamler = YAML::ENGINE.yamler
|
data/lib/r18n-core/version.rb
CHANGED
data/lib/r18n-core.rb
CHANGED
@@ -36,6 +36,8 @@ require dir.join('yaml_loader').to_s
|
|
36
36
|
require dir.join('i18n').to_s
|
37
37
|
require dir.join('helpers').to_s
|
38
38
|
|
39
|
+
require 'yecht' if RUBY_PLATFORM == 'java'
|
40
|
+
|
39
41
|
module R18n
|
40
42
|
autoload :Translated, 'r18n-core/translated'
|
41
43
|
|
@@ -72,11 +74,17 @@ module R18n
|
|
72
74
|
(@setter && set(@setter.call))
|
73
75
|
end
|
74
76
|
|
77
|
+
# Clean translations cache.
|
78
|
+
def clear_cache!
|
79
|
+
self.cache = { }
|
80
|
+
end
|
81
|
+
|
75
82
|
# Delete I18n object from current thread and global variable.
|
76
|
-
def reset
|
83
|
+
def reset!
|
77
84
|
thread[:r18n_i18n] = thread[:r18n_setter] = @i18n = @setter = nil
|
78
|
-
|
85
|
+
clear_cache!
|
79
86
|
end
|
87
|
+
alias :reset :reset!
|
80
88
|
|
81
89
|
# Get the current thread.
|
82
90
|
def thread
|
@@ -149,5 +157,5 @@ module R18n
|
|
149
157
|
self.default_loader = R18n::Loader::YAML
|
150
158
|
self.default_places = nil
|
151
159
|
self.extension_places = [Loader::YAML.new(dir + '../base')]
|
152
|
-
self.
|
160
|
+
self.clear_cache!
|
153
161
|
end
|
data/locales/mn.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module R18n
|
3
|
+
class Locales::Mn < Locale
|
4
|
+
set :title => 'Монгол',
|
5
|
+
|
6
|
+
:wday_names => ['Ням гариг', 'Даваа гариг', 'Мягмар гариг',
|
7
|
+
'Лхагва гариг', 'Пүрэв гариг', 'Баасан гариг',
|
8
|
+
'Бямба гариг'],
|
9
|
+
:wday_abbrs => %w{ня да мя лх пү ба бя},
|
10
|
+
|
11
|
+
:month_names => ['Нэгдүгээр сар', 'Хоёрдугаар сар', 'Гуравдугаар сар',
|
12
|
+
'Дөрөвдүгээр сар', 'Тавдугаар сар', 'Зургадугаар сар',
|
13
|
+
'Долдугаар сар', 'Наймдугаар сар', 'Есдүгээр сар',
|
14
|
+
'Аравдугаар сар', 'Арваннэгдүгээр сар',
|
15
|
+
'Арванхоёрдугаар сар'],
|
16
|
+
|
17
|
+
:date_format => '%Y-%m-%d',
|
18
|
+
|
19
|
+
:number_decimal => ",",
|
20
|
+
:number_group => "."
|
21
|
+
end
|
22
|
+
end
|
data/locales/pl.rb
CHANGED
data/locales/pt.rb
CHANGED
data/locales/th.rb
CHANGED
data/locales/zh-cn.rb
CHANGED
data/locales/zh-tw.rb
CHANGED
data/locales/zh.rb
CHANGED
data/spec/i18n_spec.rb
CHANGED
data/spec/r18n_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe R18n do
|
|
7
7
|
after do
|
8
8
|
R18n.default_loader = R18n::Loader::YAML
|
9
9
|
R18n.default_places = nil
|
10
|
-
R18n.reset
|
10
|
+
R18n.reset!
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should store I18n" do
|
@@ -15,7 +15,7 @@ describe R18n do
|
|
15
15
|
R18n.set(i18n)
|
16
16
|
R18n.get.should == i18n
|
17
17
|
|
18
|
-
R18n.reset
|
18
|
+
R18n.reset!
|
19
19
|
R18n.get.should be_nil
|
20
20
|
end
|
21
21
|
|
@@ -41,12 +41,18 @@ describe R18n do
|
|
41
41
|
R18n.get.locales.should == [R18n.locale('en')]
|
42
42
|
end
|
43
43
|
|
44
|
+
it "should clear cache" do
|
45
|
+
R18n.cache[:a] = 1
|
46
|
+
R18n.clear_cache!
|
47
|
+
R18n.cache.should be_empty
|
48
|
+
end
|
49
|
+
|
44
50
|
it "should reset I18n objects and cache" do
|
45
51
|
R18n.cache[:a] = 1
|
46
52
|
R18n.set('en')
|
47
53
|
R18n.thread_set('en')
|
48
54
|
|
49
|
-
R18n.reset
|
55
|
+
R18n.reset!
|
50
56
|
R18n.get.should be_nil
|
51
57
|
R18n.cache.should be_empty
|
52
58
|
end
|
@@ -96,8 +102,8 @@ describe R18n do
|
|
96
102
|
R18n.cache = { 1 => 2 }
|
97
103
|
R18n.cache.should == { 1 => 2 }
|
98
104
|
|
99
|
-
R18n.
|
100
|
-
R18n.cache.should == {}
|
105
|
+
R18n.clear_cache!
|
106
|
+
R18n.cache.should == { }
|
101
107
|
end
|
102
108
|
|
103
109
|
it "should convert Time to Date" do
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,7 @@ TWO = TRANSLATIONS + 'two' unless defined? TWO
|
|
12
12
|
EXT = R18n::Loader::YAML.new(TRANSLATIONS + 'extension') unless defined? EXT
|
13
13
|
|
14
14
|
RSpec.configure do |config|
|
15
|
-
config.before { R18n.
|
15
|
+
config.before { R18n.clear_cache! }
|
16
16
|
end
|
17
17
|
|
18
18
|
gem 'kramdown'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r18n-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- base/ja.yml
|
197
197
|
- base/kk.yml
|
198
198
|
- base/lv.yml
|
199
|
+
- base/mn.rb
|
199
200
|
- base/nb-no.yml
|
200
201
|
- base/nl.yml
|
201
202
|
- base/pl.yml
|
@@ -240,6 +241,7 @@ files:
|
|
240
241
|
- locales/ja.rb
|
241
242
|
- locales/kk.rb
|
242
243
|
- locales/lv.rb
|
244
|
+
- locales/mn.rb
|
243
245
|
- locales/nb-no.rb
|
244
246
|
- locales/nl.rb
|
245
247
|
- locales/pl.rb
|
@@ -295,7 +297,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
295
297
|
version: '0'
|
296
298
|
segments:
|
297
299
|
- 0
|
298
|
-
hash: -
|
300
|
+
hash: -3931827469984591101
|
299
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
300
302
|
none: false
|
301
303
|
requirements:
|
@@ -304,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
306
|
version: '0'
|
305
307
|
segments:
|
306
308
|
- 0
|
307
|
-
hash: -
|
309
|
+
hash: -3931827469984591101
|
308
310
|
requirements: []
|
309
311
|
rubyforge_project:
|
310
312
|
rubygems_version: 1.8.23
|