r18n-core 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/README.rdoc +1 -1
- data/base/it.yml +31 -0
- data/lib/r18n-core/filters.rb +4 -0
- data/lib/r18n-core/translated.rb +1 -1
- data/lib/r18n-core/translation.rb +1 -1
- data/lib/r18n-core/untranslated.rb +23 -7
- data/lib/r18n-core/version.rb +1 -1
- data/lib/r18n-core.rb +0 -19
- data/locales/en-us.yml +1 -0
- data/locales/it.rb +15 -0
- data/locales/it.yml +26 -0
- data/locales/pl.yml +7 -7
- data/spec/filters_spec.rb +12 -0
- data/spec/locales/it_spec.rb +12 -0
- data/spec/r18n_spec.rb +0 -9
- metadata +45 -45
data/ChangeLog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.3.2 (Pidgin)
|
2
|
+
* Print path of untranslated string by filters.
|
3
|
+
* Add Italian locale (by Guido De Rosa).
|
4
|
+
* Fix Polish locale (by Adrian Pacała).
|
5
|
+
* Fix American English locale (by Max Aller).
|
6
|
+
|
1
7
|
== 0.3.1 (Yield)
|
2
8
|
* Add Chinese locale (by Ilia Zayats).
|
3
9
|
* Add Spanish locale (by Andre O Moura).
|
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
R18n is a i18n tool to translate your Ruby application in several languages.
|
4
4
|
|
5
|
-
Use <tt>sinatra-r18n</tt> or teamon’s
|
5
|
+
Use <tt>sinatra-r18n</tt> or teamon’s <tt>merb_i18n</tt> to localize Web applications and
|
6
6
|
<tt>r18n-desktop</tt> to localize desktop application.
|
7
7
|
|
8
8
|
== Features
|
data/base/it.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
ok: OK
|
2
|
+
save: Salva
|
3
|
+
cancel: Annulla
|
4
|
+
yes: Sì
|
5
|
+
no: No
|
6
|
+
exit: Esci
|
7
|
+
delete: Cancella
|
8
|
+
|
9
|
+
human_time:
|
10
|
+
after_days: !!pl
|
11
|
+
1: dopo %1 giorno
|
12
|
+
n: dopo %1 giorni
|
13
|
+
tomorrow: domani
|
14
|
+
after_hours: !!pl
|
15
|
+
1: dopo %1 ora
|
16
|
+
n: dopo %1 ore
|
17
|
+
after_minutes: !!pl
|
18
|
+
1: dopo %1 minuto
|
19
|
+
n: dopo %1 minuti
|
20
|
+
now: ora
|
21
|
+
today: oggi
|
22
|
+
minutes_ago: !!pl
|
23
|
+
1: %1 minuto fa
|
24
|
+
n: %1 minuti fa
|
25
|
+
hours_ago: !!pl
|
26
|
+
1: %1 ora fa
|
27
|
+
n: %1 ore fa
|
28
|
+
yesterday: ieri
|
29
|
+
days_ago: !!pl
|
30
|
+
1: %1 giorno fa
|
31
|
+
n: %1 giorni fa
|
data/lib/r18n-core/filters.rb
CHANGED
@@ -214,6 +214,10 @@ module R18n
|
|
214
214
|
content
|
215
215
|
end
|
216
216
|
|
217
|
+
Filters.add(Untranslated, :untranslated) do |v, c, translated, untranslated|
|
218
|
+
"#{translated}[#{untranslated}]"
|
219
|
+
end
|
220
|
+
|
217
221
|
Filters.add('escape', :escape_html) do |content, config|
|
218
222
|
config.dont_escape_html = true
|
219
223
|
Utils.escape_html(content)
|
data/lib/r18n-core/translated.rb
CHANGED
@@ -23,6 +23,22 @@ require 'singleton'
|
|
23
23
|
module R18n
|
24
24
|
# Return if translation isn’t exists. Unlike nil, it didn’t raise error when
|
25
25
|
# you try to access for subtranslations.
|
26
|
+
#
|
27
|
+
# You can set format to print untranslated string by filters. For example:
|
28
|
+
# Disable standart output:
|
29
|
+
#
|
30
|
+
# R18n::Filters.off(:untranslated)
|
31
|
+
#
|
32
|
+
# For development environment:
|
33
|
+
#
|
34
|
+
# R18n::Filters.add(R18n::Untranslated, :untranslated_html) do
|
35
|
+
# |content, config, translated_path, untranslated_path, path|
|
36
|
+
# "#{translated_path}<span style='color: red'>#{untranslated_path}</span>"
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# For production environment:
|
40
|
+
#
|
41
|
+
# R18n::Filters.add(R18n::Untranslated, :hide_untranslated) { '' }
|
26
42
|
class Untranslated
|
27
43
|
# Path to translation.
|
28
44
|
attr_reader :path
|
@@ -33,8 +49,9 @@ module R18n
|
|
33
49
|
# Path, that exists in translation.
|
34
50
|
attr_reader :translated_path
|
35
51
|
|
36
|
-
def initialize(path, untranslated_path)
|
52
|
+
def initialize(path, untranslated_path, locales)
|
37
53
|
@path = path
|
54
|
+
@locales = locales
|
38
55
|
@untranslated_path = untranslated_path
|
39
56
|
@translated_path = path[0...(-untranslated_path.length)]
|
40
57
|
end
|
@@ -49,15 +66,14 @@ module R18n
|
|
49
66
|
|
50
67
|
def [](*params)
|
51
68
|
Untranslated.new("#{@path}.#{params.first}",
|
52
|
-
"#{@untranslated_path}.#{params.first}")
|
69
|
+
"#{@untranslated_path}.#{params.first}", @locales)
|
53
70
|
end
|
54
71
|
|
55
72
|
def to_s
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
R18n.untranslated
|
73
|
+
config = OpenStruct.new(:locale => @locales.first, :path => @path,
|
74
|
+
:locales => @locales)
|
75
|
+
Filters.enabled[Untranslated].inject(@path) do |string, filter|
|
76
|
+
filter.call(string, config, @translated_path, @untranslated_path, @path)
|
61
77
|
end
|
62
78
|
end
|
63
79
|
end
|
data/lib/r18n-core/version.rb
CHANGED
data/lib/r18n-core.rb
CHANGED
@@ -44,24 +44,5 @@ module R18n
|
|
44
44
|
def get
|
45
45
|
Thread.current['i18n']
|
46
46
|
end
|
47
|
-
|
48
|
-
# String, which will be print by untranslated items. You can use special
|
49
|
-
# values:
|
50
|
-
# * <tt>%1</tt> – path to untranslated string.
|
51
|
-
# * <tt>%2</tt> – part in path, that exists in translation.
|
52
|
-
# * <tt>%3</tt> – part in path, that isn’t exists in translation.
|
53
|
-
#
|
54
|
-
# For example, if you have in translation only:
|
55
|
-
# user:
|
56
|
-
# login: Login
|
57
|
-
#
|
58
|
-
# And write code:
|
59
|
-
#
|
60
|
-
# R18n.untranslated = '%2[%3]'
|
61
|
-
#
|
62
|
-
# i18n.user.password #=> "user.[password]"
|
63
|
-
attr_accessor :untranslated
|
64
47
|
end
|
65
|
-
|
66
|
-
self.untranslated = '%2[%3]'
|
67
48
|
end
|
data/locales/en-us.yml
CHANGED
data/locales/it.rb
ADDED
data/locales/it.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
title: Italiano
|
2
|
+
code: it
|
3
|
+
sublocales: [en]
|
4
|
+
direction: ltr
|
5
|
+
|
6
|
+
week:
|
7
|
+
start: monday
|
8
|
+
days: [domenica, lunedì, martedì, mercoledì, giovedì, venerdì, sabato]
|
9
|
+
abbrs: [dom, lun, mar, mer, gio, ven, sab]
|
10
|
+
|
11
|
+
months:
|
12
|
+
names: [gennaio, febbraio, marzo, aprile, maggio, giugno, luglio, agosto, settembre, ottobre, novembre, dicembre]
|
13
|
+
abbrs: [gen, feb, mar, apr, mag, giu, lug, ago, set, ott, nov, dic]
|
14
|
+
standalone: [gennaio, febbraio, marzo, aprile, maggio, giugno, luglio, agosto, settembre, ottobre, novembre, dicembre]
|
15
|
+
|
16
|
+
time:
|
17
|
+
am: AM
|
18
|
+
pm: PM
|
19
|
+
time: " %H:%M"
|
20
|
+
date: "%d/%m/%Y"
|
21
|
+
full: "%e %B"
|
22
|
+
year: "_ %Y"
|
23
|
+
|
24
|
+
numbers:
|
25
|
+
decimal_separator: ","
|
26
|
+
group_delimiter: "."
|
data/locales/pl.yml
CHANGED
@@ -5,13 +5,13 @@ direction: ltr
|
|
5
5
|
|
6
6
|
week:
|
7
7
|
start: monday
|
8
|
-
days: [
|
9
|
-
abbrs: [
|
8
|
+
days: [niedziela, poniedziałek, wtorek, środa, czwartek, piątek, sobota]
|
9
|
+
abbrs: [nd, pn, wt, śr, czw, pt, sob]
|
10
10
|
|
11
11
|
months:
|
12
|
-
names: [
|
13
|
-
abbrs: [
|
14
|
-
standalone: [
|
12
|
+
names: [stycznia, lutego, marca, kwietnia, maja, czerwca, lipca, sierpnia, września, pażdziernika, listopada, grudnia]
|
13
|
+
abbrs: [I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII]
|
14
|
+
standalone: [styczeń, luty, marzec, kwiecień, maj, czerwiec, lipiec, sierpień, wrzesień, październik, listopad, grudzień]
|
15
15
|
|
16
16
|
time:
|
17
17
|
am: AM
|
@@ -22,5 +22,5 @@ time:
|
|
22
22
|
year: "_ %Y"
|
23
23
|
|
24
24
|
numbers:
|
25
|
-
decimal_separator: "
|
26
|
-
group_delimiter: "
|
25
|
+
decimal_separator: ","
|
26
|
+
group_delimiter: " "
|
data/spec/filters_spec.rb
CHANGED
@@ -138,6 +138,18 @@ describe R18n::Filters do
|
|
138
138
|
@i18n.params(-1, 2).should == 'Is −1 between −1 and 2?'
|
139
139
|
end
|
140
140
|
|
141
|
+
it "should format untranslated" do
|
142
|
+
@i18n.in.not.to_s.should == 'in.[not]'
|
143
|
+
|
144
|
+
R18n::Filters.off(:untranslated)
|
145
|
+
@i18n.in.not.to_s.should == 'in.not'
|
146
|
+
|
147
|
+
R18n::Filters.add(R18n::Untranslated) do |v, c, trans, untrans, path|
|
148
|
+
"#{path} #{trans}[#{untrans}]"
|
149
|
+
end
|
150
|
+
@i18n.in.not.to_s.should == 'in.not in.[not]'
|
151
|
+
end
|
152
|
+
|
141
153
|
it "should have filter for escape HTML" do
|
142
154
|
@i18n.html.should == '<script>true && false</script>'
|
143
155
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
3
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'locales', 'it')
|
4
|
+
|
5
|
+
describe R18n::Locales::It do
|
6
|
+
it "should format Italian date" do
|
7
|
+
italian = R18n::I18n.new('it')
|
8
|
+
italian.l(Date.parse('2009-07-01'), :full).should == "1º luglio 2009"
|
9
|
+
italian.l(Date.parse('2009-07-02'), :full).should == ' 2 luglio 2009'
|
10
|
+
italian.l(Date.parse('2009-07-12'), :full).should == '12 luglio 2009'
|
11
|
+
end
|
12
|
+
end
|
data/spec/r18n_spec.rb
CHANGED
@@ -25,14 +25,5 @@ describe R18n do
|
|
25
25
|
it "should convert Time to Date" do
|
26
26
|
R18n::Utils.to_date(Time.now).should == Date.today
|
27
27
|
end
|
28
|
-
|
29
|
-
it "should set untranslated format" do
|
30
|
-
i18n = R18n::I18n.new('en', DIR)
|
31
|
-
R18n.untranslated = nil
|
32
|
-
i18n.in.not.to_s.should be_nil
|
33
|
-
|
34
|
-
R18n.untranslated = '%1 %2[%3]'
|
35
|
-
i18n.in.not.to_s.should == 'in.not in.[not]'
|
36
|
-
end
|
37
28
|
|
38
29
|
end
|
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: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey "A.I." Sitnik
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-29 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: R18n is a i18n tool to translate your Ruby application
|
16
|
+
description: " R18n is a i18n tool to translate your Ruby application.\n It can format numbers and time to the rules of the user locale,\n has translation for common words, storage translation in YAML format with\n pluralization, procedures and user filters and has special support for\n countries with two official languages.\n"
|
17
17
|
email: andrey@sitnik.ru
|
18
18
|
executables: []
|
19
19
|
|
@@ -24,52 +24,56 @@ extra_rdoc_files:
|
|
24
24
|
- LICENSE
|
25
25
|
- ChangeLog
|
26
26
|
files:
|
27
|
-
- base/pt_br.yml
|
28
|
-
- base/ru.yml
|
29
27
|
- base/kk.yml
|
30
|
-
- base/
|
31
|
-
- base/
|
32
|
-
- base/en.yml
|
28
|
+
- base/it.yml
|
29
|
+
- base/ru.yml
|
33
30
|
- base/pl.yml
|
34
31
|
- base/de.yml
|
35
|
-
- base/cs.yml
|
36
32
|
- base/eo.yml
|
33
|
+
- base/cs.yml
|
34
|
+
- base/pt_br.yml
|
35
|
+
- base/es.yml
|
36
|
+
- base/fr.yml
|
37
|
+
- base/en.yml
|
37
38
|
- base/zh.yml
|
38
|
-
- lib/r18n-core
|
39
|
+
- lib/r18n-core.rb
|
40
|
+
- lib/r18n-core/filters.rb
|
39
41
|
- lib/r18n-core/untranslated.rb
|
40
|
-
- lib/r18n-core/translated.rb
|
41
|
-
- lib/r18n-core/i18n.rb
|
42
|
-
- lib/r18n-core/locale.rb
|
43
|
-
- lib/r18n-core/utils.rb
|
44
42
|
- lib/r18n-core/version.rb
|
45
|
-
- lib/r18n-core/
|
43
|
+
- lib/r18n-core/utils.rb
|
46
44
|
- lib/r18n-core/translated_string.rb
|
47
|
-
- lib/r18n-core/
|
45
|
+
- lib/r18n-core/translation.rb
|
46
|
+
- lib/r18n-core/translated.rb
|
48
47
|
- lib/r18n-core/unsupported_locale.rb
|
49
|
-
- lib/r18n-core.rb
|
50
|
-
-
|
51
|
-
- locales/
|
52
|
-
- locales/
|
53
|
-
- locales/pt-br.yml
|
48
|
+
- lib/r18n-core/locale.rb
|
49
|
+
- lib/r18n-core/i18n.rb
|
50
|
+
- locales/it.rb
|
51
|
+
- locales/pl.rb
|
54
52
|
- locales/kk.yml
|
55
|
-
- locales/
|
56
|
-
- locales/
|
57
|
-
- locales/
|
53
|
+
- locales/it.yml
|
54
|
+
- locales/en.rb
|
55
|
+
- locales/ru.yml
|
58
56
|
- locales/pl.yml
|
59
|
-
- locales/de.yml
|
60
|
-
- locales/cs.yml
|
61
|
-
- locales/fr.rb
|
62
57
|
- locales/cs.rb
|
58
|
+
- locales/de.yml
|
63
59
|
- locales/eo.yml
|
64
60
|
- locales/en-us.rb
|
65
|
-
- locales/zh.yml
|
66
61
|
- locales/en-us.yml
|
67
|
-
- locales/
|
62
|
+
- locales/pt-br.yml
|
63
|
+
- locales/cs.yml
|
64
|
+
- locales/es.yml
|
65
|
+
- locales/fr.yml
|
66
|
+
- locales/fr.rb
|
67
|
+
- locales/ru.rb
|
68
|
+
- locales/en.yml
|
69
|
+
- locales/zh.yml
|
68
70
|
- LICENSE
|
69
71
|
- ChangeLog
|
70
72
|
- README.rdoc
|
71
73
|
has_rdoc: true
|
72
74
|
homepage: http://r18n.rubyforge.org/
|
75
|
+
licenses: []
|
76
|
+
|
73
77
|
post_install_message:
|
74
78
|
rdoc_options: []
|
75
79
|
|
@@ -90,33 +94,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
94
|
requirements: []
|
91
95
|
|
92
96
|
rubyforge_project: r18n-core
|
93
|
-
rubygems_version: 1.3.
|
97
|
+
rubygems_version: 1.3.5
|
94
98
|
signing_key:
|
95
|
-
specification_version:
|
99
|
+
specification_version: 3
|
96
100
|
summary: I18n tool to translate your Ruby application.
|
97
101
|
test_files:
|
98
|
-
- spec/
|
99
|
-
- spec/locales/
|
102
|
+
- spec/translated_spec.rb
|
103
|
+
- spec/locales/it_spec.rb
|
104
|
+
- spec/locales/fr_spec.rb
|
100
105
|
- spec/locales/pl_spec.rb
|
101
106
|
- spec/locales/cs_spec.rb
|
102
|
-
- spec/locales/en-us_spec.rb
|
103
|
-
- spec/locales/fr_spec.rb
|
104
107
|
- spec/locales/ru_spec.rb
|
108
|
+
- spec/locales/en_spec.rb
|
109
|
+
- spec/locales/en-us_spec.rb
|
105
110
|
- spec/spec_helper.rb
|
106
|
-
- spec/
|
107
|
-
- spec/
|
108
|
-
- spec/translations/two/fr.yml
|
109
|
-
- spec/translations/two/en.yml
|
110
|
-
- spec/translations/general
|
111
|
+
- spec/r18n_spec.rb
|
112
|
+
- spec/translation_spec.rb
|
111
113
|
- spec/translations/general/ru.yml
|
112
114
|
- spec/translations/general/en.yml
|
113
115
|
- spec/translations/general/no-lc.yml
|
114
|
-
- spec/translations/
|
116
|
+
- spec/translations/two/fr.yml
|
117
|
+
- spec/translations/two/en.yml
|
115
118
|
- spec/translations/extension/no-tr.yml
|
116
119
|
- spec/translations/extension/en.yml
|
117
|
-
- spec/translation_spec.rb
|
118
|
-
- spec/r18n_spec.rb
|
119
120
|
- spec/filters_spec.rb
|
120
|
-
- spec/locale_spec.rb
|
121
121
|
- spec/i18n_spec.rb
|
122
|
-
- spec/
|
122
|
+
- spec/locale_spec.rb
|