n42translation 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +13 -10
- data/lib/n42translation/cli.rb +16 -10
- data/lib/n42translation/config.rb +1 -1
- data/lib/n42translation/csv_convert.rb +15 -12
- data/lib/n42translation/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e70af4ad0c11621e44f9ad9adc1a0f36fa0cb6c4
|
4
|
+
data.tar.gz: 15ab09f954d2268539f0156abaeca16b6ff97fc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39afed9be9e708930a1ccacf2a601e4b04afd54460f7ff45bbdba736047e9b02deb70a8b7da5ab892b438eb28b3bb01223653a5e1a6b549b6ee11c13b50bc66c
|
7
|
+
data.tar.gz: aa45a8991a502022a4a2ca194c29d7c2dbb2c7f3b27bb01261b03f8f3153b8381b99b9f8acc693a920b23f30db8f880ee3699b5675fa318c4bc7af263cb85d41
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
n42translation (0.
|
5
|
-
activesupport
|
6
|
-
builder
|
7
|
-
thor
|
4
|
+
n42translation (0.1.2)
|
5
|
+
activesupport (~> 4.2)
|
6
|
+
builder (~> 3.2)
|
7
|
+
thor (~> 0.19)
|
8
|
+
write_xlsx (~> 0.83)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
activesupport (4.2.1)
|
13
|
+
activesupport (4.2.7.1)
|
13
14
|
i18n (~> 0.7)
|
14
15
|
json (~> 1.7, >= 1.7.7)
|
15
16
|
minitest (~> 5.1)
|
@@ -17,10 +18,10 @@ GEM
|
|
17
18
|
tzinfo (~> 1.1)
|
18
19
|
builder (3.2.2)
|
19
20
|
i18n (0.7.0)
|
20
|
-
json (1.8.
|
21
|
-
minitest (5.
|
21
|
+
json (1.8.3)
|
22
|
+
minitest (5.9.1)
|
22
23
|
rubyzip (1.1.7)
|
23
|
-
thor (0.19.
|
24
|
+
thor (0.19.4)
|
24
25
|
thread_safe (0.3.5)
|
25
26
|
tzinfo (1.2.2)
|
26
27
|
thread_safe (~> 0.1)
|
@@ -34,6 +35,8 @@ PLATFORMS
|
|
34
35
|
ruby
|
35
36
|
|
36
37
|
DEPENDENCIES
|
37
|
-
bundler (
|
38
|
+
bundler (~> 1.6)
|
38
39
|
n42translation!
|
39
|
-
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
1.10.6
|
data/lib/n42translation/cli.rb
CHANGED
@@ -211,12 +211,15 @@ module N42translation
|
|
211
211
|
|
212
212
|
def build_csv(source_path, project_name, outputfile_path, platforms, default_language)
|
213
213
|
languages = get_languages(project_name)
|
214
|
-
language_yamls = {}
|
215
|
-
languages.each do |language|
|
216
|
-
language_yamls["#{language}"] = platforms.map {|platform| yaml_for_platform_and_lang(source_path, project_name, platform, language) }.reduce({}, :merge)
|
217
|
-
end
|
218
214
|
|
219
|
-
|
215
|
+
language_hashes = languages.map do |language|
|
216
|
+
d = platforms.map do |platform|
|
217
|
+
join_hash_keys(yaml_for_platform_and_lang(source_path, project_name, platform, language), '.')
|
218
|
+
end.reduce({},:merge)
|
219
|
+
[language.to_sym, d]
|
220
|
+
end.to_h
|
221
|
+
|
222
|
+
csv_data = N42translation::CSVConvert.createCSV(language_hashes, languages, language_hashes[default_language.to_sym], default_language )
|
220
223
|
|
221
224
|
filename = File.join(outputfile_path,'csv',"#{project_name}.csv")
|
222
225
|
FileUtils.mkpath(File.dirname(filename))
|
@@ -225,12 +228,15 @@ module N42translation
|
|
225
228
|
|
226
229
|
def build_xlsx(source_path, project_name, outputfile_path, platforms, default_language)
|
227
230
|
languages = get_languages(project_name)
|
228
|
-
language_yamls = {}
|
229
|
-
languages.each do |language|
|
230
|
-
language_yamls["#{language}"] = platforms.map {|platform| yaml_for_platform_and_lang(source_path, project_name, platform, language) }.reduce({}, :merge)
|
231
|
-
end
|
232
231
|
|
233
|
-
|
232
|
+
language_hashes = languages.map do |language|
|
233
|
+
d = platforms.map do |platform|
|
234
|
+
join_hash_keys(yaml_for_platform_and_lang(source_path, project_name, platform, language), '.')
|
235
|
+
end.reduce({},:merge)
|
236
|
+
[language.to_sym, d]
|
237
|
+
end.to_h
|
238
|
+
|
239
|
+
csv_data = N42translation::CSVConvert.createCSV(language_hashes, languages, language_hashes[default_language.to_sym], default_language )
|
234
240
|
|
235
241
|
filename = File.join(outputfile_path,'xlsx',"#{project_name}.xlsx")
|
236
242
|
FileUtils.mkpath(File.dirname(filename))
|
@@ -2,31 +2,34 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module N42translation
|
4
4
|
class CSVConvert
|
5
|
-
def self.createCSV(
|
5
|
+
def self.createCSV(language_hashes, langs, default_yml, default_language)
|
6
6
|
|
7
|
-
keys =
|
7
|
+
keys = language_hashes.dup.map do |lang, lang_hash|
|
8
|
+
lang_hash.keys
|
9
|
+
end.flatten.uniq
|
8
10
|
|
9
11
|
rows = []
|
10
12
|
rows << ["key",langs].flatten
|
11
13
|
|
12
14
|
keys.each do |key|
|
13
|
-
rows << [
|
15
|
+
rows << [
|
16
|
+
key,
|
17
|
+
get_values_from_key(language_hashes, key, default_yml, default_language)
|
18
|
+
].flatten
|
14
19
|
end
|
15
20
|
|
16
21
|
rows
|
17
22
|
end
|
18
23
|
|
19
24
|
private
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
|
26
|
+
def self.get_values_from_key(language_hashes, key, default_yml, default_language)
|
27
|
+
default_language_name = default_language.to_s.upcase
|
28
|
+
language_hashes.map do |lang, language_hash|
|
29
|
+
val = language_hash[key.to_s]
|
30
|
+
if val.nil?
|
24
31
|
default_val = default_yml[key.to_s]
|
25
|
-
|
26
|
-
"TODO: "
|
27
|
-
else
|
28
|
-
"TODO: #{default_val}(#{default_language.to_s.upcase})"
|
29
|
-
end
|
32
|
+
"TODO: #{default_val.nil? ? '' : "#{default_val}(#{default_language_name})"}"
|
30
33
|
else
|
31
34
|
val
|
32
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: n42translation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wolfgang Lutz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: 1.3.6
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project: n42translation
|
143
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.5.2
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Translation helper to build translations files from a single source
|