i18n-translators-tools 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ec3d676d4b73931620ae4f14fda0380befb5e274
4
+ data.tar.gz: 43843b3512f6d599bff966fef2bc9609d15013c1
5
+ SHA512:
6
+ metadata.gz: f8e345b907b4a1fd80758e97b279b075c68ff9c207844f6fcc0aa9897b281ce28b7bb385cab864eae1db2f5d0a73c97a04e9346d96e9bcc5d5d45bafff730267
7
+ data.tar.gz: e371e8bfbf1b3b3b096a17f9f2a6564223bd81af903bd8221b2103efa677a639cffe24c3f99ab0949ca933060081112fe377a3ed672586d8d3b8aa527d9e8e45
data/Rakefile CHANGED
@@ -2,10 +2,10 @@
2
2
  # vi: fenc=utf-8:expandtab:ts=2:sw=2:sts=2
3
3
  #
4
4
  # @author: Petr Kovar <pejuko@gmail.com>
5
- $KCODE='UTF8'
5
+ $KCODE='UTF8' if RUBY_VERSION < "1.9"
6
6
 
7
7
  require 'rake/testtask'
8
- require 'rake/gempackagetask'
8
+ require 'rubygems/package_task'
9
9
  require 'rake/clean'
10
10
 
11
11
  CLEAN << "coverage" << "pkg" << "README.html" << "CHANGELOG.html" << '*.rbc'
@@ -16,7 +16,7 @@ Rake::TestTask.new(:test) do |t|
16
16
  t.verbose = true
17
17
  end
18
18
 
19
- Rake::GemPackageTask.new(eval(File.read("i18n-translators-tools.gemspec"))) {|pkg|}
19
+ Gem::PackageTask.new(eval(File.read("i18n-translators-tools.gemspec"))) {|pkg|}
20
20
 
21
21
  desc "Test with rcov"
22
22
  task :rcov do |t|
data/bin/i18n-translate CHANGED
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # @author: Petr Kovar <pejuko@gmail.com>
6
6
 
7
- $KCODE="UTF8"
7
+ $KCODE="UTF8" if RUBY_VERSION < "1.9"
8
8
 
9
9
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
10
10
 
@@ -20,7 +20,7 @@ def print_help
20
20
  convert -- convert from -f format to -c format
21
21
  strip -- throw away translation metadata from locales and makes them
22
22
  compatible again with I18n::Backend::Simple
23
- translate -- simple console translator; --language must be set
23
+ translate -- simple console translator; --locale must be set
24
24
 
25
25
 
26
26
  options:
@@ -90,7 +90,7 @@ rescue
90
90
  end
91
91
 
92
92
  require 'i18n'
93
- require 'i18n-translate'
93
+ require 'i18n-translators-tools'
94
94
 
95
95
 
96
96
  # converts from one file format to another
@@ -216,7 +216,7 @@ opts.each do |opt, val|
216
216
  end
217
217
  tmp[optkey] = val
218
218
  when :deep
219
- tmp[optkey] = val
219
+ tmp[optkey] = true
220
220
  when :hard
221
221
  tmp[:merge] = "hard"
222
222
  when :verbose
@@ -13,7 +13,7 @@ spec = Gem::Specification.new do |s|
13
13
  s.email = "pejuko@gmail.com"
14
14
  s.authors = ["Petr Kovar"]
15
15
  s.name = 'i18n-translators-tools'
16
- s.version = '0.2.4'
16
+ s.version = '0.2.5'
17
17
  s.date = Time.now.strftime("%Y-%m-%d")
18
18
  s.add_dependency('i18n', '>= 0.5.0')
19
19
  s.add_dependency('ya2yaml')
@@ -52,21 +52,9 @@ Functions:
52
52
  * statistics
53
53
 
54
54
  Changelog:
55
- v0.2.1
56
- * fix: I18n::Backend::Translate now returns nil if translation is empty
57
- string (this allows fallbacks)
58
-
59
- v0.2.2
60
- * fix: don't merge if default file doesn't exist (locale stays untouched)
61
- * fix: for default format autodetection works again
62
- * merge can be more verbose
63
-
64
- v0.2.3
65
- * fix: hash_to_keys can work with enhanced format => default can be in
66
- enchanced format
67
- * default file can be now in enhanced format. if translation field is missing
68
- * i18n-translate <source file> <target file>
69
- automaticlay perform convert action from one file to another
55
+ v0.2.5
56
+ * fix recursive directory scan (-r and --deep options should work now)
57
+ * enables usage require 'i18n-translators-tools'
70
58
 
71
59
  v0.2.4
72
60
  * enhanced support for java properties
@@ -75,7 +63,23 @@ Changelog:
75
63
  * processors now generate keys list from provided data and not from @tr.default
76
64
  * flag obsolete added
77
65
  * delete function
78
- * i18n-0.5.0 compatibility (for older i18n user v0.2.3)
66
+ * i18n-0.5.0 compatibility
67
+
68
+
69
+ v0.2.3
70
+ * fix: hash_to_keys can work with enhanced format => default can be in
71
+ enhanced format
72
+ * default file can be now in enhanced format. if translation field is missing
73
+ in default file then field default is used instead
74
+ * i18n-translate <source file> <target file>
75
+ automaticlay perform convert action from one file to another
76
+
77
+
78
+ v0.2.2
79
+ * fix: don't merge if default file doesn't exist
80
+ * fix: for default format autodetection works again
81
+ * merge can be more verbose
82
+
79
83
 
80
84
  For more information read README.md and CHANGELOG.md
81
85
 
@@ -0,0 +1,4 @@
1
+ dir = File.expand_path(File.dirname(__FILE__))
2
+ $:.unshift(dir) unless $:.include?(dir)
3
+
4
+ require 'i18n-translate'
@@ -21,7 +21,7 @@ module I18n
21
21
  result = super(locale, key, options)
22
22
  return nil if result.kind_of?(String) and result.empty?
23
23
  return result unless result.kind_of?(Hash)
24
- return nil unless result[:t] or result[:translation] or result[:default]
24
+ return result unless result[:t] or result[:translation] or result[:default]
25
25
 
26
26
  tr = result[:translation] || result[:t]
27
27
  tr = result[:default] if tr.to_s.empty?
@@ -110,19 +110,19 @@ module I18n::Translate::Processor
110
110
  I18n::Translate.set(key, entry, hash, @translate.options[:separator])
111
111
  end
112
112
 
113
- {@translate.lang => hash}
113
+ {@lang => hash}
114
114
  end
115
115
 
116
116
 
117
117
  def export(data)
118
- target = data[@translate.lang]
118
+ target = data[@lang]
119
119
  str = ""
120
120
  keys = I18n::Translate.hash_to_keys(target).sort
121
121
 
122
122
  str << %~msgid ""\n~
123
123
  str << %~msgstr ""\n~
124
124
  str << %~"Content-Type: text/plain; charset=#{@translate.options[:encoding]}\\n"\n~
125
- str << %~"X-Language: #{@translate.lang}\\n"\n~
125
+ str << %~"X-Language: #{@lang}\\n"\n~
126
126
  keys.each do |key|
127
127
  entry = [""]
128
128
  value = @translate.find(key, target)
@@ -20,6 +20,8 @@ module I18n::Translate::Processor
20
20
  def import(data)
21
21
  hash = {}
22
22
 
23
+ sep = @translate.options[:separator]
24
+ plus_key = sep+"translation"
23
25
  key = nil
24
26
  value = nil
25
27
  status = :first
@@ -42,20 +44,20 @@ module I18n::Translate::Processor
42
44
  # end of continuous string
43
45
  elsif line[%r{^(?:#{WHITE_SPACE})*#{VALUE_END}$}] and (status == :inside)
44
46
  value << $1.to_s.strip
45
- I18n::Translate.set(uninspect(key), uninspect(value), hash, @translate.options[:separator])
47
+ I18n::Translate.set(uninspect(key)+plus_key, uninspect(value), hash, sep)
46
48
  value = nil
47
49
  status = :first
48
50
 
49
51
  # simple key = value
50
52
  elsif line[%r{#{KEY}#{ASSIGN}#{VALUE}}]
51
53
  key, value = $1.to_s.strip, $2.to_s.strip
52
- I18n::Translate.set(uninspect(key), uninspect(value), hash, @translate.options[:separator])
54
+ I18n::Translate.set(uninspect(key)+plus_key, uninspect(value), hash, sep)
53
55
 
54
56
  # empty key
55
- elsif line[/#{KEY}$/]
57
+ elsif line[/#{KEY}\s*/]
56
58
  key = $1.to_s.strip
57
59
  value = ""
58
- I18n::Translate.set(uninspect(key), uninspect(value), hash, @translate.options[:separator])
60
+ I18n::Translate.set(uninspect(key)+plus_key, uninspect(value), hash, sep)
59
61
  else
60
62
  puts "*** not match: '#{line}'"
61
63
  end
@@ -66,7 +68,8 @@ module I18n::Translate::Processor
66
68
 
67
69
  # this export ignores data
68
70
  def export(data)
69
- target = data[@translate.lang]
71
+ sep = @translate.options[:separator]
72
+ target = data[@lang]
70
73
  str = ""
71
74
  keys = I18n::Translate.hash_to_keys(target).sort
72
75
 
@@ -82,8 +85,11 @@ module I18n::Translate::Processor
82
85
  entry = value["translation"].to_s
83
86
  end
84
87
 
88
+ k = key
89
+ k = $1 if k =~ /(.*)#{Regexp.escape sep}translation$/
90
+
85
91
  # create record in format: key = value
86
- str << key.gsub(/( |:|=)/){|m| "\\#{m}"} << " = " << entry.gsub("\n", "\\n") << "\n"
92
+ str << k.gsub(/( |:|=)/){|m| "\\#{m}"} << " = " << entry.gsub("\n", "\\n") << "\n"
87
93
  end
88
94
 
89
95
  str
@@ -250,6 +250,9 @@ module I18n::Translate
250
250
  raise "Translate#[key]: wrong key '#{key}'" unless d
251
251
 
252
252
  entry = {"key" => key, "default" => d}
253
+ if d.kind_of? Hash
254
+ entry["default"] = d["translation"] || d["t"] || d["default"]
255
+ end
253
256
 
254
257
  # translation doesn't exist
255
258
  trg = I18n::Translate.find(key, @target, @options[:separator])
data/test/all.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @author: Petr Kovar <pejuko@gmail.com>
5
5
  #
6
- $KCODE='UTF8'
6
+ $KCODE='UTF8' if RUBY_VERSION < "1.9"
7
7
 
8
8
  require 'test/unit'
9
9
  require 'rubygems'
@@ -13,4 +13,7 @@ class TestBackendTranslate < Test::Unit::TestCase
13
13
 
14
14
  include I18n::Test::Backend
15
15
 
16
+ def test_1000_returns_hash
17
+ assert_equal( {:interpolation=>"Interpolated text '%{var}'"}, I18n.t("extended", :locale => "default") )
18
+ end
16
19
  end
@@ -19,7 +19,7 @@ class TestProcessorProperties < Test::Unit::TestCase
19
19
  data = data['cze']
20
20
  str = "Interpolovaný text '%{var}'"
21
21
  #diff(str, data["extended"]["interpolation"])
22
- assert_equal( str, data["extended"]["interpolation"] )
22
+ assert_equal( str, data["extended"]["interpolation"]["translation"] )
23
23
  end
24
24
 
25
25
  def test_0020_write
metadata CHANGED
@@ -1,50 +1,43 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: i18n-translators-tools
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 4
9
- version: 0.2.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.5
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Petr Kovar
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2010-11-29 00:00:00 +01:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: i18n
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
26
17
  - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 5
31
- - 0
18
+ - !ruby/object:Gem::Version
32
19
  version: 0.5.0
33
20
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: ya2yaml
37
21
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: ya2yaml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
41
31
  - - ">="
42
- - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
- version: "0"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
46
34
  type: :runtime
47
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
48
41
  description: |
49
42
  This package brings you useful utility and library which can help you to handle
50
43
  locale files and translations in your Ruby projects.
@@ -54,75 +47,72 @@ description: |
54
47
  simple console editor. Supported formats are YAML, Ruby, Gettext po,
55
48
  QT Linguist TS and Java Properties. Read README.md file and run i18n-translate
56
49
  without parameters for more information.
57
-
58
50
  email: pejuko@gmail.com
59
- executables:
51
+ executables:
60
52
  - i18n-translate
61
53
  extensions: []
62
-
63
54
  extra_rdoc_files: []
64
-
65
- files:
66
- - bin/i18n-translate
55
+ files:
67
56
  - README.md
68
- - i18n-translators-tools.gemspec
69
57
  - Rakefile
70
- - lib/i18n/translator.rb
58
+ - bin/i18n-translate
59
+ - i18n-translators-tools.gemspec
60
+ - lib/i18n-translate.rb
61
+ - lib/i18n-translators-tools.rb
71
62
  - lib/i18n/backend/po.rb
72
63
  - lib/i18n/backend/properties.rb
73
- - lib/i18n/backend/ts.rb
74
64
  - lib/i18n/backend/translate.rb
75
- - lib/i18n/processor/properties.rb
76
- - lib/i18n/processor/ts.rb
65
+ - lib/i18n/backend/ts.rb
66
+ - lib/i18n/processor.rb
67
+ - lib/i18n/processor/gettext.rb
77
68
  - lib/i18n/processor/gettext_strscan.rb
69
+ - lib/i18n/processor/properties.rb
78
70
  - lib/i18n/processor/ruby.rb
71
+ - lib/i18n/processor/ts.rb
79
72
  - lib/i18n/processor/yaml.rb
80
- - lib/i18n/processor/gettext.rb
81
73
  - lib/i18n/translate.rb
82
- - lib/i18n/processor.rb
83
- - lib/i18n-translate.rb
84
- - test/tc_processor_properties.rb
85
- - test/tc_processor.rb
86
- - test/locale/src/cze.rb
87
- - test/backend.rb
88
- - test/tc_i18n-translate.rb
89
- - test/tc_backend_ts.rb
90
- - test/tc_processor_yaml.rb
91
- - test/tc_processor_ruby.rb
74
+ - lib/i18n/translator.rb
92
75
  - test/all.rb
76
+ - test/backend.rb
77
+ - test/locale/src/cze.po
78
+ - test/locale/src/cze.rb
79
+ - test/locale/src/cze.yml
80
+ - test/locale/src/deep/cze.yml
81
+ - test/locale/src/deep/default.yml
82
+ - test/locale/src/deep/eng.yml
83
+ - test/locale/src/default.yml
84
+ - test/processor.rb
93
85
  - test/tc_backend_po.rb
94
- - test/tc_processor_gettext.rb
86
+ - test/tc_backend_properties.rb
95
87
  - test/tc_backend_ruby.rb
96
88
  - test/tc_backend_translate.rb
97
- - test/tc_processor_ts.rb
98
- - test/processor.rb
89
+ - test/tc_backend_ts.rb
99
90
  - test/tc_backend_yaml.rb
100
- - test/tc_backend_properties.rb
91
+ - test/tc_i18n-translate.rb
92
+ - test/tc_processor.rb
93
+ - test/tc_processor_gettext.rb
94
+ - test/tc_processor_properties.rb
95
+ - test/tc_processor_ruby.rb
96
+ - test/tc_processor_ts.rb
97
+ - test/tc_processor_yaml.rb
101
98
  - test/tc_translate.rb
102
- - test/locale/src/cze.yml
103
- - test/locale/src/default.yml
104
- - test/locale/src/deep/cze.yml
105
- - test/locale/src/deep/eng.yml
106
- - test/locale/src/deep/default.yml
107
- - test/locale/src/cze.po
108
- has_rdoc: true
109
99
  homepage: http://github.com/pejuko/i18n-translators-tools
110
100
  licenses: []
111
-
101
+ metadata: {}
112
102
  post_install_message: |
113
103
  =============================================================================
114
-
104
+
115
105
  I18N TRANSLATORS TOOLS
116
-
106
+
117
107
  -----------------------------------------------------------------------------
118
-
108
+
119
109
  Supported formats:
120
110
  * yml
121
111
  * rb
122
112
  * ts
123
113
  * po
124
114
  * properties
125
-
115
+
126
116
  Backends:
127
117
  * Extended format. i18n-translators-tools brings extended format
128
118
  I18n::Backend::Simple.send(:include, I18n::Backend::Translate)
@@ -132,30 +122,18 @@ post_install_message: |
132
122
  I18n::Backend::Simple.send(:include, I18n::Backend::TS)
133
123
  * Java Properties files
134
124
  I18n::Backend::Simple.send(:include, I18n::Backend::Properties)
135
-
125
+
136
126
  Functions:
137
127
  * merge
138
128
  * convert
139
129
  * translate (built-in simple console translator)
140
130
  * statistics
141
-
131
+
142
132
  Changelog:
143
- v0.2.1
144
- * fix: I18n::Backend::Translate now returns nil if translation is empty
145
- string (this allows fallbacks)
146
-
147
- v0.2.2
148
- * fix: don't merge if default file doesn't exist (locale stays untouched)
149
- * fix: for default format autodetection works again
150
- * merge can be more verbose
151
-
152
- v0.2.3
153
- * fix: hash_to_keys can work with enhanced format => default can be in
154
- enchanced format
155
- * default file can be now in enhanced format. if translation field is missing
156
- * i18n-translate <source file> <target file>
157
- automaticlay perform convert action from one file to another
158
-
133
+ v0.2.5
134
+ * fix recursive directory scan (-r and --deep options should work now)
135
+ * enables usage require 'i18n-translators-tools'
136
+
159
137
  v0.2.4
160
138
  * enhanced support for java properties
161
139
  * hard/soft merges. hard deletes deleted keys in target and soft set them to
@@ -163,42 +141,48 @@ post_install_message: |
163
141
  * processors now generate keys list from provided data and not from @tr.default
164
142
  * flag obsolete added
165
143
  * delete function
166
- * i18n-0.5.0 compatibility (for older i18n user v0.2.3)
167
-
144
+ * i18n-0.5.0 compatibility
145
+
146
+
147
+ v0.2.3
148
+ * fix: hash_to_keys can work with enhanced format => default can be in
149
+ enhanced format
150
+ * default file can be now in enhanced format. if translation field is missing
151
+ in default file then field default is used instead
152
+ * i18n-translate <source file> <target file>
153
+ automaticlay perform convert action from one file to another
154
+
155
+
156
+ v0.2.2
157
+ * fix: don't merge if default file doesn't exist
158
+ * fix: for default format autodetection works again
159
+ * merge can be more verbose
160
+
161
+
168
162
  For more information read README.md and CHANGELOG.md
169
-
163
+
170
164
  -----------------------------------------------------------------------------
171
-
165
+
172
166
  http://github.com/pejuko/i18n-translators-tools
173
-
174
- =============================================================================
175
167
 
168
+ =============================================================================
176
169
  rdoc_options: []
177
-
178
- require_paths:
170
+ require_paths:
179
171
  - lib
180
- required_ruby_version: !ruby/object:Gem::Requirement
181
- none: false
182
- requirements:
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
183
174
  - - ">="
184
- - !ruby/object:Gem::Version
185
- segments:
186
- - 0
187
- version: "0"
188
- required_rubygems_version: !ruby/object:Gem::Requirement
189
- none: false
190
- requirements:
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
191
179
  - - ">="
192
- - !ruby/object:Gem::Version
193
- segments:
194
- - 0
195
- version: "0"
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
196
182
  requirements: []
197
-
198
183
  rubyforge_project:
199
- rubygems_version: 1.3.7
184
+ rubygems_version: 2.4.6
200
185
  signing_key:
201
- specification_version: 3
186
+ specification_version: 4
202
187
  summary: I18n translation utility which helps to manage files with locales.
203
188
  test_files: []
204
-