i18n-tasks-csv 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 280d2fc9dbbbd4cf8d254df090b8581f93656650
4
+ data.tar.gz: 27487f46a0793abaad9da8f872a790df8a8b90e2
5
+ SHA512:
6
+ metadata.gz: 52e24ef583fb62aa3fb86266ab0d40f0652a3bb976adc3f4e53c38a0465f55c3d67180a7a72d8992b4683403fa06570dcf6750469e706b0eaf0b1ed736e84336
7
+ data.tar.gz: b676b77722609f5483b48167995e6120d5aae44ac6f715a616b84b0116dba90dd625fe6d97cd687539cb9a2680fe61b8f7a97361a614ade88057642a2a67a7ff
@@ -0,0 +1,36 @@
1
+ == Contributing
2
+
3
+ I value any contribution to i18n-tasks-csv you can provide: a bug report, a
4
+ feature request, or code contributions.
5
+
6
+ === Dependencies
7
+
8
+ i18n-tasks-csv uses Ryan Davis’s {Hoe}[https://github.com/seattlerb/hoe] to
9
+ manage the release process, and it adds a number of rake tasks. To assist with
10
+ the installation of the development dependencies for i18n-tasks-csv, I have
11
+ provided the simplest possible Gemfile pointing to the (generated)
12
+ +i18n-tasks-csv.gemspec+ file. This will permit you to do:
13
+
14
+ $ bundle install
15
+
16
+ to get the development dependencies.
17
+
18
+ === Workflow
19
+
20
+ Here's the most direct way to get your work merged into the project:
21
+
22
+ * Fork the project.
23
+ * Clone down your fork (<tt>git clone git://github.com/<username>/i18n-tasks-csv.git</tt>).
24
+ * Create a topic branch to contain your change (<tt>git checkout -b my\_awesome\_feature</tt>).
25
+ * Hack away, add tests. Not necessarily in that order.
26
+ * Make sure everything still passes by running +rake+.
27
+ * If necessary, rebase your commits into logical chunks, without errors.
28
+ * Push the branch up (<tt>git push origin my\_awesome\_feature</tt>).
29
+ * Create a pull request against halostatue/i18n-tasks-csv and describe
30
+ what your change does and the why you think it should be merged.
31
+
32
+ === Contributors
33
+
34
+ * Austin Ziegler created i18n-tasks-csv based on work by Kai Schlicting.
35
+ * Kai Schlicting created the tasks originally presented in the {i18n-tasks
36
+ Wiki}[https://github.com/glebm/i18n-tasks/wiki/Custom-CSV-import-and-export-tasks].
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # -*- ruby -*-
2
+
3
+ # NOTE: This file is present to keep Travis CI happy. Edits to it will not
4
+ # be accepted.
5
+
6
+ source "https://rubygems.org/"
7
+ gemspec
8
+
9
+ # vim: syntax=ruby
@@ -0,0 +1,8 @@
1
+ === 1.0 / 2015-07-08
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday as a gem, pulled from the
6
+ {i18n-tasks
7
+ Wiki}[https://github.com/glebm/i18n-tasks/wiki/Custom-CSV-import-and-export-tasks]
8
+ originally by @lacco.
@@ -0,0 +1,27 @@
1
+ == Licence
2
+
3
+ This software is available under an MIT-style licence.
4
+
5
+ * Copyright 2014–2015 Kai Schlicting
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11
+ of the Software, and to permit persons to whom the Software is furnished to do
12
+ so, subject to the following conditions:
13
+
14
+ * The names of its contributors may not be used to endorse or promote
15
+ products derived from this software without specific prior written
16
+ permission.
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ Contributing.rdoc
2
+ Gemfile
3
+ History.rdoc
4
+ Licence.rdoc
5
+ Manifest.txt
6
+ README.rdoc
7
+ Rakefile
8
+ lib/i18n-tasks-csv.rb
@@ -0,0 +1,14 @@
1
+ = i18n-tasks-csv
2
+
3
+ home :: https://github.com/halostatue/i18n-tasks-csv/
4
+ bugs :: https://github.com/halostatue/i18n-tasks-csv/issues
5
+
6
+ == Description
7
+
8
+ This is a packaged gem version of the CSV import/export tasks on the
9
+ {i18n-tasks
10
+ Wiki}[https://github.com/glebm/i18n-tasks/wiki/Custom-CSV-import-and-export-tasks].
11
+
12
+ :include: Contributing.rdoc
13
+
14
+ :include: Licence.rdoc
@@ -0,0 +1,46 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ # Hoe.plugin :compiler
7
+ # Hoe.plugin :email
8
+ # Hoe.plugin :gem_prelude_sucks
9
+ # Hoe.plugin :geminabox
10
+ # Hoe.plugin :history
11
+ # Hoe.plugin :inline
12
+ # Hoe.plugin :perforce
13
+ # Hoe.plugin :racc
14
+ # Hoe.plugin :rcov
15
+ # Hoe.plugin :rdoc
16
+ # Hoe.plugin :rubygems
17
+ # Hoe.plugin :seattlerb
18
+ Hoe.plugin :doofus
19
+ Hoe.plugin :gemspec2
20
+ Hoe.plugin :git
21
+ Hoe.plugin :minitest
22
+ Hoe.plugin :travis
23
+
24
+ Hoe.spec 'i18n-tasks-csv' do
25
+ developer('Austin Ziegler', 'halostatue@gmail.com')
26
+
27
+ self.need_tar = true
28
+
29
+ self.history_file = 'History.rdoc'
30
+ self.readme_file = 'README.rdoc'
31
+ self.extra_rdoc_files = FileList['*.rdoc'].to_a
32
+
33
+ license 'MIT'
34
+
35
+ extra_deps << ['i18n-tasks', '~> 0.8']
36
+
37
+ extra_dev_deps << ['hoe-doofus', '~> 1.0']
38
+ extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
39
+ extra_dev_deps << ['hoe-git', '~> 1.5']
40
+ extra_dev_deps << ['hoe-rubygems', '~> 1.0']
41
+ extra_dev_deps << ['hoe-travis', '~> 1.2']
42
+ extra_dev_deps << ['minitest', '~> 5.2']
43
+ extra_dev_deps << ['rake', '~> 10.0']
44
+ end
45
+
46
+ # vim: syntax=ruby
@@ -0,0 +1,66 @@
1
+ require 'csv'
2
+
3
+ module I18nTasksCsv
4
+ VERSION = '1.0'
5
+
6
+ include ::I18n::Tasks::Command::Collection
7
+ cmd :csv_export, desc: 'export translations to CSV'
8
+ def csv_export(_opts = {})
9
+ translations_by_path = {}
10
+ router = I18n::Tasks::Data::Router::
11
+ PatternRouter.new(nil, write: i18n.config['csv']['export'])
12
+
13
+ i18n.locales.each do |locale|
14
+ router.route(locale, i18n.data_forest) do |path, nodes|
15
+ translations_by_path[path] ||= {}
16
+ translations_by_path[path][locale] ||= {}
17
+
18
+ nodes.leaves do |node|
19
+ translations_by_path[path][locale][node.full_key(root: false)] =
20
+ node.value
21
+ end
22
+ end
23
+ end
24
+
25
+ translations_by_path.each do |(path, translations_by_locale)|
26
+ FileUtils.mkdir_p(File.dirname(path))
27
+
28
+ CSV.open(path, 'wb') do |csv|
29
+ csv << (['key'] + i18n.locales)
30
+
31
+ translations_by_locale[i18n.base_locale].keys.each do |key|
32
+ values = i18n.locales.map do |locale|
33
+ translations_by_locale[locale][key]
34
+ end
35
+ csv << values.unshift(key)
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ cmd :csv_import, desc: 'import translations from CSV'
42
+ def csv_import(_opts = {})
43
+ i18n.config['csv']['import'].each do |file|
44
+ csv = open(file).read.force_encoding('UTF-8')
45
+
46
+ translations = []
47
+ CSV.parse(csv, headers: true) do |row|
48
+ key = row['key']
49
+ next unless key
50
+
51
+ i18n.locales.each do |locale|
52
+ unless row.key?(locale)
53
+ fail "Locale missing for key #{key}! (locales in app: " \
54
+ "#{locales} / locales in file: #{row.headers.inspect})"
55
+ end
56
+ translations << [[locale, key].join('.'), row[locale]]
57
+ end
58
+ end
59
+
60
+ i18n.data.merge! \
61
+ I18n::Tasks::Data::Tree::Siblings.from_flat_pairs(translations)
62
+ end
63
+ end
64
+ end
65
+
66
+ I18n::Tasks::Commands.send :include, I18nTasksCsv
metadata ADDED
@@ -0,0 +1,207 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n-tasks-csv
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Austin Ziegler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: i18n-tasks
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe-doofus
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hoe-gemspec2
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: hoe-git
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: hoe-rubygems
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: hoe-travis
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '10.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '10.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: hoe
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.13'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.13'
153
+ description: |-
154
+ This is a packaged gem version of the CSV import/export tasks on the
155
+ {i18n-tasks
156
+ Wiki}[https://github.com/glebm/i18n-tasks/wiki/Custom-CSV-import-and-export-tasks].
157
+
158
+ :include: Contributing.rdoc
159
+
160
+ :include: Licence.rdoc
161
+ email:
162
+ - halostatue@gmail.com
163
+ executables: []
164
+ extensions: []
165
+ extra_rdoc_files:
166
+ - Contributing.rdoc
167
+ - History.rdoc
168
+ - Licence.rdoc
169
+ - Manifest.txt
170
+ - README.rdoc
171
+ files:
172
+ - Contributing.rdoc
173
+ - Gemfile
174
+ - History.rdoc
175
+ - Licence.rdoc
176
+ - Manifest.txt
177
+ - README.rdoc
178
+ - Rakefile
179
+ - lib/i18n-tasks-csv.rb
180
+ homepage: https://github.com/halostatue/i18n-tasks-csv/
181
+ licenses:
182
+ - MIT
183
+ metadata: {}
184
+ post_install_message:
185
+ rdoc_options:
186
+ - "--main"
187
+ - README.rdoc
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 2.4.5
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: This is a packaged gem version of the CSV import/export tasks on the {i18n-tasks
206
+ Wiki}[https://github.com/glebm/i18n-tasks/wiki/Custom-CSV-import-and-export-tasks]
207
+ test_files: []